@Test public void shouldReturnSetScanResults() throws Exception { List<ScanResult> scanResults = new ArrayList<>(); shadowOf(wifiManager).setScanResults(scanResults); assertThat(wifiManager.getScanResults()).isSameAs(scanResults); }
@Test public void providesSet() { final Set<A> set = Collections.emptySet(); class TestEntryPoint { @Inject Set<A> set; } @Module(injects = TestEntryPoint.class) class TestModule { @Provides Set<A> provideSet() { return set; } } TestEntryPoint entryPoint = new TestEntryPoint(); TestModule module = new TestModule(); ObjectGraph.createWith(new TestingLoader(), module).inject(entryPoint); assertThat(entryPoint.set).isSameAs(set); }
@Test public void providesSetOfProvidersIsDifferentThanProvidesTypeSetValues() { final Set<A> set = Collections.emptySet(); final Set<Provider<A>> providers = Collections.emptySet(); class TestEntryPoint { @Inject Set<A> set; @Inject Set<Provider<A>> providers; } @Module(injects = TestEntryPoint.class) class TestModule { @Provides(type = Provides.Type.SET_VALUES) Set<A> provideSetContribution() { return set; } @Provides Set<Provider<A>> provideProviders() { return providers; } } TestEntryPoint entryPoint = new TestEntryPoint(); TestModule module = new TestModule(); ObjectGraph.createWith(new TestingLoader(), module).inject(entryPoint); // copies into immutable collection assertThat(entryPoint.set).isNotSameAs(set); assertThat(entryPoint.set).isEqualTo(set); assertThat(entryPoint.providers).isSameAs(providers); }
@Test public void bytesUnprintable() { ByteArray bytes = ByteArray.copyFrom(new byte[] {'a', 0, 15, -1, 'e'}); Value v = Value.bytes(bytes); assertThat(v.getBytes()).isSameAs(bytes); assertThat(v.toString()).isEqualTo(bytes.toString()); }
@Test public void bytes() { ByteArray bytes = newByteArray("abc"); Value v = Value.bytes(bytes); assertThat(v.getType()).isEqualTo(Type.bytes()); assertThat(v.isNull()).isFalse(); assertThat(v.getBytes()).isSameAs(bytes); assertThat(v.toString()).isEqualTo(bytes.toString()); }
@Test public void deviceSpecAll_hasAllDimensions() throws Exception { BuildApksResult tableOfContentsProto = BuildApksResult.getDefaultInstance(); Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks")); GetSizeCommand command = GetSizeCommand.fromFlags( new FlagParser() .parse("get-size", "total", "--apks=" + apksArchiveFile, "--dimensions=" + "ALL")); assertThat(command.getDimensions()).isSameAs(SUPPORTED_DIMENSIONS); }
@Override protected void runTest() throws Throwable { Feed feed = abdera.getFactory().newFeed(); Entry entry = feed.addEntry(); Element addedChild = addChild(feed); Element child = feed.getFirstChild(); // Entries must come after any other type of child elements assertThat(child).isSameAs(addedChild); assertThat(child.getNextSibling()).isSameAs(entry); }
@Override protected void runTest() throws Throwable { Document<Categories> document = abdera.getParser().parse( TestAddCategoryFromCategories.class.getResourceAsStream("categories.xml")); Categories categories = document.getRoot(); Entry entry = abdera.getFactory().newEntry(); Category orgCategory = categories.getCategories().get(0); entry.addCategory(orgCategory); Category category = entry.getCategories().get(0); assertThat(category).isNotSameAs(orgCategory); // Assert that the original Category has not been removed from the Categories instance assertThat(categories.getCategories().get(0)).isSameAs(orgCategory); assertThat(category.getTerm()).isEqualTo(orgCategory.getTerm()); // The scheme is inherited from the app:categories element assertThat(category.getScheme()).isEqualTo(categories.getScheme()); } }
@Test public void remove_NotPresent() { metricProducerManager.add(metricProducer); Set<MetricProducer> metricProducerSet = metricProducerManager.getAllMetricProducer(); assertThat(metricProducerSet).containsExactly(metricProducer); metricProducerManager.remove(metricProducerOther); // Returns the same object. assertThat(metricProducerManager.getAllMetricProducer()).isSameAs(metricProducerSet); }
@Test public void add_DuplicateElement() { metricProducerManager.add(metricProducer); Set<MetricProducer> metricProducerSet = metricProducerManager.getAllMetricProducer(); assertThat(metricProducerSet).containsExactly(metricProducer); metricProducerManager.add(metricProducer); // Returns the same object. assertThat(metricProducerManager.getAllMetricProducer()).isSameAs(metricProducerSet); }