Refine search
@Test public void check_component_keys() { db.prepareDbUnit(getClass(), "shared.xml"); Map<String, Boolean> result = underTest.checkComponentKeys(dbSession, newArrayList("foo:struts", "foo:struts-core", "foo:struts-ui")); assertThat(result) .hasSize(3) .containsOnly(entry("foo:struts", false), entry("foo:struts-core", true), entry("foo:struts-ui", false)); }
@Test public void simulate_bulk_update_key() { db.prepareDbUnit(getClass(), "shared.xml"); Map<String, String> result = underTest.simulateBulkUpdateKey(dbSession, "A", "org.struts", "foo"); assertThat(result) .hasSize(3) .containsOnly(entry("org.struts:struts", "foo:struts"), entry("org.struts:struts-core", "foo:struts-core"), entry("org.struts:struts-ui", "foo:struts-ui")); }
@Test public void selectByKeys_returns_values_when_properties_has_value_stored_in_clob() { underTest.save(dbSession, A_KEY, VALUE_SIZE_4001); underTest.save(dbSession, ANOTHER_KEY, OTHER_VALUE_SIZE_4001); assertThat(underTest.selectByKeys(dbSession, ImmutableSet.of(A_KEY, ANOTHER_KEY))) .containsOnly( entry(A_KEY, Optional.of(VALUE_SIZE_4001)), entry(ANOTHER_KEY, Optional.of(OTHER_VALUE_SIZE_4001))); }
@Test public void selectByKeys_returns_empty_string_when_property_is_empty_in_DB() { underTest.saveAsEmpty(dbSession, A_KEY); underTest.saveAsEmpty(dbSession, ANOTHER_KEY); assertThat(underTest.selectByKeys(dbSession, ImmutableSet.of(A_KEY, ANOTHER_KEY))) .containsOnly( entry(A_KEY, Optional.of("")), entry(ANOTHER_KEY, Optional.of(""))); }
@Test public void selectByKeys_returns_value_when_property_has_value_stored_in_varchar() { underTest.save(dbSession, A_KEY, VALUE_SMALL); underTest.save(dbSession, ANOTHER_KEY, OTHER_VALUE_SMALL); assertThat(underTest.selectByKeys(dbSession, ImmutableSet.of(A_KEY, ANOTHER_KEY))) .containsOnly( entry(A_KEY, Optional.of(VALUE_SMALL)), entry(ANOTHER_KEY, Optional.of(OTHER_VALUE_SMALL))); }
@Test public void setAttributes_should_not_clear_existing_values() { issue.setAttributes(ImmutableMap.of("1", "one")); assertThat(issue.attribute("1")).isEqualTo("one"); issue.setAttributes(ImmutableMap.of("2", "two")); assertThat(issue.attributes()).containsOnly(entry("1", "one"), entry("2", "two")); issue.setAttributes(null); assertThat(issue.attributes()).containsOnly(entry("1", "one"), entry("2", "two")); }
@Test public void insert() { underTest.insert(dbSession, create("O_1", 256)); Map<String, Object> result = db.selectFirst(dbSession, "select organization_uuid as \"organizationUuid\", user_id as \"userId\" from organization_members"); assertThat(result).containsOnly(entry("organizationUuid", "O_1"), entry("userId", 256L)); }
@Test public void facet_on_created_at() { SearchOptions searchOptions = fixtureForCreatedAtFacet(); Builder query = newQueryBuilder().createdBefore(parseDateTime("2016-01-01T00:00:00+0100")); Map<String, Long> createdAt = new Facets(underTest.search(query.build(), searchOptions), system2.getDefaultTimeZone()).get("createdAt"); assertThat(createdAt).containsOnly( entry("2011-01-01", 10L), entry("2012-01-01", 0L), entry("2013-01-01", 0L), entry("2014-01-01", 50L), entry("2015-01-01", 10L)); }
@Test public void helper_parse_methods() { assertThat(KeyValueFormat.parseIntDate("1=2014-01-15")).hasSize(1); assertThat(KeyValueFormat.parseIntDateTime("1=2014-01-15T15:50:45+0100")).hasSize(1); assertThat(KeyValueFormat.parseIntDouble("1=3.14")).hasSize(1); assertThat(KeyValueFormat.parseIntInt("1=10")).containsOnly(entry(1, 10)); assertThat(KeyValueFormat.parseIntString("1=one")).containsOnly(entry(1, "one")); assertThat(KeyValueFormat.parseIntString("1=\"escaped\"")).containsOnly(entry(1, "escaped")); assertThat(KeyValueFormat.parseStringInt("one=1")).containsOnly(entry("one", 1)); assertThat(KeyValueFormat.parseStringDouble("pi=3.14")).containsOnly(entry("pi", 3.14)); }
@Test public void test_copy_of_properties() { Map<String, String> map = Maps.newHashMap(); map.put("foo", "bar"); ScannerProperties underTest = new ScannerProperties(map); assertThat(underTest.properties()).containsOnly(entry("foo", "bar")); assertThat(underTest.properties()).isNotSameAs(map); map.put("put", "after_copy"); assertThat(underTest.properties()).hasSize(1); } }
@Test public void should_not_read_hierarchy_if_metadata_available() { when(reader.readMetadata()).thenReturn(ScannerReport.Metadata.newBuilder() .putModulesProjectRelativePathByKey("module1", "path1") .setRootComponentRef(1) .build()); Map<String, String> pathByModuleKey = reportModulesPath.get(); assertThat(pathByModuleKey).containsExactly(entry("module1", "path1")); verify(reader).readMetadata(); verifyNoMoreInteractions(reader); }
@Test public void check_component_keys_checks_inactive_components() { OrganizationDto organizationDto = db.organizations().insert(); db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("my-project")); db.components().insertComponent(ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("your-project").setEnabled(false)); Map<String, Boolean> result = underTest.checkComponentKeys(dbSession, newArrayList("my-project", "your-project", "new-project")); assertThat(result) .hasSize(3) .containsOnly(entry("my-project", true), entry("your-project", true), entry("new-project", false)); }