### Question:
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; }    }### Answer:
@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")); }
@Test public void shouldIncludeCustomAttributes() throws Exception { final Company withCustomAttributes = new Company().setName("Weyland Corp").setCompanyID("2093"); withCustomAttributes.addCustomAttribute(CustomAttribute.newIntegerAttribute("foodstuff-items", 246)); withCustomAttributes.addCustomAttribute(CustomAttribute.newStringAttribute("bestseller", "fruity oaty bar")); final List<CompanyWithStringPlan> updatedCompanies = CompanyUpdateBuilder.buildUserUpdateCompanies(new CompanyCollection(Lists.newArrayList(withCustomAttributes)), null); CompanyWithStringPlan weylandCorp = null; for (CompanyWithStringPlan updatedCompany : updatedCompanies) { if (updatedCompany.getCompanyID().equals("2093")) { weylandCorp = updatedCompany; } } assertNotNull(weylandCorp); assertNotNull(weylandCorp.getCustomAttributes()); Map<String, CustomAttribute> retrievedAttributes = weylandCorp.getCustomAttributes(); assertNotNull(retrievedAttributes.get("foodstuff-items")); assertTrue(retrievedAttributes.get("foodstuff-items").getValue().equals(246)); assertNotNull(retrievedAttributes.get("bestseller")); assertTrue(retrievedAttributes.get("bestseller").getValue().equals("fruity oaty bar")); }