Skip to content

Commit 71aa9fa

Browse files
committed
Migrate from is(Not)SameAs to is(Not)SameInstanceAs.
They behave identically, and the old names are being removed. This requires updating to Truth 0.44 or higher, so I've gone straight to 0.45.
1 parent 62b366a commit 71aa9fa

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

firebase-common/src/androidTest/java/com/google/firebase/FirebaseAppTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,18 +349,18 @@ public void testInitializeApp_shouldDiscoverAndInitializeComponents() {
349349

350350
Context appContext = mockContext.getApplicationContext();
351351

352-
assertThat(firebaseApp.get(Context.class)).isSameAs(appContext);
353-
assertThat(firebaseApp.get(FirebaseApp.class)).isSameAs(firebaseApp);
352+
assertThat(firebaseApp.get(Context.class)).isSameInstanceAs(appContext);
353+
assertThat(firebaseApp.get(FirebaseApp.class)).isSameInstanceAs(firebaseApp);
354354

355355
TestComponentOne one = firebaseApp.get(TestComponentOne.class);
356356
assertThat(one).isNotNull();
357-
assertThat(one.getContext()).isSameAs(appContext);
357+
assertThat(one.getContext()).isSameInstanceAs(appContext);
358358

359359
TestComponentTwo two = firebaseApp.get(TestComponentTwo.class);
360360
assertThat(two).isNotNull();
361-
assertThat(two.getApp()).isSameAs(firebaseApp);
362-
assertThat(two.getOptions()).isSameAs(firebaseApp.getOptions());
363-
assertThat(two.getOne()).isSameAs(one);
361+
assertThat(two.getApp()).isSameInstanceAs(firebaseApp);
362+
assertThat(two.getOptions()).isSameInstanceAs(firebaseApp.getOptions());
363+
assertThat(two.getOne()).isSameInstanceAs(one);
364364
}
365365

366366
@Test

firebase-common/src/androidTest/java/com/google/firebase/FirebaseOptionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void createOptionsWithAppIdMissing() {
7979
@Test
8080
public void checkToBuilderCreatesNewEquivalentInstance() {
8181
FirebaseOptions allValuesOptionsCopy = new FirebaseOptions.Builder(ALL_VALUES_OPTIONS).build();
82-
assertThat(allValuesOptionsCopy).isNotSameAs(ALL_VALUES_OPTIONS);
82+
assertThat(allValuesOptionsCopy).isNotSameInstanceAs(ALL_VALUES_OPTIONS);
8383
assertThat(allValuesOptionsCopy).isEqualTo(ALL_VALUES_OPTIONS);
8484
}
8585
}

firebase-common/src/test/java/com/google/firebase/components/ComponentRuntimeTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public void container_withValidDependencyGraph_shouldProperlyInjectComponents()
114114

115115
ComponentTwo componentTwo = runtime.get(ComponentTwo.class);
116116
assertThat(componentTwo.getOne()).isNotNull();
117-
assertThat(componentTwo.getOne().getTracker()).isSameAs(initTracker);
117+
assertThat(componentTwo.getOne().getTracker()).isSameInstanceAs(initTracker);
118118

119119
assertThat(initTracker.isInitialized()).isTrue();
120120
}
@@ -193,7 +193,7 @@ public void container_withCyclicProviderDependency_shouldProperlyInitialize() {
193193
assertThat(one.cyclicTwo).isNotNull();
194194
Provider<CyclicOne> oneProvider = one.cyclicTwo.cyclicOne;
195195
assertThat(oneProvider).isNotNull();
196-
assertThat(oneProvider.get()).isSameAs(one);
196+
assertThat(oneProvider.get()).isSameInstanceAs(one);
197197
}
198198

199199
@Test
@@ -230,8 +230,8 @@ public void container_shouldExposeAllProvidedInterfacesOfAComponent() {
230230
Provider<Parent> parent = runtime.getProvider(Parent.class);
231231
assertThat(parent).isNotNull();
232232

233-
assertThat(child).isSameAs(parent);
234-
assertThat(child.get()).isSameAs(parent.get());
233+
assertThat(child).isSameInstanceAs(parent);
234+
assertThat(child.get()).isSameInstanceAs(parent.get());
235235
}
236236

237237
@Test

firebase-common/src/test/java/com/google/firebase/components/ComponentTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void of_withMultipleInterfaces_shouldSetCorrectDefaults() {
4242
assertThat(component.isAlwaysEager()).isFalse();
4343
assertThat(component.isEagerInDefaultApp()).isFalse();
4444
assertThat(component.getDependencies()).isEmpty();
45-
assertThat(component.getFactory().create(null)).isSameAs(testClass);
45+
assertThat(component.getFactory().create(null)).isSameInstanceAs(testClass);
4646
}
4747

4848
@Test
@@ -193,6 +193,6 @@ public void build_withNoFactoryProvided_shouldThrow() {
193193
public void getFactory_shouldReturnFactorySetInBuilder() {
194194
Component<TestClass> component =
195195
Component.builder(TestClass.class).factory(nullFactory).build();
196-
assertThat(component.getFactory()).isSameAs(nullFactory);
196+
assertThat(component.getFactory()).isSameInstanceAs(nullFactory);
197197
}
198198
}

firebase-common/src/test/java/com/google/firebase/components/LazyTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void get_whenLazyIsInitializedWithValue_shouldReturnTheValue() {
4646
Object instance = new Object();
4747
Lazy<Object> lazy = new Lazy<>(instance);
4848

49-
assertThat(lazy.get()).isSameAs(instance);
49+
assertThat(lazy.get()).isSameInstanceAs(instance);
5050
}
5151

5252
@Test
@@ -56,7 +56,7 @@ public void get_shouldDelegateToFactory() {
5656

5757
when(mockProvider.get()).thenReturn(instance);
5858

59-
assertThat(lazy.get()).isSameAs(instance);
59+
assertThat(lazy.get()).isSameInstanceAs(instance);
6060

6161
verify(mockProvider, times(1)).get();
6262
}

firebase-common/src/test/java/com/google/firebase/components/RestrictedComponentContainerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void get_withAllowedClass_shouldReturnAnInstanceOfThatClass() {
5757
Float value = 1.0f;
5858
when(delegate.get(Float.class)).thenReturn(value);
5959

60-
assertThat(container.get(Float.class)).isSameAs(value);
60+
assertThat(container.get(Float.class)).isSameInstanceAs(value);
6161
verify(delegate).get(Float.class);
6262
}
6363

@@ -96,7 +96,7 @@ public void getProvider_withAllowedClass_shouldReturnAnInstanceOfThatClass() {
9696
Double value = 3.0d;
9797
when(delegate.getProvider(Double.class)).thenReturn(new Lazy<>(value));
9898

99-
assertThat(container.getProvider(Double.class).get()).isSameAs(value);
99+
assertThat(container.getProvider(Double.class).get()).isSameInstanceAs(value);
100100
verify(delegate).getProvider(Double.class);
101101
}
102102

@@ -125,7 +125,7 @@ public void setOf_withAllowedClass_shouldReturnExpectedSet() {
125125
Set<Long> set = Collections.emptySet();
126126
when(delegate.setOf(Long.class)).thenReturn(set);
127127

128-
assertThat(container.setOf(Long.class)).isSameAs(set);
128+
assertThat(container.setOf(Long.class)).isSameInstanceAs(set);
129129
verify(delegate).setOf(Long.class);
130130
}
131131

@@ -144,7 +144,7 @@ public void setOfProvider_withAllowedClass_shouldReturnExpectedSet() {
144144
Set<Boolean> set = Collections.emptySet();
145145
when(delegate.setOfProvider(Boolean.class)).thenReturn(new Lazy<>(set));
146146

147-
assertThat(container.setOfProvider(Boolean.class).get()).isSameAs(set);
147+
assertThat(container.setOfProvider(Boolean.class).get()).isSameInstanceAs(set);
148148
verify(delegate).setOfProvider(Boolean.class);
149149
}
150150

root-project.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ext {
4646
supportAnnotationsVersion = '28.0.0'
4747
errorproneVersion = '2.3.2'
4848
errorproneJavacVersion = '9+181-r4173-1'
49-
googleTruthVersion = '0.40'
49+
googleTruthVersion = '0.45'
5050
robolectricVersion = '4.1'
5151
}
5252

smoke-tests/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ apply from: "configure.gradle"
8888
dependencies {
8989
// Common
9090
api "androidx.test:runner:1.1.0"
91-
api "com.google.truth:truth:0.43"
91+
api "com.google.truth:truth:0.45"
9292
api "junit:junit:4.12"
9393

9494
implementation "androidx.test:rules:1.1.0"

0 commit comments

Comments
 (0)