@Test public void toInteger() { assertThat(RubyUtils.toInteger(null)).isNull(); assertThat(RubyUtils.toInteger("")).isNull(); assertThat(RubyUtils.toInteger(" ")).isNull(); assertThat(RubyUtils.toInteger("123")).isEqualTo(123); assertThat(RubyUtils.toInteger(123)).isEqualTo(123); assertThat(RubyUtils.toInteger(123L)).isEqualTo(123); }
@Test public void noSourcePublisherCombined() { assertThat(Mono.zip(args -> (int) args[0] + (int) args[1]) .block()).isNull(); }
@Test public void empty() throws Exception { CompletableFuture<Integer> f = Mono.<Integer>empty().toFuture(); assertThat(f.get()).isNull(); } }
@Test public void unset_line_has_no_effect_if_line_is_already_null() { issue.setLine(null); boolean updated = underTest.unsetLine(issue, context); assertThat(updated).isFalse(); assertThat(issue.line()).isNull(); assertThat(issue.isChanged()).isFalse(); assertThat(issue.currentChange()).isNull(); assertThat(issue.mustSendNotifications()).isFalse(); }
private void verifyComponentByKey(String publicKey, String key, String shortName, @Nullable String uuid) { Map<String, Component> componentsByKey = indexAllComponentsInTreeByKey(treeRootHolder.getRoot()); Component component = componentsByKey.get(publicKey); assertThat(component.getDbKey()).isEqualTo(key); assertThat(component.getReportAttributes().getRef()).isNull(); assertThat(component.getKey()).isEqualTo(publicKey); assertThat(component.getShortName()).isEqualTo(shortName); if (uuid != null) { assertThat(component.getUuid()).isEqualTo(uuid); } else { assertThat(component.getUuid()).isNotNull(); } }
@Test public void delegateCallNull() throws Exception { MonoCallable<Integer> monoCallable = new MonoCallable<>(() -> null); assertThat(monoCallable.call()).isNull(); } }
@Test public void file_without_branch() throws Exception { addFileToFs(fileWithoutBranch); GenericCoverageReportParser parser = new GenericCoverageReportParser(); parser.parse(new File(this.getClass().getResource("coverage.xml").toURI()), context); assertThat(parser.numberOfMatchedFiles()).isEqualTo(1); assertThat(context.lineHits(fileWithoutBranch.key(), 2)).isEqualTo(0); assertThat(context.lineHits(fileWithoutBranch.key(), 3)).isEqualTo(1); assertThat(context.lineHits(fileWithoutBranch.key(), 4)).isNull(); assertThat(context.lineHits(fileWithoutBranch.key(), 5)).isEqualTo(1); assertThat(context.lineHits(fileWithoutBranch.key(), 6)).isEqualTo(0); }
@Test public void non_decimal_metric_has_no_scale() { Metric metric = new Metric.Builder("foo", "Foo", Metric.ValueType.INT) .create(); assertThat(metric.getDecimalScale()).isNull(); } }
@Test public void testConditions() { assertThat(tester.conditions("foo:src/Foo.java", 1)).isNull(); assertThat(tester.coveredConditions("foo:src/Foo.java", 1)).isNull(); tester.newCoverage() .onFile(new TestInputFileBuilder("foo", "src/Foo.java") .initMetadata("annot dsf fds foo bar\nasd\nasdas\nasdfas") .build()) .conditions(1, 4, 2) .save(); assertThat(tester.conditions("foo:src/Foo.java", 1)).isEqualTo(4); assertThat(tester.coveredConditions("foo:src/Foo.java", 1)).isEqualTo(2); }
@Test public void testLineHits() { assertThat(tester.lineHits("foo:src/Foo.java", 1)).isNull(); assertThat(tester.lineHits("foo:src/Foo.java", 4)).isNull(); tester.newCoverage() .onFile(new TestInputFileBuilder("foo", "src/Foo.java").initMetadata("annot dsf fds foo bar\nasdas").build()) .lineHits(1, 2) .lineHits(2, 3) .save(); assertThat(tester.lineHits("foo:src/Foo.java", 1)).isEqualTo(2); assertThat(tester.lineHits("foo:src/Foo.java", 2)).isEqualTo(3); }
@Test public void session_is_anonymous() { assertThat(underTest.getLogin()).isNull(); assertThat(underTest.getUuid()).isNull(); assertThat(underTest.isLoggedIn()).isFalse(); assertThat(underTest.getName()).isNull(); assertThat(underTest.getUserId()).isNull(); assertThat(underTest.getGroups()).isEmpty(); }
@Test public void null_param() { assertThat(underTest.param("a_string")).isNull(); assertThat(underTest.paramAsBoolean("a_boolean")).isNull(); assertThat(underTest.paramAsInt("a_number")).isNull(); assertThat(underTest.paramAsLong("a_number")).isNull(); }
@Test public void count_tokens_by_user() { UserDto user = db.users().insertUser(); db.users().insertToken(user, t -> t.setName("name")); db.users().insertToken(user, t -> t.setName("another-name")); Map<String, Integer> result = underTest.countTokensByUsers(dbSession, singletonList(user)); assertThat(result.get(user.getUuid())).isEqualTo(2); assertThat(result.get("unknown-user_uuid")).isNull(); } }
@Test public void nullValues() { rawIssue = createIssueWithoutFields(); issue = new DefaultFilterableIssue(mockedProject, projectAnalysisInfo, rawIssue, component); assertThat(issue.line()).isNull(); assertThat(issue.gap()).isNull(); } }
@Test public void get_session_for_anonymous() { AnonymousMockUserSession expected = new AnonymousMockUserSession(); threadLocalUserSession.set(expected); UserSession session = threadLocalUserSession.get(); assertThat(session).isSameAs(expected); assertThat(threadLocalUserSession.getLogin()).isNull(); assertThat(threadLocalUserSession.getUserId()).isNull(); assertThat(threadLocalUserSession.isLoggedIn()).isFalse(); assertThat(threadLocalUserSession.getGroups()).isEmpty(); }
@Test public void testCoverageAtLineZero() { assertThat(tester.lineHits("foo:src/Foo.java", 1)).isNull(); assertThat(tester.lineHits("foo:src/Foo.java", 4)).isNull(); exception.expect(IllegalStateException.class); tester.newCoverage() .onFile(new TestInputFileBuilder("foo", "src/Foo.java").initMetadata("annot dsf fds foo bar").build()) .lineHits(0, 3); }
@Test public void testCoverageAtLineOutOfRange() { assertThat(tester.lineHits("foo:src/Foo.java", 1)).isNull(); assertThat(tester.lineHits("foo:src/Foo.java", 4)).isNull(); exception.expect(IllegalStateException.class); tester.newCoverage() .onFile(new TestInputFileBuilder("foo", "src/Foo.java").initMetadata("annot dsf fds foo bar").build()) .lineHits(4, 3); }
@Test public void test_nullable_fields() { issue.setGap(null).setSeverity(null).setLine(null); assertThat(issue.gap()).isNull(); assertThat(issue.severity()).isNull(); assertThat(issue.line()).isNull(); }
@Test public void insert_row_with_only_mandatory_columns() { WebhookDeliveryDto dto = WebhookDeliveryTesting.newDto("DELIVERY_1", "WEBHOOK_UUID_1", "COMPONENT_1", "TASK_1") .setDurationMs(1000) .setHttpStatus(null) .setErrorStacktrace(null); underTest.insert(dbSession, dto); WebhookDeliveryDto stored = selectByUuid(dto.getUuid()); verifyMandatoryFields(dto, stored); assertThat(stored.getDurationMs()).isEqualTo(1000); // optional fields are null assertThat(stored.getHttpStatus()).isNull(); assertThat(stored.getErrorStacktrace()).isNull(); }
@Test public void rule_id_is_not_set_on_updated_issue_when_rule_is_removed() { RuleDefinitionDto rule = db.rules().insert(r -> r.setStatus(REMOVED)); ComponentDto project = db.components().insertMainBranch(); ComponentDto module = db.components().insertComponent(newModuleDto(project)); ComponentDto file = db.components().insertComponent(newFileDto(module)); DefaultIssue issue = newIssue(rule, project, file).toDefaultIssue(); Collection<IssueDto> results = underTest.save(db.getSession(), singletonList(issue)); assertThat(results).hasSize(1); assertThat(results.iterator().next().getRuleId()).isNull(); }