99import com .segment .analytics .integrations .IdentifyPayload ;
1010import com .segment .analytics .integrations .Logger ;
1111import com .segment .analytics .integrations .TrackPayload ;
12- import com .segment .analytics .test .TrackPayloadBuilder ;
1312
14- import org .hamcrest .Description ;
15- import org .hamcrest .TypeSafeMatcher ;
1613import org .json .JSONException ;
1714import org .json .JSONObject ;
1815import org .junit .Before ;
1916import org .junit .Rule ;
2017import org .junit .Test ;
2118import org .junit .runner .RunWith ;
2219import org .mockito .ArgumentMatcher ;
23- import org .mockito .InOrder ;
2420import org .mockito .Mockito ;
2521import org .powermock .api .mockito .PowerMockito ;
2622import org .powermock .core .classloader .annotations .PowerMockIgnore ;
3733import static com .segment .analytics .Analytics .LogLevel .VERBOSE ;
3834import static org .mockito .Matchers .argThat ;
3935import static org .mockito .Matchers .eq ;
40- import static org .mockito .Mockito .inOrder ;
4136import static org .mockito .Mockito .verify ;
4237
4338@ RunWith (RobolectricTestRunner .class )
@@ -100,6 +95,7 @@ public void trackWithProperties() {
10095 .putValue ("string" , "foo" )
10196 .putValue ("date" , new Date (117 , 0 , 1 ))
10297 .putValue ("key with spaces" , "bar" )
98+ .putValue ("key.with.periods" , "test" )
10399 .putValue ("total" , 100.0 )
104100 .putValue (" extra spaces " , "baz" );
105101
@@ -111,13 +107,42 @@ public void trackWithProperties() {
111107 expected .putString ("string" , "foo" );
112108 expected .putString ("date" , String .valueOf (new Date (117 , 0 , 1 )));
113109 expected .putString ("key_with_spaces" , "bar" );
110+ expected .putString ("key_with_periods" , "test" );
114111 expected .putDouble ("value" , 100.0 );
115112 expected .putString ("currency" , "USD" );
116113 expected .putString ("extra_spaces" , "baz" );
117114
118115 verify (firebase ).logEvent (eq ("foo" ), bundleEq (expected ));
119116 }
120117
118+ @ Test
119+ public void trackWithEventNameTransformation () {
120+ Properties properties = new Properties ()
121+ .putValue ("integer" , 1 )
122+ .putValue ("double" , 1.0 )
123+ .putValue ("string" , "foo" )
124+ .putValue ("date" , new Date (117 , 0 , 1 ))
125+ .putValue ("key with spaces" , "bar" )
126+ .putValue ("key.with.periods" , "test" )
127+ .putValue ("total" , 100.0 )
128+ .putValue (" extra spaces " , "baz" );
129+
130+ integration .track (new TrackPayload .Builder ().anonymousId ("1234" ).properties (properties ).event ("foo.bar" ).build ());
131+
132+ Bundle expected = new Bundle ();
133+ expected .putInt ("integer" , 1 );
134+ expected .putDouble ("double" , 1.0 );
135+ expected .putString ("string" , "foo" );
136+ expected .putString ("date" , String .valueOf (new Date (117 , 0 , 1 )));
137+ expected .putString ("key_with_spaces" , "bar" );
138+ expected .putString ("key_with_periods" , "test" );
139+ expected .putDouble ("value" , 100.0 );
140+ expected .putString ("currency" , "USD" );
141+ expected .putString ("extra_spaces" , "baz" );
142+
143+ verify (firebase ).logEvent (eq ("foo_bar" ), bundleEq (expected ));
144+ }
145+
121146 /**
122147 * Uses the string representation of the object. Useful for JSON objects.
123148 * @param expected Expected object
0 commit comments