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());
}
Aggregations