use of org.junit.Assert.assertTrue in project flink by apache.
the class ReporterSetupTest method testSeveralReportersWithArgumentForwarding.
/**
* Verifies that multiple reporters can be configured with all their arguments being forwarded.
*/
@Test
public void testSeveralReportersWithArgumentForwarding() {
final Configuration config = new Configuration();
configureReporter1(config);
configureReporter2(config);
final List<ReporterSetup> reporterSetups = ReporterSetup.fromConfiguration(config, null);
Assert.assertEquals(2, reporterSetups.size());
final Optional<ReporterSetup> reporter1Config = reporterSetups.stream().filter(c -> "reporter1".equals(c.getName())).findFirst();
Assert.assertTrue(reporter1Config.isPresent());
assertReporter1Configured(reporter1Config.get());
final Optional<ReporterSetup> reporter2Config = reporterSetups.stream().filter(c -> "reporter2".equals(c.getName())).findFirst();
Assert.assertTrue(reporter2Config.isPresent());
assertReporter2Configured(reporter2Config.get());
}
use of org.junit.Assert.assertTrue in project hbase by apache.
the class TestSpaceQuotaBasicFunctioning method testDisablePolicyQuotaAndViolate.
@Test
public void testDisablePolicyQuotaAndViolate() throws Exception {
TableName tableName = helper.createTable();
helper.setQuotaLimit(tableName, SpaceViolationPolicy.DISABLE, 1L);
helper.writeData(tableName, SpaceQuotaHelperForTests.ONE_MEGABYTE * 2L);
TEST_UTIL.getConfiguration().setLong("hbase.master.quotas.region.report.retention.millis", 100);
HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
MasterQuotaManager quotaManager = master.getMasterQuotaManager();
// Make sure the master has report for the table.
Waiter.waitFor(TEST_UTIL.getConfiguration(), 30 * 1000, new Waiter.Predicate<Exception>() {
@Override
public boolean evaluate() throws Exception {
Map<RegionInfo, Long> regionSizes = quotaManager.snapshotRegionSizes();
List<RegionInfo> tableRegions = MetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), tableName);
return regionSizes.containsKey(tableRegions.get(0));
}
});
// Check if disabled table region report present in the map after retention period expired.
// It should be present after retention period expired.
final long regionSizes = quotaManager.snapshotRegionSizes().keySet().stream().filter(k -> k.getTable().equals(tableName)).count();
Assert.assertTrue(regionSizes > 0);
}
use of org.junit.Assert.assertTrue in project CzechIdMng by bcvsolutions.
the class IdentityFilterTest method testRecursivelyFilter.
@Test
public void testRecursivelyFilter() {
// setting employees
IdmIdentityDto person1 = getIdmIdentity("Klement", "Marek", "ThisIsTestName011@gemail.eu", "000000011", false);
IdmIdentityDto person2 = getIdmIdentity("Klement", "Marek", "ThisIsTestName014@gemail.eu", "000000014", false);
IdmIdentityDto person3 = getIdmIdentity("Klement", "Marek", "ThisIsTestName015@gemail.eu", "000000015", false);
IdmIdentityDto person4 = getIdmIdentity("Klement", "Marek", "ThisIsTestName016@gemail.eu", "000000016", false);
// setting structure
IdmTreeTypeDto type1 = getHelper().createTreeType("ThisIsTestType005x");
IdmTreeTypeDto type2 = getHelper().createTreeType("ThisIsTestType006x");
/*
r1 o
/
n1 o
/
n2 o
*/
IdmTreeNodeDto node1 = getHelper().createTreeNode(type1, "ThisIsTestNode005", null);
IdmTreeNodeDto node11 = getHelper().createTreeNode(type1, "ThisIsTestNode006", node1);
IdmTreeNodeDto node12 = getHelper().createTreeNode(type1, "ThisIsTestNode007", node11);
/*
r2 o
*/
IdmTreeNodeDto node2 = getHelper().createTreeNode(type2, "ThisIsTestNode008", null);
// contracts
getHelper().createContract(person1, node1);
getHelper().createContract(person2, node11);
getHelper().createContract(person3, node12);
getHelper().createContract(person4, node2);
// node1 UUID
UUID node1id = node1.getId();
// test
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setFirstName(person1.getFirstName());
filter.setRecursively(true);
filter.setTreeNode(node1id);
List<IdmIdentityDto> results = identityService.find(filter, null).getContent();
Assert.assertEquals("Wrong Recursive firstname", 3, results.size());
Assert.assertTrue(results.stream().anyMatch(i -> i.getId().equals(person1.getId())));
Assert.assertTrue(results.stream().anyMatch(i -> i.getId().equals(person2.getId())));
Assert.assertTrue(results.stream().anyMatch(i -> i.getId().equals(person3.getId())));
//
filter.setRecursively(false);
results = identityService.find(filter, null).getContent();
Assert.assertEquals("Wrong NonRecursive firstname", 1, results.size());
Assert.assertTrue(results.stream().anyMatch(i -> i.getId().equals(person1.getId())));
}
use of org.junit.Assert.assertTrue in project CzechIdMng by bcvsolutions.
the class IdentityAddRoleBulkActionIntegrationTest method processBulkActionByIdsWithoutValidityIsGiven.
@Test
public void processBulkActionByIdsWithoutValidityIsGiven() {
IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
IdmIdentityContractDto primeContract = getHelper().getPrimeContract(identityOne);
IdmIdentityContractDto otherValidContract = getHelper().createContract(identityOne, null, LocalDate.now().plusDays(1), LocalDate.now().plusDays(2));
IdmIdentityContractDto otherInvalidContract = getHelper().createContract(identityOne, null, null, LocalDate.now().minusDays(1));
IdmRoleDto roleOne = getHelper().createRole();
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityAddRoleBulkAction.NAME);
bulkAction.setIdentifiers(Sets.newHashSet(identityOne.getId()));
Map<String, Object> properties = new HashMap<>();
properties.put(IdentityAddRoleBulkAction.ROLE_CODE, Lists.newArrayList(roleOne.getId().toString()));
properties.put(IdentityAddRoleBulkAction.PRIMARY_CONTRACT_CODE, Boolean.FALSE);
properties.put(IdentityAddRoleBulkAction.APPROVE_CODE, Boolean.FALSE);
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 2l, null, null);
List<IdmIdentityContractDto> contracts = identityContractService.findAllByIdentity(identityOne.getId());
// +1 primary vithout validity is set
Assert.assertEquals(3, contracts.size());
Assert.assertTrue(identityRoleService.findAllByContract(otherInvalidContract.getId()).isEmpty());
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByIdentity(identityOne.getId());
Assert.assertEquals(2, identityRoles.size());
Assert.assertTrue(identityRoles.stream().anyMatch(ir -> ir.getRole().equals(roleOne.getId()) && ir.getIdentityContract().equals(primeContract.getId()) && ir.getValidFrom() == null && ir.getValidTill() == null));
Assert.assertTrue(identityRoles.stream().anyMatch(ir -> ir.getRole().equals(roleOne.getId()) && ir.getIdentityContract().equals(otherValidContract.getId()) && ir.getValidFrom().equals(otherValidContract.getValidFrom()) && ir.getValidTill() == null));
}
use of org.junit.Assert.assertTrue in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleRequestServiceIntegrationTest method testExecuteRequestForSameAutomaticRole.
@Test
public void testExecuteRequestForSameAutomaticRole() {
IdmRoleDto role = getHelper().createRole();
IdmAutomaticRoleAttributeDto automaticRole = getHelper().createAutomaticRole(role.getId());
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
IdmIdentityContractDto primeContract = getHelper().getPrimeContract(identity);
//
// create two requests
IdmRoleRequestDto requestOne = new IdmRoleRequestDto();
requestOne.setApplicant(identity.getId());
requestOne.setExecuteImmediately(true);
requestOne.setRequestedByType(RoleRequestedByType.MANUALLY);
requestOne.setState(RoleRequestState.EXECUTED);
requestOne = roleRequestService.save(requestOne);
Assert.assertEquals(RoleRequestState.CONCEPT, requestOne.getState());
IdmConceptRoleRequestDto concept = new IdmConceptRoleRequestDto();
concept.setRoleRequest(requestOne.getId());
concept.setState(RoleRequestState.EXECUTED);
concept.setOperation(ConceptRoleRequestOperation.ADD);
concept.setRole(role.getId());
concept.setAutomaticRole(automaticRole.getId());
concept.setIdentityContract(primeContract.getId());
concept = conceptRoleRequestService.save(concept);
Assert.assertEquals(RoleRequestState.CONCEPT, concept.getState());
//
// create two requests
IdmRoleRequestDto requestTwo = new IdmRoleRequestDto();
requestTwo.setApplicant(identity.getId());
requestTwo.setExecuteImmediately(true);
requestTwo.setRequestedByType(RoleRequestedByType.MANUALLY);
requestTwo.setState(RoleRequestState.EXECUTED);
requestTwo = roleRequestService.save(requestTwo);
Assert.assertEquals(RoleRequestState.CONCEPT, requestTwo.getState());
concept = new IdmConceptRoleRequestDto();
concept.setRoleRequest(requestTwo.getId());
concept.setState(RoleRequestState.EXECUTED);
concept.setOperation(ConceptRoleRequestOperation.ADD);
concept.setRole(role.getId());
concept.setAutomaticRole(automaticRole.getId());
concept.setIdentityContract(primeContract.getId());
concept = conceptRoleRequestService.save(concept);
Assert.assertEquals(RoleRequestState.CONCEPT, concept.getState());
getHelper().startRequestInternal(requestOne, true, true);
requestOne = roleRequestService.get(requestOne.getId());
Assert.assertEquals(RoleRequestState.EXECUTED, requestOne.getState());
getHelper().startRequestInternal(requestTwo, true, true);
requestTwo = roleRequestService.get(requestTwo.getId());
Assert.assertEquals(RoleRequestState.EXECUTED, requestTwo.getState());
//
List<IdmIdentityRoleDto> assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
Assert.assertEquals(1, assignedRoles.size());
Assert.assertTrue(assignedRoles.stream().allMatch(ir -> ir.getAutomaticRole().equals(automaticRole.getId())));
}
Aggregations