Search in sources :

Example 6 with DescriptorFieldRelation

use of com.synopsys.integration.alert.database.configuration.DescriptorFieldRelation in project hub-alert by blackducksoftware.

the class DefinedFieldRepositoryTestIT method onDeleteCascadeTest.

@Test
public void onDeleteCascadeTest() {
    final String descriptorName = "test descriptor";
    RegisteredDescriptorEntity registeredDescriptorEntity = new RegisteredDescriptorEntity(descriptorName, 1L);
    RegisteredDescriptorEntity savedRegisteredDescriptorEntity = registeredDescriptorRepository.save(registeredDescriptorEntity);
    assertEquals(1, registeredDescriptorRepository.findAll().size());
    DefinedFieldEntity definedFieldEntity = new DefinedFieldEntity(FIELD_KEY_1, Boolean.FALSE);
    DefinedFieldEntity savedDefinedFieldEntity = definedFieldRepository.save(definedFieldEntity);
    assertEquals(1, definedFieldRepository.findAll().size());
    DescriptorFieldRelation descriptorFieldRelation = new DescriptorFieldRelation(savedRegisteredDescriptorEntity.getId(), savedDefinedFieldEntity.getId());
    descriptorFieldRepository.save(descriptorFieldRelation);
    assertEquals(1, descriptorFieldRepository.findAll().size());
    definedFieldRepository.deleteById(savedDefinedFieldEntity.getId());
    definedFieldRepository.flush();
    assertEquals(0, descriptorFieldRepository.findAll().size());
}
Also used : DescriptorFieldRelation(com.synopsys.integration.alert.database.configuration.DescriptorFieldRelation) RegisteredDescriptorEntity(com.synopsys.integration.alert.database.configuration.RegisteredDescriptorEntity) DefinedFieldEntity(com.synopsys.integration.alert.database.configuration.DefinedFieldEntity) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

DefinedFieldEntity (com.synopsys.integration.alert.database.configuration.DefinedFieldEntity)6 DescriptorFieldRelation (com.synopsys.integration.alert.database.configuration.DescriptorFieldRelation)6 RegisteredDescriptorEntity (com.synopsys.integration.alert.database.configuration.RegisteredDescriptorEntity)5 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)5 Test (org.junit.jupiter.api.Test)5 ConfigContextEntity (com.synopsys.integration.alert.database.configuration.ConfigContextEntity)3 DescriptorConfigEntity (com.synopsys.integration.alert.database.configuration.DescriptorConfigEntity)2 FieldValueEntity (com.synopsys.integration.alert.database.configuration.FieldValueEntity)2 OffsetDateTime (java.time.OffsetDateTime)2 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)1 FieldContextRelation (com.synopsys.integration.alert.database.configuration.FieldContextRelation)1