@Test public void updateFamilyMissingPhenotype() throws JsonProcessingException, CatalogException { QueryResult<Family> originalFamily = createDummyFamily("Martinez-Martinez"); Phenotype phenotype1 = new Phenotype("dis1", "New name", "New source"); Family family = new Family(); family.setPhenotypes(Arrays.asList(phenotype1)); ObjectMapper jsonObjectMapper = catalogManagerResource.generateNewObjectMapper(); ObjectMap params = new ObjectMap(jsonObjectMapper.writeValueAsString(family)); params = new ObjectMap(FamilyDBAdaptor.QueryParams.PHENOTYPES.key(), params.get(FamilyDBAdaptor.QueryParams.PHENOTYPES.key())); thrown.expect(CatalogException.class); thrown.expectMessage("not present in any member of the family"); familyManager.update(STUDY, originalFamily.first().getName(), params, QueryOptions.empty(), sessionIdUser); }
@Test public void updateFamilyPhenotype() throws JsonProcessingException, CatalogException { QueryResult<Family> originalFamily = createDummyFamily("Martinez-Martinez"); Phenotype phenotype1 = new Phenotype("dis1", "New name", "New source"); Phenotype phenotype2 = new Phenotype("dis2", "New name", "New source"); Phenotype phenotype3 = new Phenotype("dis3", "New name", "New source"); Family family = new Family(); family.setPhenotypes(Arrays.asList(phenotype1, phenotype2, phenotype3)); ObjectMapper jsonObjectMapper = catalogManagerResource.generateNewObjectMapper(); ObjectMap params = new ObjectMap(jsonObjectMapper.writeValueAsString(family)); params = new ObjectMap(FamilyDBAdaptor.QueryParams.PHENOTYPES.key(), params.get(FamilyDBAdaptor.QueryParams.PHENOTYPES.key())); QueryResult<Family> updatedFamily = familyManager.update(STUDY, originalFamily.first().getName(), params, QueryOptions.empty(), sessionIdUser); assertEquals(3, updatedFamily.first().getPhenotypes().size()); // Only one id should be the same as in originalFamilyIds (father id) for (Phenotype phenotype : updatedFamily.first().getPhenotypes()) { assertEquals("New name", phenotype.getName()); assertEquals("New source", phenotype.getSource()); } }
@Test public void updateFamilyMissingMember() throws CatalogException, JsonProcessingException { QueryResult<Family> originalFamily = createDummyFamily("Martinez-Martinez"); Individual father = new Individual().setId("father"); Individual mother = new Individual().setId("mother2"); // We create a new father and mother with the same information to mimic the behaviour of the webservices. Otherwise, we would be // ingesting references to exactly the same object and this test would not work exactly the same way. Individual relFather = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual relChild1 = new Individual().setId("child3") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"), new Phenotype("dis2", "dis2", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Family family = new Family(); family.setMembers(Arrays.asList(relChild1, relFather)); ObjectMapper jsonObjectMapper = catalogManagerResource.generateNewObjectMapper(); ObjectMap params = new ObjectMap(jsonObjectMapper.writeValueAsString(family)); params = new ObjectMap(FamilyDBAdaptor.QueryParams.MEMBERS.key(), params.get(FamilyDBAdaptor.QueryParams.MEMBERS.key())); thrown.expect(CatalogException.class); thrown.expectMessage("not present in the members list"); familyManager.update(STUDY, originalFamily.first().getName(), params, QueryOptions.empty(), sessionIdUser); }