Java Code Examples for com.facebook.react.bridge.JavaOnlyArray.pushArray()

The following are Jave code examples for showing how to use pushArray() of the com.facebook.react.bridge.JavaOnlyArray class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: RNLearn_Project1   File: AsyncStorageModuleTest.java   Source Code and License Vote up 5 votes
@Test
public void testMultiSetMultiGet() {
  final String key1 = "foo1";
  final String key2 = "foo2";
  final String fakeKey = "fakeKey";
  final String value1 = "bar1";
  final String value2 = "bar2";
  JavaOnlyArray keyValues = new JavaOnlyArray();
  keyValues.pushArray(getArray(key1, value1));
  keyValues.pushArray(getArray(key2, value2));

  Callback setCallback = mock(Callback.class);
  mStorage.multiSet(keyValues, setCallback);
  Mockito.verify(setCallback, Mockito.times(1)).invoke();

  JavaOnlyArray keys = new JavaOnlyArray();
  keys.pushString(key1);
  keys.pushString(key2);

  Callback getCallback = mock(Callback.class);
  mStorage.multiGet(keys, getCallback);
  Mockito.verify(getCallback, Mockito.times(1)).invoke(null, keyValues);

  keys.pushString(fakeKey);
  JavaOnlyArray row3 = new JavaOnlyArray();
  row3.pushString(fakeKey);
  row3.pushString(null);
  keyValues.pushArray(row3);

  Callback getCallback2 = mock(Callback.class);
  mStorage.multiGet(keys, getCallback2);
  Mockito.verify(getCallback2, Mockito.times(1)).invoke(null, keyValues);
}
 
Example 2
Project: RNLearn_Project1   File: AsyncStorageModuleTest.java   Source Code and License Vote up 5 votes
@Test
public void testMultiRemove() {
  final String key1 = "foo1";
  final String key2 = "foo2";
  final String value1 = "bar1";
  final String value2 = "bar2";

  JavaOnlyArray keyValues = new JavaOnlyArray();
  keyValues.pushArray(getArray(key1, value1));
  keyValues.pushArray(getArray(key2, value2));
  mStorage.multiSet(keyValues, mock(Callback.class));

  JavaOnlyArray keys = new JavaOnlyArray();
  keys.pushString(key1);
  keys.pushString(key2);

  Callback getCallback = mock(Callback.class);
  mStorage.multiRemove(keys, getCallback);
  Mockito.verify(getCallback, Mockito.times(1)).invoke();

  Callback getAllCallback = mock(Callback.class);
  mStorage.getAllKeys(getAllCallback);
  Mockito.verify(getAllCallback, Mockito.times(1)).invoke(null, mEmptyArray);

  mStorage.multiSet(keyValues, mock(Callback.class));

  keys.pushString("fakeKey");
  Callback getCallback2 = mock(Callback.class);
  mStorage.multiRemove(keys, getCallback2);
  Mockito.verify(getCallback2, Mockito.times(1)).invoke();

  Callback getAllCallback2 = mock(Callback.class);
  mStorage.getAllKeys(getAllCallback2);
  Mockito.verify(getAllCallback2, Mockito.times(1)).invoke(null, mEmptyArray);
}
 
Example 3
Project: RNLearn_Project1   File: AsyncStorageModuleTest.java   Source Code and License Vote up 5 votes
@Test
public void testGetAllKeys() {
  final String[] keys = {"foo", "foo2"};
  final String[] values = {"bar", "bar2"};
  JavaOnlyArray keyValues = new JavaOnlyArray();
  keyValues.pushArray(getArray(keys[0], values[0]));
  keyValues.pushArray(getArray(keys[1], values[1]));
  mStorage.multiSet(keyValues, mock(Callback.class));

  JavaOnlyArray storedKeys = new JavaOnlyArray();
  storedKeys.pushString(keys[0]);
  storedKeys.pushString(keys[1]);

  Callback getAllCallback = mock(Callback.class);
  mStorage.getAllKeys(getAllCallback);
  Mockito.verify(getAllCallback, Mockito.times(1)).invoke(null, storedKeys);

  Callback getAllCallback2 = mock(Callback.class);
  mStorage.multiRemove(getArray(keys[0]), mock(Callback.class));

  mStorage.getAllKeys(getAllCallback2);
  Mockito.verify(getAllCallback2, Mockito.times(1)).invoke(null, getArray(keys[1]));

  mStorage.multiRemove(getArray(keys[1]), mock(Callback.class));
  Callback getAllCallback3 = mock(Callback.class);
  mStorage.getAllKeys(getAllCallback3);
  Mockito.verify(getAllCallback3, Mockito.times(1)).invoke(null, mEmptyArray);
}
 
Example 4
Project: RNLearn_Project1   File: AsyncStorageModuleTest.java   Source Code and License Vote up 5 votes
@Test
public void testClear() {
  JavaOnlyArray keyValues = new JavaOnlyArray();
  keyValues.pushArray(getArray("foo", "foo2"));
  keyValues.pushArray(getArray("bar", "bar2"));
  mStorage.multiSet(keyValues, mock(Callback.class));

  Callback clearCallback2 = mock(Callback.class);
  mStorage.clear(clearCallback2);
  Mockito.verify(clearCallback2, Mockito.times(1)).invoke();

  Callback getAllCallback2 = mock(Callback.class);
  mStorage.getAllKeys(getAllCallback2);
  Mockito.verify(getAllCallback2, Mockito.times(1)).invoke(null, mEmptyArray);
}
 
Example 5
Project: RNLearn_Project1   File: AsyncStorageModuleTest.java   Source Code and License Vote up 5 votes
@Test
public void testMultiSetMultiGet() {
  final String key1 = "foo1";
  final String key2 = "foo2";
  final String fakeKey = "fakeKey";
  final String value1 = "bar1";
  final String value2 = "bar2";
  JavaOnlyArray keyValues = new JavaOnlyArray();
  keyValues.pushArray(getArray(key1, value1));
  keyValues.pushArray(getArray(key2, value2));

  Callback setCallback = mock(Callback.class);
  mStorage.multiSet(keyValues, setCallback);
  Mockito.verify(setCallback, Mockito.times(1)).invoke();

  JavaOnlyArray keys = new JavaOnlyArray();
  keys.pushString(key1);
  keys.pushString(key2);

  Callback getCallback = mock(Callback.class);
  mStorage.multiGet(keys, getCallback);
  Mockito.verify(getCallback, Mockito.times(1)).invoke(null, keyValues);

  keys.pushString(fakeKey);
  JavaOnlyArray row3 = new JavaOnlyArray();
  row3.pushString(fakeKey);
  row3.pushString(null);
  keyValues.pushArray(row3);

  Callback getCallback2 = mock(Callback.class);
  mStorage.multiGet(keys, getCallback2);
  Mockito.verify(getCallback2, Mockito.times(1)).invoke(null, keyValues);
}
 
Example 6
Project: RNLearn_Project1   File: AsyncStorageModuleTest.java   Source Code and License Vote up 5 votes
@Test
public void testMultiRemove() {
  final String key1 = "foo1";
  final String key2 = "foo2";
  final String value1 = "bar1";
  final String value2 = "bar2";

  JavaOnlyArray keyValues = new JavaOnlyArray();
  keyValues.pushArray(getArray(key1, value1));
  keyValues.pushArray(getArray(key2, value2));
  mStorage.multiSet(keyValues, mock(Callback.class));

  JavaOnlyArray keys = new JavaOnlyArray();
  keys.pushString(key1);
  keys.pushString(key2);

  Callback getCallback = mock(Callback.class);
  mStorage.multiRemove(keys, getCallback);
  Mockito.verify(getCallback, Mockito.times(1)).invoke();

  Callback getAllCallback = mock(Callback.class);
  mStorage.getAllKeys(getAllCallback);
  Mockito.verify(getAllCallback, Mockito.times(1)).invoke(null, mEmptyArray);

  mStorage.multiSet(keyValues, mock(Callback.class));

  keys.pushString("fakeKey");
  Callback getCallback2 = mock(Callback.class);
  mStorage.multiRemove(keys, getCallback2);
  Mockito.verify(getCallback2, Mockito.times(1)).invoke();

  Callback getAllCallback2 = mock(Callback.class);
  mStorage.getAllKeys(getAllCallback2);
  Mockito.verify(getAllCallback2, Mockito.times(1)).invoke(null, mEmptyArray);
}
 
Example 7
Project: RNLearn_Project1   File: AsyncStorageModuleTest.java   Source Code and License Vote up 5 votes
@Test
public void testGetAllKeys() {
  final String[] keys = {"foo", "foo2"};
  final String[] values = {"bar", "bar2"};
  JavaOnlyArray keyValues = new JavaOnlyArray();
  keyValues.pushArray(getArray(keys[0], values[0]));
  keyValues.pushArray(getArray(keys[1], values[1]));
  mStorage.multiSet(keyValues, mock(Callback.class));

  JavaOnlyArray storedKeys = new JavaOnlyArray();
  storedKeys.pushString(keys[0]);
  storedKeys.pushString(keys[1]);

  Callback getAllCallback = mock(Callback.class);
  mStorage.getAllKeys(getAllCallback);
  Mockito.verify(getAllCallback, Mockito.times(1)).invoke(null, storedKeys);

  Callback getAllCallback2 = mock(Callback.class);
  mStorage.multiRemove(getArray(keys[0]), mock(Callback.class));

  mStorage.getAllKeys(getAllCallback2);
  Mockito.verify(getAllCallback2, Mockito.times(1)).invoke(null, getArray(keys[1]));

  mStorage.multiRemove(getArray(keys[1]), mock(Callback.class));
  Callback getAllCallback3 = mock(Callback.class);
  mStorage.getAllKeys(getAllCallback3);
  Mockito.verify(getAllCallback3, Mockito.times(1)).invoke(null, mEmptyArray);
}
 
Example 8
Project: RNLearn_Project1   File: AsyncStorageModuleTest.java   Source Code and License Vote up 5 votes
@Test
public void testClear() {
  JavaOnlyArray keyValues = new JavaOnlyArray();
  keyValues.pushArray(getArray("foo", "foo2"));
  keyValues.pushArray(getArray("bar", "bar2"));
  mStorage.multiSet(keyValues, mock(Callback.class));

  Callback clearCallback2 = mock(Callback.class);
  mStorage.clear(clearCallback2);
  Mockito.verify(clearCallback2, Mockito.times(1)).invoke();

  Callback getAllCallback2 = mock(Callback.class);
  mStorage.getAllKeys(getAllCallback2);
  Mockito.verify(getAllCallback2, Mockito.times(1)).invoke(null, mEmptyArray);
}