android - How to Compare two arrays objects with nested objects? -


i writing test case need compare 2 array objects contains nested objects. here sample code please check.

class testgeonames {      private status status;     public void setstatus(status lstatus) {         status = lstatus;     }     public class status {         private string mesg;         private string value;          public string getmesg() {             return mesg;         }          public void setmesg(string mesg) {             this.mesg = mesg;         }          public string getvalue() {             return value;         }          public void setvalue(string value) {             this.value = value;         }      }  } 

here testcase code:

list<testgeonames > result = networkmanager.executebyjson(request, testgeonames .class);      list<testgeonames > cacheresult = cachemanager.getresponsefromcache(request);      assertnotnull(result);     assertnotnull(cacheresult);      testgeonamesbean[] tgb = new testgeonamesbean[0];     testgeonamesbean[] cacheresultarray = result.toarray(tgb);     testgeonamesbean[] resultarray = cacheresult.toarray(tgb);       assertequals(true, arrays.equals(resultarray, cacheresultarray)); 

for equals work on custom object have override hashcode() , equals(object o) object class


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -