public void testClickOnChildShouldShowViewPage() throws JSONException { ChildRepository repository = RapidFtrApplication.getInstance().getInjector().getInstance(ChildRepository.class); Child child1 = new Child("id1", "rapidftr", "{\"name\":\"Test1\"}"); repository.createOrUpdate(child1); Child child2 = new Child("id2", "rapidftr", "{\"name\":\"Test2\"}"); repository.createOrUpdate(child2); viewAllChildrenPage.clickChild("id1"); viewAllChildrenPage.verifyChildDetails(child1); }
public void testClickOnChildShouldShowViewPage() throws JSONException { ChildRepository repository = RapidFtrApplication.getApplicationInstance() .getInjector() .getInstance(ChildRepository.class); Child child1 = new Child(getAlphaNumeric(4), "rapidftr", "{\"name\":\"Test1\"}"); repository.createOrUpdate(child1); Child child2 = new Child(getAlphaNumeric(6), "rapidftr", "{\"name\":\"Test2\"}"); repository.createOrUpdate(child2); viewAllChildrenPage.navigateToViewAllPage(); viewAllChildrenPage.clickChild(child1.getUniqueId()); viewAllChildrenPage.verifyChildDetails(child1); }
public void testDisplayAllChildren() throws JSONException { ChildRepository repository = RapidFtrApplication.getInstance().getInjector().getInstance(ChildRepository.class); repository.createOrUpdate(new Child("id1", "rapidftr", "{\"name\":\"Test1\"}")); repository.createOrUpdate(new Child("id2", "rapidftr", "{\"name\":\"Test2\"}")); assertTrue(viewAllChildrenPage.isChildPresent("id1", "Test1")); assertTrue(viewAllChildrenPage.isChildPresent("id2", "Test2")); }
private void saveIncomingChildren(ArrayList<String> idsToDownload) throws IOException, JSONException { for (String idToDownload : idsToDownload) { Child incomingChild = childService.getChild(idToDownload); if (isCancelled()) { break; } try { incomingChild.setSynced(true); if (childRepository.exists(incomingChild.getUniqueId())) { childRepository.update(incomingChild); } else { childRepository.createOrUpdate(incomingChild); } childService.setPhoto(incomingChild); } catch (Exception e) { Log.e("SyncAllDataTask", "Error syncing child", e); throw new RuntimeException(e); } } }