9
9
import com .segment .analytics .integrations .IdentifyPayload ;
10
10
import com .segment .analytics .integrations .Logger ;
11
11
import com .segment .analytics .integrations .TrackPayload ;
12
- import com .segment .analytics .test .TrackPayloadBuilder ;
13
12
14
- import org .hamcrest .Description ;
15
- import org .hamcrest .TypeSafeMatcher ;
16
13
import org .json .JSONException ;
17
14
import org .json .JSONObject ;
18
15
import org .junit .Before ;
19
16
import org .junit .Rule ;
20
17
import org .junit .Test ;
21
18
import org .junit .runner .RunWith ;
22
19
import org .mockito .ArgumentMatcher ;
23
- import org .mockito .InOrder ;
24
20
import org .mockito .Mockito ;
25
21
import org .powermock .api .mockito .PowerMockito ;
26
22
import org .powermock .core .classloader .annotations .PowerMockIgnore ;
37
33
import static com .segment .analytics .Analytics .LogLevel .VERBOSE ;
38
34
import static org .mockito .Matchers .argThat ;
39
35
import static org .mockito .Matchers .eq ;
40
- import static org .mockito .Mockito .inOrder ;
41
36
import static org .mockito .Mockito .verify ;
42
37
43
38
@ RunWith (RobolectricTestRunner .class )
@@ -100,6 +95,7 @@ public void trackWithProperties() {
100
95
.putValue ("string" , "foo" )
101
96
.putValue ("date" , new Date (117 , 0 , 1 ))
102
97
.putValue ("key with spaces" , "bar" )
98
+ .putValue ("key.with.periods" , "test" )
103
99
.putValue ("total" , 100.0 )
104
100
.putValue (" extra spaces " , "baz" );
105
101
@@ -111,13 +107,42 @@ public void trackWithProperties() {
111
107
expected .putString ("string" , "foo" );
112
108
expected .putString ("date" , String .valueOf (new Date (117 , 0 , 1 )));
113
109
expected .putString ("key_with_spaces" , "bar" );
110
+ expected .putString ("key_with_periods" , "test" );
114
111
expected .putDouble ("value" , 100.0 );
115
112
expected .putString ("currency" , "USD" );
116
113
expected .putString ("extra_spaces" , "baz" );
117
114
118
115
verify (firebase ).logEvent (eq ("foo" ), bundleEq (expected ));
119
116
}
120
117
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
+
121
146
/**
122
147
* Uses the string representation of the object. Useful for JSON objects.
123
148
* @param expected Expected object
0 commit comments