@Test(groups = {TLS, PROFILE_SPECIFIC_TESTS}) public void testHttpPortIsClosed() throws Exception { assertThat(httpPort).isNotNull(); assertThat(httpsPort).isNotNull(); waitForNodeRefresh(); List<String> activeNodesUrls = getActiveNodesUrls(); assertThat(activeNodesUrls).hasSize(3); List<String> hosts = activeNodesUrls.stream() .map((uri) -> URI.create(uri).getHost()) .collect(toList()); for (String host : hosts) { assertPortIsOpen(host, httpsPort); assertPortIsClosed(host, httpPort); } }
@Test public void selectByName() { db.getDbClient().groupDao().insert(dbSession, aGroup); GroupDto group = underTest.selectByName(dbSession, AN_ORGANIZATION.getUuid(), aGroup.getName()).get(); assertThat(group.getId()).isNotNull(); assertThat(group.getOrganizationUuid()).isEqualTo(aGroup.getOrganizationUuid()); assertThat(group.getName()).isEqualTo(aGroup.getName()); assertThat(group.getDescription()).isEqualTo(aGroup.getDescription()); assertThat(group.getCreatedAt()).isEqualTo(new Date(NOW)); assertThat(group.getUpdatedAt()).isEqualTo(new Date(NOW)); }
@Test public void testCreateScheduleAndRun() throws Exception { scheduler.registerJob("* * * * * ?", createJobDescription()); assertThat(scheduler.ifJobExist("SampleJob", "SampleService")).isEqualTo(true); TestUtils.await().untilAsserted(() -> assertThat(SampleQuartzJob.COUNT_EXECUTION) .isNotNull().isGreaterThan(1)); }
private QProfileDto verifyProfileInDb(OrganizationDto organization, BuiltInQProfile builtIn) { QProfileDto profileOnOrg1 = db.getDbClient().qualityProfileDao().selectByNameAndLanguage(dbSession, organization, builtIn.getName(), builtIn.getLanguage()); assertThat(profileOnOrg1.getLanguage()).isEqualTo(builtIn.getLanguage()); assertThat(profileOnOrg1.getName()).isEqualTo(builtIn.getName()); assertThat(profileOnOrg1.getOrganizationUuid()).isEqualTo(organization.getUuid()); assertThat(profileOnOrg1.getParentKee()).isNull(); assertThat(profileOnOrg1.getLastUsed()).isNull(); assertThat(profileOnOrg1.getUserUpdatedAt()).isNull(); assertThat(profileOnOrg1.getRulesUpdatedAt()).isNotEmpty(); assertThat(profileOnOrg1.getKee()).isNotEqualTo(profileOnOrg1.getRulesProfileUuid()); assertThat(profileOnOrg1.getId()).isNotNull(); return profileOnOrg1; }
@Test public void create_user_with_minimum_fields() { createDefaultGroup(); underTest.createAndCommit(db.getSession(), NewUser.builder() .setLogin("us") .setName("User") .build(), u -> { }); UserDto dto = dbClient.userDao().selectByLogin(session, "us"); assertThat(dto.getId()).isNotNull(); assertThat(dto.getLogin()).isEqualTo("us"); assertThat(dto.getName()).isEqualTo("User"); assertThat(dto.getEmail()).isNull(); assertThat(dto.getScmAccounts()).isNull(); assertThat(dto.isActive()).isTrue(); }
@Test public void checkAndCreateCustom() { OrganizationDto organization = db.organizations().insert(); QProfileDto profile = underTest.checkAndCreateCustom(dbSession, organization, new QProfileName("xoo", "P1")); assertThat(profile.getOrganizationUuid()).isEqualTo(organization.getUuid()); assertThat(profile.getKee()).isNotEmpty(); assertThat(profile.getName()).isEqualTo("P1"); assertThat(profile.getLanguage()).isEqualTo("xoo"); assertThat(profile.getId()).isNotNull(); assertThat(profile.isBuiltIn()).isFalse(); QProfileDto reloaded = db.getDbClient().qualityProfileDao().selectByNameAndLanguage(dbSession, organization, profile.getName(), profile.getLanguage()); assertEqual(profile, reloaded); assertThat(db.getDbClient().qualityProfileDao().selectOrderedByOrganizationUuid(dbSession, organization)).extracting(QProfileDto::getKee).containsExactly(profile.getKee()); }
assertThat(result.getId()).isNotNull(); assertThat(result.getKey()).isEqualTo("coverage"); assertThat(result.getShortName()).isEqualTo("Coverage");
@Test public void testHashCode() { assertThat(new PropertyDto().setKey("123").setResourceId(123L).hashCode()).isNotNull(); assertThat(new PropertyDto().setKey("123").setResourceId(123L).hashCode()) .isEqualTo(new PropertyDto().setKey("123").setResourceId(123L).hashCode()); }
assertThat(user.getId()).isNotNull(); assertThat(user.getLogin()).isEqualTo("john"); assertThat(user.getName()).isEqualTo("John");
}); assertThat(dto.getId()).isNotNull(); assertThat(dto.getLogin()).isEqualTo("user"); assertThat(dto.getName()).isEqualTo("User");
@Test public void selectOpenByComponentUuid_should_correctly_map_required_fields() { RuleDefinitionDto rule = db.rules().insert(); ComponentDto project = db.components().insertMainBranch(); ComponentDto projectBranch = db.components().insertProjectBranch(project, b -> b.setKey("feature/foo") .setBranchType(BranchType.SHORT)); ComponentDto file = db.components().insertComponent(newFileDto(projectBranch)); IssueDto fpIssue = db.issues().insert(rule, projectBranch, file, i -> i.setStatus("RESOLVED").setResolution("FALSE-POSITIVE")); ShortBranchIssueDto fp = underTest.selectOpenByComponentUuids(db.getSession(), Collections.singletonList(file.uuid())).get(0); assertThat(fp.getLine()).isEqualTo(fpIssue.getLine()); assertThat(fp.getMessage()).isEqualTo(fpIssue.getMessage()); assertThat(fp.getChecksum()).isEqualTo(fpIssue.getChecksum()); assertThat(fp.getRuleKey()).isEqualTo(fpIssue.getRuleKey()); assertThat(fp.getStatus()).isEqualTo(fpIssue.getStatus()); assertThat(fp.getLine()).isNotNull(); assertThat(fp.getLine()).isNotZero(); assertThat(fp.getMessage()).isNotNull(); assertThat(fp.getChecksum()).isNotNull(); assertThat(fp.getChecksum()).isNotEmpty(); assertThat(fp.getRuleKey()).isNotNull(); assertThat(fp.getStatus()).isNotNull(); assertThat(fp.getBranchName()).isEqualTo("feature/foo"); assertThat(fp.getIssueCreationDate()).isNotNull(); }
@Test public void create_group_on_specific_organization() throws Exception { OrganizationDto org = db.organizations().insert(); loginAsAdmin(org); newRequest() .setParam("organization", org.getKey()) .setParam("name", "some-product-bu") .setParam("description", "Business Unit for Some Awesome Product") .execute() .assertJson("{" + " \"group\": {" + " \"organization\": \"" + org.getKey() + "\"," + " \"name\": \"some-product-bu\"," + " \"description\": \"Business Unit for Some Awesome Product\"," + " \"membersCount\": 0" + " }" + "}"); GroupDto createdGroup = db.users().selectGroup(org, "some-product-bu").get(); assertThat(createdGroup.getId()).isNotNull(); assertThat(createdGroup.getOrganizationUuid()).isEqualTo(org.getUuid()); }
@Test @SuppressWarnings("SelfEquals") // We're asserting that calling .equals on a proxy does not redirect // the .equals call to the instance its being proxied. public void shouldAllowObjectMethodsWhenLeading() { when(mockLeader.getSuspectedLeaderInMemory()).thenReturn(Optional.empty()); when(mockLeader.getCurrentTokenIfLeading()).thenReturn(Optional.empty()); when(mockLeader.isStillLeading(any(LeaderElectionService.LeadershipToken.class))) .thenReturn(LeaderElectionService.StillLeadingStatus.LEADING); Runnable proxy = AwaitingLeadershipProxy.newProxyInstance(Runnable.class, delegateSupplier, mockLeader); assertThat(proxy.hashCode()).isNotNull(); assertThat(proxy.equals(proxy)).isTrue(); assertThat(proxy.equals(null)).isFalse(); assertThat(proxy.toString()).startsWith("com.palantir.leader.proxy.AwaitingLeadershipProxy@"); }
@Test @SuppressWarnings("SelfEquals") // We're asserting that calling .equals on a proxy does not redirect // the .equals call to the instance its being proxied. public void shouldAllowObjectMethodsWhenNotLeading() { when(mockLeader.getSuspectedLeaderInMemory()).thenReturn(Optional.empty()); when(mockLeader.getCurrentTokenIfLeading()).thenReturn(Optional.empty()); when(mockLeader.isStillLeading(any(LeaderElectionService.LeadershipToken.class))) .thenReturn(LeaderElectionService.StillLeadingStatus.NOT_LEADING); Runnable proxy = AwaitingLeadershipProxy.newProxyInstance(Runnable.class, delegateSupplier, mockLeader); assertThat(proxy.hashCode()).isNotNull(); assertThat(proxy.equals(proxy)).isTrue(); assertThat(proxy.equals(null)).isFalse(); assertThat(proxy.toString()).startsWith("com.palantir.leader.proxy.AwaitingLeadershipProxy@"); }
assertThat(this.listener.latch2.await(60, TimeUnit.SECONDS)).isTrue(); assertThat(this.listener.key).isEqualTo(123); assertThat(this.listener.partition).isNotNull(); assertThat(this.listener.topic).isEqualTo("annotated2");
private void doSimpleTest404(HttpClient client) { Integer res = client.followRedirect(true) .get() .uri("/unsupportedURI") .responseSingle((r, buf) -> Mono.just(r.status().code())) .log() .block(); assertThat(res).isNotNull(); if (res != 404) { throw new IllegalStateException("test status failed with " + res); } }
@Test public void testCreateUser() throws RedmineException { User createdUser = null; try { User userToCreate = UserGenerator.generateRandomUser(); createdUser = userManager.createUser(userToCreate); assertThat(createdUser).isNotNull(); assertThat(createdUser.getLogin()).isEqualTo(userToCreate.getLogin()); assertThat(createdUser.getFirstName()).isEqualTo(userToCreate.getFirstName()); assertThat(createdUser.getLastName()).isEqualTo(userToCreate.getLastName()); assertThat(createdUser.getId()).isNotNull(); } finally { if (createdUser != null) { userManager.deleteUser(createdUser.getId()); } } }
@Test public void testTypes() { TestTypes object = createSavedInstance(TestTypes.class); object.mBooleanObj = Boolean.FALSE; StateSaver.restoreInstanceState(object, mBundle); assertThat(object.mBooleanObj).isNull(); object.mInt = 5; object.mIntegerObj = 6; object.mParcelableArrayList = new ArrayList<TestTypes.ParcelableImpl>() {{ add(new TestTypes.ParcelableImpl(7)); }}; StateSaver.saveInstanceState(object, mBundle); object.mInt = 0; object.mIntegerObj = null; object.mParcelableArrayList = null; StateSaver.restoreInstanceState(object, mBundle); assertThat(object.mInt).isEqualTo(5); assertThat(object.mIntegerObj).isNotNull().isEqualTo(6); assertThat(object.mParcelableArrayList).isNotNull().isNotEmpty().containsExactly(new TestTypes.ParcelableImpl(7)); }
@Test // #414 public void shouldRecognizeOverwrittenPostLoadFromSuperClass() { ChildA parent = new ChildA(); parent.add(new ChildB()); parent.add(new ChildB()); parent.add(new ChildC()); session.save(parent); session.clear(); Set<AnotherEntity> children = session.load(ChildA.class, parent.getUuid()).getChildren(); assertThat(children).isNotEmpty() .filteredOn(ChildB.class::isInstance) .allSatisfy(child -> assertThat(((ChildB) child).getValue()).isNotNull()); } }
@Test public void testTypesReflection() { TestTypesReflection object = createSavedInstance(TestTypesReflection.class); object.setIntegerObj(5); StateSaver.restoreInstanceState(object, mBundle); assertThat(object.getIntegerObj()).isNull(); object.setInt(5); object.setIntegerObj(6); object.setParcelableArrayList(new ArrayList<TestTypes.ParcelableImpl>() {{ add(new TestTypes.ParcelableImpl(7)); }}); StateSaver.saveInstanceState(object, mBundle); object.setInt(0); object.setIntegerObj(null); object.setParcelableArrayList(null); StateSaver.restoreInstanceState(object, mBundle); assertThat(object.getInt()).isEqualTo(5); assertThat(object.getIntegerObj()).isNotNull().isEqualTo(6); assertThat(object.getParcelableArrayList()).isNotNull().isNotEmpty().containsExactly(new TestTypes.ParcelableImpl(7)); }