@Test public void test_loadAll_with_no_properties() { Map<String, String> map = underTest.loadAll(); assertThat(map).isEmpty(); }
@Test public void test_defaults() { assertThat(underTest.getMethod()).isEqualTo(WsRequest.Method.GET); assertThat(underTest.getParams()).isEmpty(); assertThat(underTest.getMediaType()).isEqualTo(MediaTypes.JSON); assertThat(underTest.getPath()).isEqualTo("api/foo"); }
@Test public void test_parse_empty() { diffs = FieldDiffs.parse(""); assertThat(diffs.diffs()).isEmpty(); } }
@Test public void null_param_value() { Boolean nullBool = null; underTest.setParam("key", nullBool); assertThat(underTest.getParams()).isEmpty(); }
@Test public void getCumulativeDurations_returns_an_empty_map_when_computation_is_disabled_in_constructor() { VisitorsCrawler underTest = new VisitorsCrawler(Arrays.asList(spyPreOrderTypeAwareVisitor, spyPostOrderTypeAwareVisitor), false); underTest.visit(COMPONENT_TREE); assertThat(underTest.getCumulativeDurations()).isEmpty(); }
@Test public void getCumulativeDurations_returns_an_empty_map_when_computation_is_disabled_in_constructor() { VisitorsCrawler underTest = new VisitorsCrawler(Arrays.asList(spyPreOrderTypeAwareVisitor, spyPostOrderTypeAwareVisitor), false); underTest.visit(COMPONENT_TREE); assertThat(underTest.getCumulativeDurations()).isEmpty(); }
@Test public void simple_tracking() { rawIssues.add(createIssue(1, RuleTesting.XOO_X1)); Tracking<DefaultIssue, DefaultIssue> tracking = underTest.track(FILE); assertThat(tracking.getUnmatchedBases()).isEmpty(); assertThat(tracking.getMatchedRaws()).isEmpty(); assertThat(tracking.getUnmatchedRaws()).containsOnly(rawIssues.get(0)); }
@Test public void getProperties_return_empty_if_DB_error_on_first_call_ever_out_of_thread_cache() { SettingLoader settingLoaderMock = mock(SettingLoader.class); PersistenceException toBeThrown = new PersistenceException("Faking an error connecting to DB"); doThrow(toBeThrown).when(settingLoaderMock).loadAll(); underTest = new ThreadLocalSettings(new PropertyDefinitions(), new Properties(), settingLoaderMock); assertThat(underTest.getProperties()) .isEmpty(); }
@Test void shouldValidateIfEverythingIsGood() { BackupConfig backupConfig = new BackupConfig("0 0 12 * * ?", "/bin/true", false, false); backupConfig.validate(null); assertThat(backupConfig.errors()).isEmpty(); }
@Test public void getProperties_returns_empty_if_DB_error_on_first_call_ever_in_thread_cache() { SettingLoader settingLoaderMock = mock(SettingLoader.class); PersistenceException toBeThrown = new PersistenceException("Faking an error connecting to DB"); doThrow(toBeThrown).when(settingLoaderMock).loadAll(); underTest = new ThreadLocalSettings(new PropertyDefinitions(), new Properties(), settingLoaderMock); underTest.load(); assertThat(underTest.getProperties()) .isEmpty(); }
@Test public void convert_data_to_map() { underTest.setData((Map) null); assertThat(underTest.getDataAsMap()).isEmpty(); underTest.setData(Collections.emptyMap()); assertThat(underTest.getDataAsMap()).isEmpty(); underTest.setData(ImmutableMap.of("k1", "v1", "k2", "v2")); assertThat(underTest.getDataAsMap()).containsOnly(entry("k1", "v1"), entry("k2", "v2")); } }
@Test public void add_does_not_assignee_if_empty_neither_globally_nor_per_assignee() { underTest.add(new DefaultIssue().setType(randomRuleTypeExceptHotspot).setAssigneeUuid(null).setNew(new Random().nextBoolean())); DistributedMetricStatsInt globalDistribution = underTest.globalStatistics().getDistributedMetricStats(Metric.ASSIGNEE); assertThat(globalDistribution.getTotal()).isEqualTo(0); assertThat(globalDistribution.getForLabel(null).isPresent()).isFalse(); assertThat(underTest.getAssigneesStatistics()).isEmpty(); }
@Test public void groupByKey() { assertThat(ActiveRuleParamDto.groupByKey(Collections.emptyList())).isEmpty(); Collection<ActiveRuleParamDto> dtos = Arrays.asList( new ActiveRuleParamDto().setKey("foo"), new ActiveRuleParamDto().setKey("bar") ); Map<String, ActiveRuleParamDto> group = ActiveRuleParamDto.groupByKey(dtos); assertThat(group.keySet()).containsOnly("foo", "bar"); } }
@Test public void testContextProperties() { assertThat(tester.getContextProperties()).isEmpty(); tester.addContextProperty("foo", "bar"); assertThat(tester.getContextProperties()).containsOnly(entry("foo", "bar")); } }
@Test public void put_property() { assertThat(underTest.getAll()).isEmpty(); underTest.put("foo", "bar"); assertThat(underTest.getAll()).containsOnly(entry("foo", "bar")); }
@Test public void noProfileDefinitions() { BuiltInQProfileDefinitionsBridge bridge = new BuiltInQProfileDefinitionsBridge(); BuiltInQualityProfilesDefinition.Context context = new BuiltInQualityProfilesDefinition.Context(); bridge.define(context); assertThat(context.profilesByLanguageAndName()).isEmpty(); }
@Test public void setCharacteristics_null_is_considered_as_empty() { CeTask task = underTest.setOrganizationUuid("org1").setType("TYPE_1").setUuid("UUID_1") .setCharacteristics(null) .build(); assertThat(task.getCharacteristics()).isEmpty(); }
@Test public void return_nothing_on_unknown_project() { OrganizationDto organization = dbTester.organizations().insert(); ComponentDto project = dbTester.components().insertPrivateProject(organization); dbTester.components().insertSnapshot(project); Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById("UNKNOWN"); assertThat(docsById).isEmpty(); }
@Test public void does_not_fail_when_quality_gate_has_no_value() { OrganizationDto organization = dbTester.organizations().insert(); ComponentDto project = dbTester.components().insertPrivateProject(organization); MetricDto metric = dbTester.measures().insertMetric(m -> m.setValueType(LEVEL.name()).setKey("alert_status")); dbTester.measures().insertLiveMeasure(project, metric, m -> m.setValue(null).setVariation(null).setData((String) null)); Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById(); assertThat(docsById.get(project.uuid()).getMeasures().getNumericMeasures()).isEmpty(); }