Refine search
public void testToGenericType_staticMemberClass() throws Exception { Method getStaticAnonymousClassMethod = TypeTokenTest.class.getDeclaredMethod("getStaticAnonymousClass", Object.class); ParameterizedType javacReturnType = (ParameterizedType) getStaticAnonymousClassMethod.getGenericReturnType(); ParameterizedType parameterizedType = (ParameterizedType) TypeToken.toGenericType(GenericClass.class).getType(); assertThat(parameterizedType.getOwnerType()).isEqualTo(javacReturnType.getOwnerType()); }
@Test public void testLoadBitmap_asDrawable() { Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); requestManager .load(bitmap) .into(target); ArgumentCaptor<Object> captor = ArgumentCaptor.forClass(Object.class); verify(target).onResourceReady(captor.capture(), any(Transition.class)); BitmapDrawable drawable = (BitmapDrawable) captor.getValue(); assertThat(drawable.getBitmap()).isEqualTo(bitmap); }
@Test public void getDefaultTransitionOptions_withNoOptionsRegistered_returnsDefaultOptions() { assertThat(context.getDefaultTransitionOptions(Object.class)) .isEqualTo(GlideContext.DEFAULT_TRANSITION_OPTIONS); }
public void testGetSubtype_subtypeSameAsDeclaringType() throws Exception { class Bar<T> {} class SubBar<T> extends Bar<T> { @SuppressWarnings("unused") Bar<T> delegate; TypeToken<SubBar<T>> fieldTypeAsSubBar() { return new TypeToken<SubBar<T>>() {}; } } Field delegateField = SubBar.class.getDeclaredField("delegate"); // barType is Bar<T>, a ParameterizedType with no generic arguments specified TypeToken<?> barType = TypeToken.of(delegateField.getGenericType()); assertThat(barType.getSubtype(SubBar.class)).isEqualTo(new SubBar<Void>().fieldTypeAsSubBar()); }
@Test public void testGetCurrentFrameReturnsFirstFrameWHenNoLoadHasCompleted() { assertThat(loader.getCurrentFrame()).isEqualTo(firstFrame); }
public void testToByteArrayAndFromByteArrayRoundTrip() { for (PairedStats pairedStats : ALL_PAIRED_STATS) { byte[] pairedStatsByteArray = pairedStats.toByteArray(); // Round trip to byte array and back assertThat(PairedStats.fromByteArray(pairedStatsByteArray)).isEqualTo(pairedStats); } }
@Test public void copyOf_directedGraph() { Graph<Integer> directedGraph = buildDirectedGraph(); Graph<Integer> copy = copyOf(directedGraph); assertThat(copy).isEqualTo(directedGraph); }
public void testToByteArrayAndFromByteArrayRoundTrip() { for (Stats stats : ALL_STATS) { byte[] statsByteArray = stats.toByteArray(); // Round trip to byte array and back assertThat(Stats.fromByteArray(statsByteArray)).isEqualTo(stats); } }
@Test public void copyOf_undirectedGraph() { Graph<Integer> undirectedGraph = buildUndirectedGraph(); Graph<Integer> copy = copyOf(undirectedGraph); assertThat(copy).isEqualTo(undirectedGraph); }
static void assertStronglyEquivalent(ValueGraph<?, ?> graphA, ValueGraph<?, ?> graphB) { // Properties not covered by equals() assertThat(graphA.allowsSelfLoops()).isEqualTo(graphB.allowsSelfLoops()); assertThat(graphA.nodeOrder()).isEqualTo(graphB.nodeOrder()); assertThat(graphA).isEqualTo(graphB); }
@Test public void copyOf_directedValueGraph() { ValueGraph<Integer, String> directedGraph = buildDirectedValueGraph(); ValueGraph<Integer, String> copy = copyOf(directedGraph); assertThat(copy).isEqualTo(directedGraph); }
@GwtIncompatible // Iterables.filter(Iterable, Class) public void testFilterByType_forEach() throws Exception { HasBoth hasBoth1 = new HasBoth(); HasBoth hasBoth2 = new HasBoth(); Iterable<TypeA> alist = Lists.newArrayList(hasBoth1, new TypeA(), hasBoth2, new TypeA()); Iterable<TypeB> blist = Iterables.filter(alist, TypeB.class); Iterator<TypeB> expectedIterator = Arrays.<TypeB>asList(hasBoth1, hasBoth2).iterator(); blist.forEach(b -> assertThat(b).isEqualTo(expectedIterator.next())); assertThat(expectedIterator.hasNext()).isFalse(); }
@Test public void copyOf_undirectedValueGraph() { ValueGraph<Integer, String> undirectedGraph = buildUndirectedValueGraph(); ValueGraph<Integer, String> copy = copyOf(undirectedGraph); assertThat(copy).isEqualTo(undirectedGraph); }
static void assertStronglyEquivalent(Graph<?> graphA, Graph<?> graphB) { // Properties not covered by equals() assertThat(graphA.allowsSelfLoops()).isEqualTo(graphB.allowsSelfLoops()); assertThat(graphA.nodeOrder()).isEqualTo(graphB.nodeOrder()); assertThat(graphA).isEqualTo(graphB); }
@Test public void copyOf_directedNetwork() { Network<Integer, String> directedGraph = buildDirectedNetwork(); Network<Integer, String> copy = copyOf(directedGraph); assertThat(copy).isEqualTo(directedGraph); }
static void assertStronglyEquivalent(Network<?, ?> networkA, Network<?, ?> networkB) { // Properties not covered by equals() assertThat(networkA.allowsParallelEdges()).isEqualTo(networkB.allowsParallelEdges()); assertThat(networkA.allowsSelfLoops()).isEqualTo(networkB.allowsSelfLoops()); assertThat(networkA.nodeOrder()).isEqualTo(networkB.nodeOrder()); assertThat(networkA.edgeOrder()).isEqualTo(networkB.edgeOrder()); assertThat(networkA).isEqualTo(networkB); }
@Test public void copyOf_undirectedNetwork() { Network<Integer, String> undirectedGraph = buildUndirectedNetwork(); Network<Integer, String> copy = copyOf(undirectedGraph); assertThat(copy).isEqualTo(undirectedGraph); }
public void testCatching() throws Exception { FluentFuture<?> f = FluentFuture.from(immediateFailedFuture(new RuntimeException())) .catching( Throwable.class, new Function<Throwable, Class<?>>() { @Override public Class<?> apply(Throwable input) { return input.getClass(); } }, directExecutor()); assertThat(f.get()).isEqualTo(RuntimeException.class); }
@Test public void getDefaultTransitionOptions_withSuperClassRegistered_returnsSuperClassOptions() { DrawableTransitionOptions expected = new DrawableTransitionOptions(); transitionOptions.put(Drawable.class, expected); assertThat(context.getDefaultTransitionOptions(BitmapDrawable.class)) .isEqualTo(expected); assertThat(context.getDefaultTransitionOptions(GifDrawable.class)) .isEqualTo(expected); } }
public void testCatchingAsync() throws Exception { FluentFuture<?> f = FluentFuture.from(immediateFailedFuture(new RuntimeException())) .catchingAsync( Throwable.class, new AsyncFunction<Throwable, Class<?>>() { @Override public ListenableFuture<Class<?>> apply(Throwable input) { return Futures.<Class<?>>immediateFuture(input.getClass()); } }, directExecutor()); assertThat(f.get()).isEqualTo(RuntimeException.class); }