Search in sources :

Example 61 with Assert.assertEquals

use of org.junit.Assert.assertEquals in project jtharness by openjdk.

the class Filtering method absorbingExceptions_exceptionThrownOut.

@Test
public void absorbingExceptions_exceptionThrownOut() {
    try {
        final TestResult run = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(new BaseTestGroup() {

            Values values = createColumn(Double.class, Class.class).filter((Values.Transformer1<Class<?>>) c -> c.getConstructor().newInstance());

            @TestCase
            @TestData("values")
            public void myTest(Object s) {
                System.out.println("s = " + s);
            }
        });
        Assert.fail("Exception expected");
    } catch (RuntimeException e) {
        Assert.assertTrue(e.getCause() instanceof InvocationTargetException);
        Assert.assertTrue(e.getCause().getCause() instanceof NoSuchMethodException);
        Assert.assertEquals("java.lang.Double.<init>()", e.getCause().getCause().getMessage());
    }
}
Also used : java.util(java.util) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TU(com.oracle.tck.lib.autd2.unittests.TU) TestResult(com.oracle.tck.lib.autd2.TestResult) ValuesComparison(com.oracle.tck.lib.autd2.unittests.ValuesComparison) InvocationTargetException(java.lang.reflect.InvocationTargetException) java.awt(java.awt) DataFactory.createValues(com.sun.tck.lib.tgf.DataFactory.createValues) TestCase(com.sun.tck.test.TestCase) DataFactory.createRow(com.sun.tck.lib.tgf.DataFactory.createRow) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) Assert(org.junit.Assert) DataFactory.createColumn(com.sun.tck.lib.tgf.DataFactory.createColumn) Assert.assertEquals(org.junit.Assert.assertEquals) com.sun.tck.lib.tgf(com.sun.tck.lib.tgf) javax.swing(javax.swing) TestCase(com.sun.tck.test.TestCase) DataFactory.createValues(com.sun.tck.lib.tgf.DataFactory.createValues) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestResult(com.oracle.tck.lib.autd2.TestResult) InvocationTargetException(java.lang.reflect.InvocationTargetException) Test(org.junit.Test)

Example 62 with Assert.assertEquals

use of org.junit.Assert.assertEquals in project parquet-mr by apache.

the class TestParquetMetadataConverter method testParquetMetadataConverterWithoutDictionary.

@Test
public void testParquetMetadataConverterWithoutDictionary() throws IOException {
    ParquetMetadata parquetMetaData = createParquetMetaData(null, Encoding.PLAIN);
    ParquetMetadataConverter converter = new ParquetMetadataConverter();
    FileMetaData fmd1 = converter.toParquetMetadata(1, parquetMetaData);
    // Flag should be false
    fmd1.row_groups.forEach(rowGroup -> rowGroup.columns.forEach(column -> {
        assertFalse(column.meta_data.isSetDictionary_page_offset());
    }));
    ByteArrayOutputStream metaDataOutputStream = new ByteArrayOutputStream();
    Util.writeFileMetaData(fmd1, metaDataOutputStream);
    ByteArrayInputStream metaDataInputStream = new ByteArrayInputStream(metaDataOutputStream.toByteArray());
    FileMetaData fmd2 = Util.readFileMetaData(metaDataInputStream);
    ParquetMetadata pmd2 = converter.fromParquetMetadata(fmd2);
    long dicOffsetConverted = pmd2.getBlocks().get(0).getColumns().get(0).getDictionaryPageOffset();
    Assert.assertEquals(0, dicOffsetConverted);
}
Also used : Encoding(org.apache.parquet.column.Encoding) Arrays(java.util.Arrays) LogicalTypeAnnotation.decimalType(org.apache.parquet.schema.LogicalTypeAnnotation.decimalType) ConvertedType(org.apache.parquet.format.ConvertedType) Group(org.apache.parquet.example.data.Group) LogicalTypeAnnotation.dateType(org.apache.parquet.schema.LogicalTypeAnnotation.dateType) SecureRandom(java.security.SecureRandom) LogicalTypeAnnotation.enumType(org.apache.parquet.schema.LogicalTypeAnnotation.enumType) Configuration(org.apache.hadoop.conf.Configuration) BigInteger(java.math.BigInteger) GroupReadSupport(org.apache.parquet.hadoop.example.GroupReadSupport) OffsetIndexBuilder(org.apache.parquet.internal.column.columnindex.OffsetIndexBuilder) ParquetReader(org.apache.parquet.hadoop.ParquetReader) Set(java.util.Set) LogicalTypeAnnotation.bsonType(org.apache.parquet.schema.LogicalTypeAnnotation.bsonType) EncodingStats(org.apache.parquet.column.EncodingStats) ParquetMetadataConverter.filterFileMetaDataByStart(org.apache.parquet.format.converter.ParquetMetadataConverter.filterFileMetaDataByStart) Assert.assertFalse(org.junit.Assert.assertFalse) ColumnDescriptor(org.apache.parquet.column.ColumnDescriptor) BlockMetaData(org.apache.parquet.hadoop.metadata.BlockMetaData) PageHeader(org.apache.parquet.format.PageHeader) SimpleGroup(org.apache.parquet.example.data.simple.SimpleGroup) CompressionCodecName(org.apache.parquet.hadoop.metadata.CompressionCodecName) UNCOMPRESSED(org.apache.parquet.format.CompressionCodec.UNCOMPRESSED) ParquetMetadataConverter.getOffset(org.apache.parquet.format.converter.ParquetMetadataConverter.getOffset) LogicalTypeAnnotation.timeType(org.apache.parquet.schema.LogicalTypeAnnotation.timeType) ByteArrayOutputStream(java.io.ByteArrayOutputStream) INT32(org.apache.parquet.format.Type.INT32) LogicalTypeAnnotation.timestampType(org.apache.parquet.schema.LogicalTypeAnnotation.timestampType) Repetition(org.apache.parquet.schema.Type.Repetition) ColumnIndexBuilder(org.apache.parquet.internal.column.columnindex.ColumnIndexBuilder) FileMetaData(org.apache.parquet.format.FileMetaData) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Assert.assertSame(org.junit.Assert.assertSame) Util(org.apache.parquet.format.Util) MILLIS(org.apache.parquet.schema.LogicalTypeAnnotation.TimeUnit.MILLIS) StringType(org.apache.parquet.format.StringType) Lists(com.google.common.collect.Lists) PrimitiveTypeName(org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName) PageType(org.apache.parquet.format.PageType) BinaryStatistics(org.apache.parquet.column.statistics.BinaryStatistics) MICROS(org.apache.parquet.schema.LogicalTypeAnnotation.TimeUnit.MICROS) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) FixedBinaryTestUtils(org.apache.parquet.FixedBinaryTestUtils) ExampleParquetWriter(org.apache.parquet.hadoop.example.ExampleParquetWriter) ColumnChunk(org.apache.parquet.format.ColumnChunk) LongStatistics(org.apache.parquet.column.statistics.LongStatistics) Assert.assertNull(org.junit.Assert.assertNull) LogicalTypeAnnotation.stringType(org.apache.parquet.schema.LogicalTypeAnnotation.stringType) ParquetMetadata(org.apache.parquet.hadoop.metadata.ParquetMetadata) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) NANOS(org.apache.parquet.schema.LogicalTypeAnnotation.TimeUnit.NANOS) PrimitiveType(org.apache.parquet.schema.PrimitiveType) ColumnIndex(org.apache.parquet.internal.column.columnindex.ColumnIndex) Random(java.util.Random) ByteBuffer(java.nio.ByteBuffer) OffsetIndex(org.apache.parquet.internal.column.columnindex.OffsetIndex) Paper(org.apache.parquet.example.Paper) ByteArrayInputStream(java.io.ByteArrayInputStream) BooleanStatistics(org.apache.parquet.column.statistics.BooleanStatistics) SchemaElement(org.apache.parquet.format.SchemaElement) Type(org.apache.parquet.format.Type) LogicalTypeAnnotation.listType(org.apache.parquet.schema.LogicalTypeAnnotation.listType) Path(org.apache.hadoop.fs.Path) Assert.fail(org.junit.Assert.fail) Types(org.apache.parquet.schema.Types) LogicalTypeAnnotation.mapType(org.apache.parquet.schema.LogicalTypeAnnotation.mapType) ParquetMetadataConverter.filterFileMetaDataByMidpoint(org.apache.parquet.format.converter.ParquetMetadataConverter.filterFileMetaDataByMidpoint) LogicalTypeAnnotation.uuidType(org.apache.parquet.schema.LogicalTypeAnnotation.uuidType) Collections.emptyList(java.util.Collections.emptyList) ColumnOrder(org.apache.parquet.schema.ColumnOrder) Util.readPageHeader(org.apache.parquet.format.Util.readPageHeader) Sets(com.google.common.collect.Sets) ColumnChunkMetaData(org.apache.parquet.hadoop.metadata.ColumnChunkMetaData) Binary(org.apache.parquet.io.api.Binary) ColumnMetaData(org.apache.parquet.format.ColumnMetaData) MessageType(org.apache.parquet.schema.MessageType) List(java.util.List) ParquetWriter(org.apache.parquet.hadoop.ParquetWriter) MapType(org.apache.parquet.format.MapType) RowGroup(org.apache.parquet.format.RowGroup) LogicalTypeAnnotation.intType(org.apache.parquet.schema.LogicalTypeAnnotation.intType) BoundaryOrder(org.apache.parquet.internal.column.columnindex.BoundaryOrder) ColumnPath(org.apache.parquet.hadoop.metadata.ColumnPath) Util.writePageHeader(org.apache.parquet.format.Util.writePageHeader) LogicalTypeAnnotation.jsonType(org.apache.parquet.schema.LogicalTypeAnnotation.jsonType) BytesUtils(org.apache.parquet.bytes.BytesUtils) IntStatistics(org.apache.parquet.column.statistics.IntStatistics) HashMap(java.util.HashMap) LogicalType(org.apache.parquet.format.LogicalType) LogicalTypeAnnotation(org.apache.parquet.schema.LogicalTypeAnnotation) UTF8(org.apache.hadoop.io.UTF8) HashSet(java.util.HashSet) Charset(java.nio.charset.Charset) DecimalType(org.apache.parquet.format.DecimalType) OriginalType(org.apache.parquet.schema.OriginalType) MessageTypeParser.parseMessageType(org.apache.parquet.schema.MessageTypeParser.parseMessageType) ParquetProperties(org.apache.parquet.column.ParquetProperties) FloatStatistics(org.apache.parquet.column.statistics.FloatStatistics) Statistics(org.apache.parquet.column.statistics.Statistics) Assert.assertNotNull(org.junit.Assert.assertNotNull) FieldRepetitionType(org.apache.parquet.format.FieldRepetitionType) Version(org.apache.parquet.Version) DoubleStatistics(org.apache.parquet.column.statistics.DoubleStatistics) Rule(org.junit.Rule) Collections(java.util.Collections) TemporaryFolder(org.junit.rules.TemporaryFolder) ParquetMetadata(org.apache.parquet.hadoop.metadata.ParquetMetadata) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FileMetaData(org.apache.parquet.format.FileMetaData) Test(org.junit.Test)

Example 63 with Assert.assertEquals

use of org.junit.Assert.assertEquals in project parquet-mr by apache.

the class TestParquetMetadataConverter method testParquetMetadataConverterWithDictionary.

@Test
public void testParquetMetadataConverterWithDictionary() throws IOException {
    ParquetMetadata parquetMetaData = createParquetMetaData(Encoding.PLAIN_DICTIONARY, Encoding.PLAIN);
    ParquetMetadataConverter converter = new ParquetMetadataConverter();
    FileMetaData fmd1 = converter.toParquetMetadata(1, parquetMetaData);
    // Flag should be true
    fmd1.row_groups.forEach(rowGroup -> rowGroup.columns.forEach(column -> {
        assertTrue(column.meta_data.isSetDictionary_page_offset());
    }));
    ByteArrayOutputStream metaDataOutputStream = new ByteArrayOutputStream();
    Util.writeFileMetaData(fmd1, metaDataOutputStream);
    ByteArrayInputStream metaDataInputStream = new ByteArrayInputStream(metaDataOutputStream.toByteArray());
    FileMetaData fmd2 = Util.readFileMetaData(metaDataInputStream);
    ParquetMetadata parquetMetaDataConverted = converter.fromParquetMetadata(fmd2);
    long dicOffsetOriginal = parquetMetaData.getBlocks().get(0).getColumns().get(0).getDictionaryPageOffset();
    long dicOffsetConverted = parquetMetaDataConverted.getBlocks().get(0).getColumns().get(0).getDictionaryPageOffset();
    Assert.assertEquals(dicOffsetOriginal, dicOffsetConverted);
}
Also used : Encoding(org.apache.parquet.column.Encoding) Arrays(java.util.Arrays) LogicalTypeAnnotation.decimalType(org.apache.parquet.schema.LogicalTypeAnnotation.decimalType) ConvertedType(org.apache.parquet.format.ConvertedType) Group(org.apache.parquet.example.data.Group) LogicalTypeAnnotation.dateType(org.apache.parquet.schema.LogicalTypeAnnotation.dateType) SecureRandom(java.security.SecureRandom) LogicalTypeAnnotation.enumType(org.apache.parquet.schema.LogicalTypeAnnotation.enumType) Configuration(org.apache.hadoop.conf.Configuration) BigInteger(java.math.BigInteger) GroupReadSupport(org.apache.parquet.hadoop.example.GroupReadSupport) OffsetIndexBuilder(org.apache.parquet.internal.column.columnindex.OffsetIndexBuilder) ParquetReader(org.apache.parquet.hadoop.ParquetReader) Set(java.util.Set) LogicalTypeAnnotation.bsonType(org.apache.parquet.schema.LogicalTypeAnnotation.bsonType) EncodingStats(org.apache.parquet.column.EncodingStats) ParquetMetadataConverter.filterFileMetaDataByStart(org.apache.parquet.format.converter.ParquetMetadataConverter.filterFileMetaDataByStart) Assert.assertFalse(org.junit.Assert.assertFalse) ColumnDescriptor(org.apache.parquet.column.ColumnDescriptor) BlockMetaData(org.apache.parquet.hadoop.metadata.BlockMetaData) PageHeader(org.apache.parquet.format.PageHeader) SimpleGroup(org.apache.parquet.example.data.simple.SimpleGroup) CompressionCodecName(org.apache.parquet.hadoop.metadata.CompressionCodecName) UNCOMPRESSED(org.apache.parquet.format.CompressionCodec.UNCOMPRESSED) ParquetMetadataConverter.getOffset(org.apache.parquet.format.converter.ParquetMetadataConverter.getOffset) LogicalTypeAnnotation.timeType(org.apache.parquet.schema.LogicalTypeAnnotation.timeType) ByteArrayOutputStream(java.io.ByteArrayOutputStream) INT32(org.apache.parquet.format.Type.INT32) LogicalTypeAnnotation.timestampType(org.apache.parquet.schema.LogicalTypeAnnotation.timestampType) Repetition(org.apache.parquet.schema.Type.Repetition) ColumnIndexBuilder(org.apache.parquet.internal.column.columnindex.ColumnIndexBuilder) FileMetaData(org.apache.parquet.format.FileMetaData) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Assert.assertSame(org.junit.Assert.assertSame) Util(org.apache.parquet.format.Util) MILLIS(org.apache.parquet.schema.LogicalTypeAnnotation.TimeUnit.MILLIS) StringType(org.apache.parquet.format.StringType) Lists(com.google.common.collect.Lists) PrimitiveTypeName(org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName) PageType(org.apache.parquet.format.PageType) BinaryStatistics(org.apache.parquet.column.statistics.BinaryStatistics) MICROS(org.apache.parquet.schema.LogicalTypeAnnotation.TimeUnit.MICROS) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) FixedBinaryTestUtils(org.apache.parquet.FixedBinaryTestUtils) ExampleParquetWriter(org.apache.parquet.hadoop.example.ExampleParquetWriter) ColumnChunk(org.apache.parquet.format.ColumnChunk) LongStatistics(org.apache.parquet.column.statistics.LongStatistics) Assert.assertNull(org.junit.Assert.assertNull) LogicalTypeAnnotation.stringType(org.apache.parquet.schema.LogicalTypeAnnotation.stringType) ParquetMetadata(org.apache.parquet.hadoop.metadata.ParquetMetadata) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) NANOS(org.apache.parquet.schema.LogicalTypeAnnotation.TimeUnit.NANOS) PrimitiveType(org.apache.parquet.schema.PrimitiveType) ColumnIndex(org.apache.parquet.internal.column.columnindex.ColumnIndex) Random(java.util.Random) ByteBuffer(java.nio.ByteBuffer) OffsetIndex(org.apache.parquet.internal.column.columnindex.OffsetIndex) Paper(org.apache.parquet.example.Paper) ByteArrayInputStream(java.io.ByteArrayInputStream) BooleanStatistics(org.apache.parquet.column.statistics.BooleanStatistics) SchemaElement(org.apache.parquet.format.SchemaElement) Type(org.apache.parquet.format.Type) LogicalTypeAnnotation.listType(org.apache.parquet.schema.LogicalTypeAnnotation.listType) Path(org.apache.hadoop.fs.Path) Assert.fail(org.junit.Assert.fail) Types(org.apache.parquet.schema.Types) LogicalTypeAnnotation.mapType(org.apache.parquet.schema.LogicalTypeAnnotation.mapType) ParquetMetadataConverter.filterFileMetaDataByMidpoint(org.apache.parquet.format.converter.ParquetMetadataConverter.filterFileMetaDataByMidpoint) LogicalTypeAnnotation.uuidType(org.apache.parquet.schema.LogicalTypeAnnotation.uuidType) Collections.emptyList(java.util.Collections.emptyList) ColumnOrder(org.apache.parquet.schema.ColumnOrder) Util.readPageHeader(org.apache.parquet.format.Util.readPageHeader) Sets(com.google.common.collect.Sets) ColumnChunkMetaData(org.apache.parquet.hadoop.metadata.ColumnChunkMetaData) Binary(org.apache.parquet.io.api.Binary) ColumnMetaData(org.apache.parquet.format.ColumnMetaData) MessageType(org.apache.parquet.schema.MessageType) List(java.util.List) ParquetWriter(org.apache.parquet.hadoop.ParquetWriter) MapType(org.apache.parquet.format.MapType) RowGroup(org.apache.parquet.format.RowGroup) LogicalTypeAnnotation.intType(org.apache.parquet.schema.LogicalTypeAnnotation.intType) BoundaryOrder(org.apache.parquet.internal.column.columnindex.BoundaryOrder) ColumnPath(org.apache.parquet.hadoop.metadata.ColumnPath) Util.writePageHeader(org.apache.parquet.format.Util.writePageHeader) LogicalTypeAnnotation.jsonType(org.apache.parquet.schema.LogicalTypeAnnotation.jsonType) BytesUtils(org.apache.parquet.bytes.BytesUtils) IntStatistics(org.apache.parquet.column.statistics.IntStatistics) HashMap(java.util.HashMap) LogicalType(org.apache.parquet.format.LogicalType) LogicalTypeAnnotation(org.apache.parquet.schema.LogicalTypeAnnotation) UTF8(org.apache.hadoop.io.UTF8) HashSet(java.util.HashSet) Charset(java.nio.charset.Charset) DecimalType(org.apache.parquet.format.DecimalType) OriginalType(org.apache.parquet.schema.OriginalType) MessageTypeParser.parseMessageType(org.apache.parquet.schema.MessageTypeParser.parseMessageType) ParquetProperties(org.apache.parquet.column.ParquetProperties) FloatStatistics(org.apache.parquet.column.statistics.FloatStatistics) Statistics(org.apache.parquet.column.statistics.Statistics) Assert.assertNotNull(org.junit.Assert.assertNotNull) FieldRepetitionType(org.apache.parquet.format.FieldRepetitionType) Version(org.apache.parquet.Version) DoubleStatistics(org.apache.parquet.column.statistics.DoubleStatistics) Rule(org.junit.Rule) Collections(java.util.Collections) TemporaryFolder(org.junit.rules.TemporaryFolder) ParquetMetadata(org.apache.parquet.hadoop.metadata.ParquetMetadata) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FileMetaData(org.apache.parquet.format.FileMetaData) Test(org.junit.Test)

Example 64 with Assert.assertEquals

use of org.junit.Assert.assertEquals in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedDisabledTest.

@Test
@Transactional
public void compileAttributesOverrloadedDisabledTest() {
    List<AttributeMapping> defaultAttributes = new ArrayList<>();
    List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
    initDataSystem();
    SysSchemaAttributeDto attOne = new SysSchemaAttributeDto();
    attOne.setName("attOne");
    attOne.setObjectClass(objectClasses.get(0).getId());
    attOne.setClassType(String.class.getName());
    attOne = schemaAttributeService.save(attOne);
    SysSchemaAttributeDto attTwo = new SysSchemaAttributeDto();
    attTwo.setName("attTwo");
    attTwo.setObjectClass(objectClasses.get(0).getId());
    attTwo.setClassType(String.class.getName());
    attTwo = schemaAttributeService.save(attTwo);
    SysSystemAttributeMappingDto defOne = new SysSystemAttributeMappingDto();
    defOne.setEntityAttribute(true);
    defOne.setIdmPropertyName("one");
    defOne.setName("defOne");
    defOne.setDisabledAttribute(true);
    defOne.setSchemaAttribute(attOne.getId());
    defOne.setSystemMapping(systemMapping.getId());
    defOne = systemAttributeMappingService.save(defOne);
    defaultAttributes.add(defOne);
    SysSystemAttributeMappingDto defTwo = new SysSystemAttributeMappingDto();
    defTwo.setEntityAttribute(true);
    defTwo.setIdmPropertyName("two");
    defTwo.setName("defTwo");
    defTwo.setSchemaAttribute(attTwo.getId());
    defTwo.setSystemMapping(systemMapping.getId());
    defTwo = systemAttributeMappingService.save(defTwo);
    defaultAttributes.add(defTwo);
    IdmRoleDto roleOne = new IdmRoleDto();
    roleOne.setCode("roleOne");
    roleOne.setPriority(100);
    roleOne = roleService.save(roleOne);
    SysRoleSystemDto roleSystem = new SysRoleSystemDto();
    roleSystem.setRole(roleOne.getId());
    roleSystem.setSystem(system.getId());
    roleSystem.setSystemMapping(systemMapping.getId());
    roleSystem = roleSystemService.save(roleSystem);
    SysRoleSystemAttributeDto overloadedOne = new SysRoleSystemAttributeDto();
    overloadedOne.setSystemAttributeMapping(defOne.getId());
    overloadedOne.setEntityAttribute(true);
    overloadedOne.setIdmPropertyName("one");
    overloadedOne.setName("defOneOverloaded");
    overloadedOne.setDisabledDefaultAttribute(false);
    overloadedOne.setRoleSystem(roleSystem.getId());
    overloadedOne = roleSystemAttributeService.save(overloadedOne);
    overloadingAttributes.add(overloadedOne);
    List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
    Assert.assertEquals(2, compilledAttributes.size());
    Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
        return "defOneOverloaded".equals(attribute.getName());
    }).findFirst().isPresent());
}
Also used : MethodSorters(org.junit.runners.MethodSorters) IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) AccIdentityAccount_(eu.bcvsolutions.idm.acc.entity.AccIdentityAccount_) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SysRoleSystemService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemService) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) After(org.junit.After) ProvisioningConfiguration(eu.bcvsolutions.idm.acc.config.domain.ProvisioningConfiguration) Assert.fail(org.junit.Assert.fail) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) AccountType(eu.bcvsolutions.idm.acc.domain.AccountType) AccIdentityAccountService(eu.bcvsolutions.idm.acc.service.api.AccIdentityAccountService) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) FixMethodOrder(org.junit.FixMethodOrder) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmTreeNodeService(eu.bcvsolutions.idm.core.api.service.IdmTreeNodeService) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) SystemEvent(eu.bcvsolutions.idm.acc.event.SystemEvent) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) SystemEventType(eu.bcvsolutions.idm.acc.event.SystemEvent.SystemEventType) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) IdmAccountDto(eu.bcvsolutions.idm.core.api.dto.IdmAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ArrayList(java.util.ArrayList) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) IdmPasswordPolicyGenerateType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyGenerateType) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) ImmutableList(com.google.common.collect.ImmutableList) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) ProvisioningOperationType(eu.bcvsolutions.idm.acc.domain.ProvisioningOperationType) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Before(org.junit.Before) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) SysRoleSystemAttributeService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService) SysProvisioningArchiveService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningArchiveService) IdmPasswordPolicyType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyType) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) Assert.assertNotNull(org.junit.Assert.assertNotNull) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) IdmTreeTypeService(eu.bcvsolutions.idm.core.api.service.IdmTreeTypeService) Test(org.junit.Test) EntityManager(javax.persistence.EntityManager) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) CoreEntityManager(eu.bcvsolutions.idm.core.api.config.datasource.CoreEntityManager) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) Assert.assertNull(org.junit.Assert.assertNull) AccAccount_(eu.bcvsolutions.idm.acc.entity.AccAccount_) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ProvisioningService(eu.bcvsolutions.idm.acc.service.api.ProvisioningService) IdmIdentity_(eu.bcvsolutions.idm.core.model.entity.IdmIdentity_) TestHelper(eu.bcvsolutions.idm.acc.TestHelper) Assert(org.junit.Assert) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) Assert.assertEquals(org.junit.Assert.assertEquals) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) Transactional(org.springframework.transaction.annotation.Transactional) IdmPasswordPolicyService(eu.bcvsolutions.idm.core.api.service.IdmPasswordPolicyService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) ArrayList(java.util.ArrayList) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 65 with Assert.assertEquals

use of org.junit.Assert.assertEquals in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningArchiveServiceIntegrationTest method differenceObjectMultipleTest.

@Test
public void differenceObjectMultipleTest() {
    String attrName = getHelper().createName();
    IcAttributeImpl icAttributeOne = new IcAttributeImpl(attrName, Lists.newArrayList("TESTExisting", "TESTRemoved"));
    IcConnectorObject connObjectOld = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of(icAttributeOne));
    IcAttributeImpl icAttributeTwo = new IcAttributeImpl(attrName, Lists.newArrayList("TESTExisting", "TESTNew"));
    IcConnectorObject connObjectNew = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of(icAttributeTwo));
    List<SysAttributeDifferenceDto> diffs = service.evaluateProvisioningDifferences(connObjectOld, connObjectNew);
    List<SysAttributeDifferenceValueDto> values = diffs.get(0).getValues();
    Assert.assertEquals(1, diffs.size());
    Assert.assertTrue(diffs.get(0).isMultivalue());
    Assert.assertTrue(diffs.get(0).isChanged());
    Assert.assertNotNull(values);
    Assert.assertEquals(3, values.size());
    SysAttributeDifferenceValueDto value;
    value = values.stream().filter(item -> item.getChange() == null).findFirst().orElse(null);
    Assert.assertNotNull(value);
    Assert.assertEquals("TESTExisting", value.getValue());
    Assert.assertEquals("TESTExisting", value.getOldValue());
    value = values.stream().filter(item -> item.getChange() == SysValueChangeType.ADDED).findFirst().orElse(null);
    Assert.assertNotNull(value);
    Assert.assertEquals("TESTNew", value.getValue());
    Assert.assertEquals(null, value.getOldValue());
    value = values.stream().filter(item -> item.getChange() == SysValueChangeType.REMOVED).findFirst().orElse(null);
    Assert.assertNotNull(value);
    Assert.assertEquals("TESTRemoved", value.getValue());
    Assert.assertEquals("TESTRemoved", value.getOldValue());
}
Also used : ProvisioningEventType(eu.bcvsolutions.idm.acc.domain.ProvisioningEventType) SysAttributeDifferenceValueDto(eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceValueDto) Autowired(org.springframework.beans.factory.annotation.Autowired) SysAttributeDifferenceDto(eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceDto) IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) ProvisioningContext(eu.bcvsolutions.idm.acc.domain.ProvisioningContext) SysProvisioningArchiveService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningArchiveService) SysProvisioningOperationService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningOperationService) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) Assert.assertTrue(org.junit.Assert.assertTrue) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) UUID(java.util.UUID) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) Page(org.springframework.data.domain.Page) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) SysProvisioningAttributeRepository(eu.bcvsolutions.idm.acc.repository.SysProvisioningAttributeRepository) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) Assert.assertFalse(org.junit.Assert.assertFalse) SysProvisioningAttribute(eu.bcvsolutions.idm.acc.entity.SysProvisioningAttribute) DefaultAccTestHelper(eu.bcvsolutions.idm.acc.DefaultAccTestHelper) SysValueChangeType(eu.bcvsolutions.idm.acc.domain.SysValueChangeType) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) Transactional(org.springframework.transaction.annotation.Transactional) IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcAttributeImpl) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysAttributeDifferenceDto(eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceDto) IcConnectorObjectImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl) SysAttributeDifferenceValueDto(eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceValueDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

Assert.assertEquals (org.junit.Assert.assertEquals)282 Assert (org.junit.Assert)277 Test (org.junit.Test)276 List (java.util.List)233 Assert.assertTrue (org.junit.Assert.assertTrue)191 Before (org.junit.Before)166 ArrayList (java.util.ArrayList)134 Assert.assertNotNull (org.junit.Assert.assertNotNull)133 Map (java.util.Map)121 Assert.assertFalse (org.junit.Assert.assertFalse)116 Arrays (java.util.Arrays)113 UUID (java.util.UUID)108 Autowired (org.springframework.beans.factory.annotation.Autowired)105 Collections (java.util.Collections)102 After (org.junit.After)99 HashMap (java.util.HashMap)96 Assert.assertNull (org.junit.Assert.assertNull)94 Collectors (java.util.stream.Collectors)93 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)91 IOException (java.io.IOException)85