@Test public void testFetchCurrentParentsFromStudentNullChecks() { Map<String, List<Entity>> embeddedData = new HashMap<String, List<Entity>>(); Assert.assertTrue(helper.fetchCurrentParentsFromStudent(mockEntity).size() == 0); Mockito.when(mockEntity.getEmbeddedData()).thenReturn(embeddedData); Assert.assertTrue(helper.fetchCurrentParentsFromStudent(mockEntity).size() == 0); Entity parentAssoc1 = Mockito.mock(Entity.class); Entity parentAssoc2 = Mockito.mock(Entity.class); Map<String, Object> body = Mockito.mock(Map.class); Map<String, Object> body2 = Mockito.mock(Map.class); Mockito.when(parentAssoc1.getBody()).thenReturn(body); Mockito.when(parentAssoc2.getBody()).thenReturn(body2); List<Entity> parentAssociations = Arrays.asList(parentAssoc1, parentAssoc2); embeddedData.put(EntityNames.STUDENT_PARENT_ASSOCIATION, parentAssociations); Assert.assertTrue(helper.fetchCurrentParentsFromStudent(mockEntity).size() == 0); Mockito.when(body.get(Mockito.eq(ParameterConstants.PARENT_ID))).thenReturn("ParentId123"); Mockito.when(body2.get(Mockito.eq(ParameterConstants.PARENT_ID))).thenReturn("ParentId456"); Assert.assertTrue(helper.fetchCurrentParentsFromStudent(mockEntity).size() == 2); }
public Set<String> fetchCurrentParentsFromStudent(Entity student) { Set<String> parents = new TreeSet<String>(); if (student.getEmbeddedData().containsKey(EntityNames.STUDENT_PARENT_ASSOCIATION)) { for (Entity assoc : student.getEmbeddedData().get(EntityNames.STUDENT_PARENT_ASSOCIATION)) { String parentId = (String) assoc.getBody().get(ParameterConstants.PARENT_ID); if (parentId != null) { parents.add(parentId); } } } return parents; }
ExtractorHelper { public Set<String> fetchCurrentParentsFromStudent(Entity student) { Set<String> parents = new TreeSet<String>(); if (student.getEmbeddedData().containsKey(EntityNames.STUDENT_PARENT_ASSOCIATION)) { for (Entity assoc : student.getEmbeddedData().get(EntityNames.STUDENT_PARENT_ASSOCIATION)) { String parentId = (String) assoc.getBody().get(ParameterConstants.PARENT_ID); if (parentId != null) { parents.add(parentId); } } } return parents; } }
ExtractorHelper { public Set<String> fetchCurrentParentsFromStudent(Entity student) { Set<String> parents = new TreeSet<String>(); if (student.getEmbeddedData().containsKey(EntityNames.STUDENT_PARENT_ASSOCIATION)) { for (Entity assoc : student.getEmbeddedData().get(EntityNames.STUDENT_PARENT_ASSOCIATION)) { String parentId = (String) assoc.getBody().get(ParameterConstants.PARENT_ID); if (parentId != null) { parents.add(parentId); } } } return parents; } ExtractorHelper();  ExtractorHelper(EdOrgExtractHelper edOrgExtractHelper); }
ExtractorHelper { public Set<String> fetchCurrentParentsFromStudent(Entity student) { Set<String> parents = new TreeSet<String>(); if (student.getEmbeddedData().containsKey(EntityNames.STUDENT_PARENT_ASSOCIATION)) { for (Entity assoc : student.getEmbeddedData().get(EntityNames.STUDENT_PARENT_ASSOCIATION)) { String parentId = (String) assoc.getBody().get(ParameterConstants.PARENT_ID); if (parentId != null) { parents.add(parentId); } } } return parents; } ExtractorHelper();  ExtractorHelper(EdOrgExtractHelper edOrgExtractHelper); Map<String, DateTime> fetchAllEdOrgsForStudent(Entity student); Map<String, DateTime> updateEdorgToDateMap(Map<String, Object> entityBody, Map<String, DateTime> edOrgToDate,
                                                      String edOrgIdField, String beginDateField, String endDateField); void setDateHelper(DateHelper helper); Set<String> fetchCurrentParentsFromStudent(Entity student); Map<String, Collection<String>> buildSubToParentEdOrgCache(EntityToEdOrgCache edOrgCache); EdOrgExtractHelper getEdOrgExtractHelper(); void setEdOrgExtractHelper(EdOrgExtractHelper edOrgExtractHelper); }
ExtractorHelper { public Set<String> fetchCurrentParentsFromStudent(Entity student) { Set<String> parents = new TreeSet<String>(); if (student.getEmbeddedData().containsKey(EntityNames.STUDENT_PARENT_ASSOCIATION)) { for (Entity assoc : student.getEmbeddedData().get(EntityNames.STUDENT_PARENT_ASSOCIATION)) { String parentId = (String) assoc.getBody().get(ParameterConstants.PARENT_ID); if (parentId != null) { parents.add(parentId); } } } return parents; } ExtractorHelper();  ExtractorHelper(EdOrgExtractHelper edOrgExtractHelper); Map<String, DateTime> fetchAllEdOrgsForStudent(Entity student); Map<String, DateTime> updateEdorgToDateMap(Map<String, Object> entityBody, Map<String, DateTime> edOrgToDate,
                                                      String edOrgIdField, String beginDateField, String endDateField); void setDateHelper(DateHelper helper); Set<String> fetchCurrentParentsFromStudent(Entity student); Map<String, Collection<String>> buildSubToParentEdOrgCache(EntityToEdOrgCache edOrgCache); EdOrgExtractHelper getEdOrgExtractHelper(); void setEdOrgExtractHelper(EdOrgExtractHelper edOrgExtractHelper);  }