File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
main/java/io/intercom/api
test/java/io/intercom/api Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ private static CompanyWithStringPlan prepareUpdatableCompany(Company company) {
3838 updatableCompany .setSessionCount (company .getSessionCount ());
3939 updatableCompany .setMonthlySpend (company .getMonthlySpend ());
4040 updatableCompany .setRemoteCreatedAt (company .getRemoteCreatedAt ());
41+ if (company .getCustomAttributes () != null ) {
42+ updatableCompany .getCustomAttributes ().putAll (company .getCustomAttributes ());
43+ }
4144 if (company .getPlan () != null ) {
4245 updatableCompany .setPlan (company .getPlan ().getName ());
4346 }
Original file line number Diff line number Diff line change 66import org .junit .Test ;
77
88import java .util .List ;
9+ import java .util .Map ;
910
1011import static org .junit .Assert .*;
1112
@@ -60,4 +61,34 @@ public void testRemove() throws Exception {
6061 assertTrue (baconJson .contains ("true" ));
6162 }
6263
64+ @ Test
65+ public void shouldIncludeCustomAttributes () throws Exception {
66+
67+ final Company withCustomAttributes = new Company ().setName ("Weyland Corp" ).setCompanyID ("2093" );
68+
69+ withCustomAttributes .addCustomAttribute (CustomAttribute .newIntegerAttribute ("foodstuff-items" , 246 ));
70+ withCustomAttributes .addCustomAttribute (CustomAttribute .newStringAttribute ("bestseller" , "fruity oaty bar" ));
71+
72+ final List <CompanyWithStringPlan > updatedCompanies = CompanyUpdateBuilder .buildUserUpdateCompanies (new CompanyCollection (Lists .newArrayList (withCustomAttributes )), null );
73+
74+ CompanyWithStringPlan weylandCorp = null ;
75+
76+ for (CompanyWithStringPlan updatedCompany : updatedCompanies ) {
77+ if (updatedCompany .getCompanyID ().equals ("2093" )) {
78+ weylandCorp = updatedCompany ;
79+ }
80+ }
81+
82+ assertNotNull (weylandCorp );
83+ assertNotNull (weylandCorp .getCustomAttributes ());
84+ Map <String , CustomAttribute > retrievedAttributes = weylandCorp .getCustomAttributes ();
85+
86+ assertNotNull (retrievedAttributes .get ("foodstuff-items" ));
87+ assertTrue (retrievedAttributes .get ("foodstuff-items" ).getValue ().equals (246 ));
88+ assertNotNull (retrievedAttributes .get ("bestseller" ));
89+ assertTrue (retrievedAttributes .get ("bestseller" ).getValue ().equals ("fruity oaty bar" ));
90+
91+
92+ }
93+
6394}
You can’t perform that action at this time.
0 commit comments