mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Format Java code in xplat/js/react-native-github
Summary: This diff formats the Java class files inside xplat/js/react-native-github. Since google-java-format was enabled in D16071401 we want to codemode the existing code so that users don't have to deal with formatter lint noise at diff-time. ```arc f --paths-cmd 'hg files -I "**/*.java"'``` drop-conflicts Reviewed By: cpojer Differential Revision: D16071725 fbshipit-source-id: fc6e3852e45742c109f0c5ac4065d64201c74204
This commit is contained in:
1 parent
61e95e5cbf
commit
6c0f73b322
681 files changed
+14082
-16365
No files matched your search
+47
-66
@@ -1,34 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
||||
* directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.bridge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.common.logging.FakeLoggingDelegate;
|
||||
import com.facebook.common.logging.LoggingDelegate;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
import static org.fest.assertions.api.Assertions.fail;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.common.logging.FakeLoggingDelegate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class FallbackJSBundleLoaderTest {
|
||||
|
||||
private static final String UNRECOVERABLE;
|
||||
|
||||
static {
|
||||
String prefix = FallbackJSBundleLoader.RECOVERABLE;
|
||||
char first = prefix.charAt(0);
|
||||
@@ -46,36 +42,31 @@ public class FallbackJSBundleLoaderTest {
|
||||
|
||||
@Test
|
||||
public void firstLoaderSucceeds() {
|
||||
JSBundleLoader delegates[] = new JSBundleLoader[] {
|
||||
successfulLoader("url1"),
|
||||
successfulLoader("url2")
|
||||
};
|
||||
JSBundleLoader delegates[] =
|
||||
new JSBundleLoader[] {successfulLoader("url1"), successfulLoader("url2")};
|
||||
|
||||
FallbackJSBundleLoader fallbackLoader =
|
||||
new FallbackJSBundleLoader(new ArrayList<>(Arrays.asList(delegates)));
|
||||
new FallbackJSBundleLoader(new ArrayList<>(Arrays.asList(delegates)));
|
||||
|
||||
assertThat(fallbackLoader.loadScript(null)).isEqualTo("url1");
|
||||
|
||||
verify(delegates[0], times(1)).loadScript(null);
|
||||
verify(delegates[1], never()).loadScript(null);
|
||||
|
||||
assertThat(mLoggingDelegate.logContains(
|
||||
FakeLoggingDelegate.WTF,
|
||||
FallbackJSBundleLoader.TAG,
|
||||
null))
|
||||
.isFalse();
|
||||
assertThat(
|
||||
mLoggingDelegate.logContains(FakeLoggingDelegate.WTF, FallbackJSBundleLoader.TAG, null))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fallingBackSuccessfully() {
|
||||
JSBundleLoader delegates[] = new JSBundleLoader[] {
|
||||
recoverableLoader("url1", "error1"),
|
||||
successfulLoader("url2"),
|
||||
successfulLoader("url3")
|
||||
};
|
||||
JSBundleLoader delegates[] =
|
||||
new JSBundleLoader[] {
|
||||
recoverableLoader("url1", "error1"), successfulLoader("url2"), successfulLoader("url3")
|
||||
};
|
||||
|
||||
FallbackJSBundleLoader fallbackLoader =
|
||||
new FallbackJSBundleLoader(new ArrayList<>(Arrays.asList(delegates)));
|
||||
new FallbackJSBundleLoader(new ArrayList<>(Arrays.asList(delegates)));
|
||||
|
||||
assertThat(fallbackLoader.loadScript(null)).isEqualTo("url2");
|
||||
|
||||
@@ -83,22 +74,21 @@ public class FallbackJSBundleLoaderTest {
|
||||
verify(delegates[1], times(1)).loadScript(null);
|
||||
verify(delegates[2], never()).loadScript(null);
|
||||
|
||||
assertThat(mLoggingDelegate.logContains(
|
||||
FakeLoggingDelegate.WTF,
|
||||
FallbackJSBundleLoader.TAG,
|
||||
recoverableMsg("error1")))
|
||||
.isTrue();
|
||||
assertThat(
|
||||
mLoggingDelegate.logContains(
|
||||
FakeLoggingDelegate.WTF, FallbackJSBundleLoader.TAG, recoverableMsg("error1")))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fallingbackUnsuccessfully() {
|
||||
JSBundleLoader delegates[] = new JSBundleLoader[] {
|
||||
recoverableLoader("url1", "error1"),
|
||||
recoverableLoader("url2", "error2")
|
||||
};
|
||||
JSBundleLoader delegates[] =
|
||||
new JSBundleLoader[] {
|
||||
recoverableLoader("url1", "error1"), recoverableLoader("url2", "error2")
|
||||
};
|
||||
|
||||
FallbackJSBundleLoader fallbackLoader =
|
||||
new FallbackJSBundleLoader(new ArrayList<>(Arrays.asList(delegates)));
|
||||
new FallbackJSBundleLoader(new ArrayList<>(Arrays.asList(delegates)));
|
||||
|
||||
try {
|
||||
fallbackLoader.loadScript(null);
|
||||
@@ -113,36 +103,30 @@ public class FallbackJSBundleLoaderTest {
|
||||
cause = cause.getCause();
|
||||
}
|
||||
|
||||
assertThat(msgs).containsExactly(
|
||||
recoverableMsg("error1"),
|
||||
recoverableMsg("error2"));
|
||||
assertThat(msgs).containsExactly(recoverableMsg("error1"), recoverableMsg("error2"));
|
||||
}
|
||||
|
||||
verify(delegates[0], times(1)).loadScript(null);
|
||||
verify(delegates[1], times(1)).loadScript(null);
|
||||
|
||||
assertThat(mLoggingDelegate.logContains(
|
||||
FakeLoggingDelegate.WTF,
|
||||
FallbackJSBundleLoader.TAG,
|
||||
recoverableMsg("error1")))
|
||||
.isTrue();
|
||||
assertThat(
|
||||
mLoggingDelegate.logContains(
|
||||
FakeLoggingDelegate.WTF, FallbackJSBundleLoader.TAG, recoverableMsg("error1")))
|
||||
.isTrue();
|
||||
|
||||
assertThat(mLoggingDelegate.logContains(
|
||||
FakeLoggingDelegate.WTF,
|
||||
FallbackJSBundleLoader.TAG,
|
||||
recoverableMsg("error2")))
|
||||
.isTrue();
|
||||
assertThat(
|
||||
mLoggingDelegate.logContains(
|
||||
FakeLoggingDelegate.WTF, FallbackJSBundleLoader.TAG, recoverableMsg("error2")))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unrecoverable() {
|
||||
JSBundleLoader delegates[] = new JSBundleLoader[] {
|
||||
fatalLoader("url1", "error1"),
|
||||
recoverableLoader("url2", "error2")
|
||||
};
|
||||
JSBundleLoader delegates[] =
|
||||
new JSBundleLoader[] {fatalLoader("url1", "error1"), recoverableLoader("url2", "error2")};
|
||||
|
||||
FallbackJSBundleLoader fallbackLoader =
|
||||
new FallbackJSBundleLoader(new ArrayList(Arrays.asList(delegates)));
|
||||
new FallbackJSBundleLoader(new ArrayList(Arrays.asList(delegates)));
|
||||
|
||||
try {
|
||||
fallbackLoader.loadScript(null);
|
||||
@@ -154,11 +138,9 @@ public class FallbackJSBundleLoaderTest {
|
||||
verify(delegates[0], times(1)).loadScript(null);
|
||||
verify(delegates[1], never()).loadScript(null);
|
||||
|
||||
assertThat(mLoggingDelegate.logContains(
|
||||
FakeLoggingDelegate.WTF,
|
||||
FallbackJSBundleLoader.TAG,
|
||||
null))
|
||||
.isFalse();
|
||||
assertThat(
|
||||
mLoggingDelegate.logContains(FakeLoggingDelegate.WTF, FallbackJSBundleLoader.TAG, null))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
private static JSBundleLoader successfulLoader(String url) {
|
||||
@@ -175,7 +157,7 @@ public class FallbackJSBundleLoaderTest {
|
||||
private static JSBundleLoader recoverableLoader(String url, String errMsg) {
|
||||
JSBundleLoader loader = mock(JSBundleLoader.class);
|
||||
when(loader.loadScript(null))
|
||||
.thenThrow(new RuntimeException(FallbackJSBundleLoader.RECOVERABLE + errMsg));
|
||||
.thenThrow(new RuntimeException(FallbackJSBundleLoader.RECOVERABLE + errMsg));
|
||||
|
||||
return loader;
|
||||
}
|
||||
@@ -186,8 +168,7 @@ public class FallbackJSBundleLoaderTest {
|
||||
|
||||
private static JSBundleLoader fatalLoader(String url, String errMsg) {
|
||||
JSBundleLoader loader = mock(JSBundleLoader.class);
|
||||
when(loader.loadScript(null))
|
||||
.thenThrow(new RuntimeException(UNRECOVERABLE + errMsg));
|
||||
when(loader.loadScript(null)).thenThrow(new RuntimeException(UNRECOVERABLE + errMsg));
|
||||
|
||||
return loader;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user