@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")); }
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; }    }