@Test public void testRemove() throws Exception { final Company bacon = new Company().setCompanyID("bacon"); final Company pancake = new Company().setCompanyID("pancake"); final List<CompanyWithStringPlan> cos = CompanyUpdateBuilder.buildUserUpdateCompanies( new CompanyCollection(Lists.newArrayList(bacon, pancake)), new CompanyCollection(Lists.newArrayList(bacon))); Boolean baconIsRemoved = null; Boolean pancakeIsRemoved = null; CompanyWithStringPlan baconCo = null; CompanyWithStringPlan pancakeCo = null; for (CompanyWithStringPlan co : cos) { if (co.getCompanyID().equals("pancake")) { pancakeIsRemoved = co.getRemove(); pancakeCo = co; } if (co.getCompanyID().equals("bacon")) { baconIsRemoved = co.getRemove(); baconCo = co; } } assertNull(pancakeIsRemoved); assertTrue(baconIsRemoved); final String pancakeJson = mapper.writeValueAsString(pancakeCo); assertFalse(pancakeJson.contains("remove")); assertFalse(pancakeJson.contains("true")); final String baconJson = mapper.writeValueAsString(baconCo); assertTrue(baconJson.contains("remove")); assertTrue(baconJson.contains("true")); }
static List<CompanyWithStringPlan> buildUserUpdateCompanies(CompanyCollection add, CompanyCollection remove) { final List<CompanyWithStringPlan> updatableCompanies = Lists.newArrayList(); if (add != null) { final List<Company> companies = add.getPage(); for (Company company : companies) { if (!isCompanyInList(company, remove)) { updatableCompanies.add(prepareUpdatableCompany(company)); } } } if (remove != null) { final List<Company> companies = remove.getPage(); for (Company company : companies) { updatableCompanies.add(prepareUpdatableCompany(company).setRemove(Boolean.TRUE)); } } return updatableCompanies; }
CompanyUpdateBuilder { static List<CompanyWithStringPlan> buildUserUpdateCompanies(CompanyCollection add, CompanyCollection remove) { final List<CompanyWithStringPlan> updatableCompanies = Lists.newArrayList(); if (add != null) { final List<Company> companies = add.getPage(); for (Company company : companies) { if (!isCompanyInList(company, remove)) { updatableCompanies.add(prepareUpdatableCompany(company)); } } } if (remove != null) { final List<Company> companies = remove.getPage(); for (Company company : companies) { updatableCompanies.add(prepareUpdatableCompany(company).setRemove(Boolean.TRUE)); } } return updatableCompanies; } }
CompanyUpdateBuilder { static List<CompanyWithStringPlan> buildUserUpdateCompanies(CompanyCollection add, CompanyCollection remove) { final List<CompanyWithStringPlan> updatableCompanies = Lists.newArrayList(); if (add != null) { final List<Company> companies = add.getPage(); for (Company company : companies) { if (!isCompanyInList(company, remove)) { updatableCompanies.add(prepareUpdatableCompany(company)); } } } if (remove != null) { final List<Company> companies = remove.getPage(); for (Company company : companies) { updatableCompanies.add(prepareUpdatableCompany(company).setRemove(Boolean.TRUE)); } } return updatableCompanies; }  }
CompanyUpdateBuilder { static List<CompanyWithStringPlan> buildUserUpdateCompanies(CompanyCollection add, CompanyCollection remove) { final List<CompanyWithStringPlan> updatableCompanies = Lists.newArrayList(); if (add != null) { final List<Company> companies = add.getPage(); for (Company company : companies) { if (!isCompanyInList(company, remove)) { updatableCompanies.add(prepareUpdatableCompany(company)); } } } if (remove != null) { final List<Company> companies = remove.getPage(); for (Company company : companies) { updatableCompanies.add(prepareUpdatableCompany(company).setRemove(Boolean.TRUE)); } } return updatableCompanies; }   }
CompanyUpdateBuilder { static List<CompanyWithStringPlan> buildUserUpdateCompanies(CompanyCollection add, CompanyCollection remove) { final List<CompanyWithStringPlan> updatableCompanies = Lists.newArrayList(); if (add != null) { final List<Company> companies = add.getPage(); for (Company company : companies) { if (!isCompanyInList(company, remove)) { updatableCompanies.add(prepareUpdatableCompany(company)); } } } if (remove != null) { final List<Company> companies = remove.getPage(); for (Company company : companies) { updatableCompanies.add(prepareUpdatableCompany(company).setRemove(Boolean.TRUE)); } } return updatableCompanies; }    }