11package io .intercom .api ;
22
3- import com .fasterxml .jackson .databind .ObjectMapper ;
4- import com .google .common .collect .Lists ;
5- import org .junit .BeforeClass ;
6- import org .junit .Test ;
3+ import static org .junit .Assert .assertFalse ;
4+ import static org .junit .Assert .assertNull ;
5+ import static org .junit .Assert .assertTrue ;
76
87import java .util .List ;
98
10- import static org .junit .Assert .*;
9+ import org .junit .BeforeClass ;
10+ import org .junit .Test ;
11+
12+ import com .fasterxml .jackson .databind .ObjectMapper ;
13+ import com .google .common .collect .Lists ;
1114
1215public class CompanyUpdateBuilderTest {
1316
14- private static ObjectMapper mapper ;
17+ private static ObjectMapper mapper ;
1518
16- @ BeforeClass
17- public static void beforeClass () {
18- mapper = MapperSupport .objectMapper ();
19- }
19+ @ BeforeClass
20+ public static void beforeClass () {
21+ mapper = MapperSupport .objectMapper ();
22+ }
2023
24+ @ Test
25+ public void testRemove () throws Exception {
2126
22- @ Test
23- public void testRemove () throws Exception {
27+ final Company bacon = new Company (). setCompanyID ( "bacon" );
28+ final Company pancake = new Company (). setCompanyID ( "pancake" );
2429
25- final Company bacon = new Company ().setCompanyID ("bacon" );
26- final Company pancake = new Company ().setCompanyID ("pancake" );
30+ final List <CompanyWithStringPlan > cos = CompanyUpdateBuilder .buildUserUpdateCompanies (//
31+ new CompanyCollection (Lists .newArrayList (bacon , pancake )),//
32+ new CompanyCollection (Lists .newArrayList (bacon )));
2733
28- final List <CompanyWithStringPlan > cos = CompanyUpdateBuilder .buildUserUpdateCompanies (
29- new CompanyCollection (Lists .newArrayList (pancake )),
30- new CompanyCollection (Lists .newArrayList (bacon ))
31- );
34+ Boolean baconIsRemoved = null ;
35+ Boolean pancakeIsRemoved = null ;
3236
33- Boolean baconIsRemoved = null ;
34- Boolean pancakeIsRemoved = null ;
37+ CompanyWithStringPlan baconCo = null ;
38+ CompanyWithStringPlan pancakeCo = null ;
3539
36- CompanyWithStringPlan baconCo = null ;
37- CompanyWithStringPlan pancakeCo = null ;
40+ for (CompanyWithStringPlan co : cos ) {
41+ if (co .getCompanyID ().equals ("pancake" )) {
42+ pancakeIsRemoved = co .getRemove ();
43+ pancakeCo = co ;
44+ }
3845
39- for (CompanyWithStringPlan co : cos ) {
40- if (co .getCompanyID ().equals ("pancake" )) {
41- pancakeIsRemoved = co .getRemove ();
42- pancakeCo = co ;
43- }
46+ if (co .getCompanyID ().equals ("bacon" )) {
47+ baconIsRemoved = co .getRemove ();
48+ baconCo = co ;
49+ }
4450
45- if (co .getCompanyID ().equals ("bacon" )) {
46- baconIsRemoved = co .getRemove ();
47- baconCo = co ;
48- }
51+ }
52+ assertNull (pancakeIsRemoved );
53+ assertTrue (baconIsRemoved );
4954
50- }
51- assertNull ( pancakeIsRemoved );
52- assertTrue ( baconIsRemoved );
55+ final String pancakeJson = mapper . writeValueAsString ( pancakeCo );
56+ assertFalse ( pancakeJson . contains ( "remove" ) );
57+ assertFalse ( pancakeJson . contains ( "true" ) );
5358
54- final String pancakeJson = mapper .writeValueAsString (pancakeCo );
55- assertFalse ( pancakeJson .contains ("remove" ));
56- assertFalse ( pancakeJson .contains ("true" ));
59+ final String baconJson = mapper .writeValueAsString (baconCo );
60+ assertTrue ( baconJson .contains ("remove" ));
61+ assertTrue ( baconJson .contains ("true" ));
5762
58- final String baconJson = mapper .writeValueAsString (baconCo );
59- assertTrue (baconJson .contains ("remove" ));
60- assertTrue (baconJson .contains ("true" ));
61- }
63+ }
6264
6365}
0 commit comments