private static void verifyCallRecords(Iterator<PathAwareCallRecord> expected, Iterator<PathAwareCallRecord> actual) { while (expected.hasNext()) { assertThat(actual.next()).isEqualTo(expected.next()); } }
@Test public void testSchemeHttps() throws Exception { String uri = "https://image.com/1.png"; Scheme result = Scheme.ofUri(uri); Scheme expected = Scheme.HTTPS; Assertions.assertThat(result).isEqualTo(expected); }
@Test public void testSchemeContent() throws Exception { String uri = "content://path/to/content"; Scheme result = Scheme.ofUri(uri); Scheme expected = Scheme.CONTENT; Assertions.assertThat(result).isEqualTo(expected); }
@Test public void testSchemeUnknown() throws Exception { String uri = "other://image.com/1.png"; Scheme result = Scheme.ofUri(uri); Scheme expected = Scheme.UNKNOWN; Assertions.assertThat(result).isEqualTo(expected); } }
@Test public void testSchemeHttp() throws Exception { String uri = "http://image.com/1.png"; Scheme result = Scheme.ofUri(uri); Scheme expected = Scheme.HTTP; Assertions.assertThat(result).isEqualTo(expected); }
@Test public void testSchemeAssets() throws Exception { String uri = "assets://folder/1.png"; Scheme result = Scheme.ofUri(uri); Scheme expected = Scheme.ASSETS; Assertions.assertThat(result).isEqualTo(expected); }
@Test public void testSchemeDrawables() throws Exception { String uri = "drawable://123456890"; Scheme result = Scheme.ofUri(uri); Scheme expected = Scheme.DRAWABLE; Assertions.assertThat(result).isEqualTo(expected); }
@Test public void testSchemeFile() throws Exception { String uri = "file://path/on/the/device/1.png"; Scheme result = Scheme.ofUri(uri); Scheme expected = Scheme.FILE; Assertions.assertThat(result).isEqualTo(expected); }
@Test public void equals_is_based_on_key_only() { ScannerPlugin plugin = new ScannerPlugin("key", "base", 12345L); assertThat(plugin).isEqualTo(plugin); assertThat(plugin).isEqualTo(new ScannerPlugin("key", null, 45678L)); assertThat(plugin).isNotEqualTo(new ScannerPlugin("key2", "base", 12345L)); assertThat(plugin).isNotEqualTo(null); assertThat(plugin).isNotEqualTo("toto"); }
@Test public void test_getters() { DefaultTrackingInput underTest = new DefaultTrackingInput(issues, lineHashes, blockHashes); assertThat(underTest.getBlockHashSequence()).isEqualTo(blockHashes); assertThat(underTest.getLineHashSequence()).isEqualTo(lineHashes); assertThat(underTest.getIssues()).isEqualTo(issues); } }
@Test public void verify_readComponentMeasures_returns_measures() { writer.writeComponentMeasures(COMPONENT_REF, of(MEASURE)); try (CloseableIterator<ScannerReport.Measure> measures = underTest.readComponentMeasures(COMPONENT_REF)) { assertThat(measures.next()).isEqualTo(MEASURE); assertThat(measures.hasNext()).isFalse(); } }
@Test public void verify_readChangesets_returns_changesets() { writer.writeComponentChangesets(CHANGESETS); ScannerReport.Changesets res = underTest.readChangesets(COMPONENT_REF); assertThat(res).isEqualTo(CHANGESETS); }
@Test public void verify_readComponent_returns_Component() { writer.writeComponent(COMPONENT); assertThat(underTest.readComponent(COMPONENT_REF)).isEqualTo(COMPONENT); }
@Test public void verify_readComponentDuplications_returns_Issues() { writer.writeComponentDuplications(COMPONENT_REF, of(DUPLICATION)); try (CloseableIterator<ScannerReport.Duplication> res = underTest.readComponentDuplications(COMPONENT_REF)) { assertThat(res.next()).isEqualTo(DUPLICATION); assertThat(res.hasNext()).isFalse(); } }
@Test public void aggregate_from_counter() { when(counterInitializationContext.getMeasure(METRIC_KEY)).thenReturn(Optional.of(Measure.newMeasureBuilder().create(10))); SumCounter anotherCounter = new IntSumCounter(METRIC_KEY); anotherCounter.initialize(counterInitializationContext); sumCounter.aggregate(anotherCounter); assertThat(sumCounter.getValue().get()).isEqualTo(10); }
@Test public void equals_is_based_on_both_properties() { assertThat(underTest).isEqualTo(new Match(SOME_KEY, SOME_REPORT_KEY)); assertThat(underTest).isNotEqualTo(new Match("other key", SOME_REPORT_KEY)); assertThat(underTest).isNotEqualTo(new Match(SOME_KEY, "other report key")); assertThat(underTest).isNotEqualTo(new Match(null, SOME_REPORT_KEY)); assertThat(underTest).isNotEqualTo(new Match(SOME_KEY, null)); assertThat(underTest).isNotEqualTo(new Match(null, null)); }
@Test public void equals_is_based_on_uuid_only() { Organization organization = Organization.from(underTest.setUuid("uuid").setKey("key").setName("name").setDefaultQualityGateUuid("uuid1")); assertThat(organization).isEqualTo(Organization.from(underTest.setUuid("uuid").setKey("key").setName("name").setDefaultQualityGateUuid("uuid1"))); assertThat(organization).isEqualTo(Organization.from(underTest.setUuid("uuid").setKey("other key").setName("name").setDefaultQualityGateUuid("uuid1"))); assertThat(organization).isEqualTo(Organization.from(underTest.setUuid("uuid").setKey("key").setName("other name").setDefaultQualityGateUuid("uuid1"))); assertThat(organization).isEqualTo(Organization.from(underTest.setUuid("uuid").setKey("key").setName("name").setDefaultQualityGateUuid("other uuid"))); assertThat(organization).isNotEqualTo(Organization.from(underTest.setUuid("other uuid").setKey("key").setName("name").setDefaultQualityGateUuid("uuid1"))); assertThat(organization).isNotEqualTo(null); assertThat(organization).isNotEqualTo("toto"); }
@Test public void equals_compares_on_file_and_TextBlock() { TextBlock textBlock1 = new TextBlock(1, 2); assertThat(new InProjectDuplicate(FILE_1, textBlock1)).isEqualTo(new InProjectDuplicate(FILE_1, new TextBlock(1, 2))); assertThat(new InProjectDuplicate(FILE_1, textBlock1)).isNotEqualTo(new InProjectDuplicate(FILE_1, new TextBlock(1, 1))); assertThat(new InProjectDuplicate(FILE_1, textBlock1)).isNotEqualTo(new InProjectDuplicate(FILE_2, textBlock1)); }
@Test public void equals_compares_on_file_and_TextBlock() { TextBlock textBlock1 = new TextBlock(1, 2); assertThat(new CrossProjectDuplicate(FILE_KEY_1, textBlock1)).isEqualTo(new CrossProjectDuplicate(FILE_KEY_1, new TextBlock(1, 2))); assertThat(new CrossProjectDuplicate(FILE_KEY_1, textBlock1)).isNotEqualTo(new CrossProjectDuplicate(FILE_KEY_1, new TextBlock(1, 1))); assertThat(new CrossProjectDuplicate(FILE_KEY_1, textBlock1)).isNotEqualTo(new CrossProjectDuplicate(FILE_KEY_2, textBlock1)); }