use of io.gravitee.repository.management.model.Audit.AuditProperties.QUALITY_RULE in project gravitee-management-rest-api by gravitee-io.
the class QualityRuleServiceTest method shouldCreate.
@Test
public void shouldCreate() throws TechnicalException {
final NewQualityRuleEntity newQualityRuleEntity = new NewQualityRuleEntity();
newQualityRuleEntity.setName("NAME");
newQualityRuleEntity.setDescription("DESC");
newQualityRuleEntity.setWeight(1);
final QualityRule createdQualityRule = new QualityRule();
createdQualityRule.setId(QUALITY_RULE_ID);
createdQualityRule.setName("NAME");
createdQualityRule.setDescription("DESC");
createdQualityRule.setWeight(1);
createdQualityRule.setCreatedAt(new Date());
createdQualityRule.setUpdatedAt(new Date());
when(qualityRuleRepository.create(any())).thenReturn(createdQualityRule);
final QualityRuleEntity qualityRuleEntity = qualityRuleService.create(newQualityRuleEntity);
assertNotNull(qualityRuleEntity.getId());
assertEquals("NAME", qualityRuleEntity.getName());
assertEquals("DESC", qualityRuleEntity.getDescription());
assertEquals(1, qualityRuleEntity.getWeight());
assertNotNull(qualityRuleEntity.getCreatedAt());
assertNotNull(qualityRuleEntity.getUpdatedAt());
final QualityRule qualityRule = new QualityRule();
qualityRule.setName("NAME");
qualityRule.setDescription("DESC");
qualityRule.setWeight(1);
verify(qualityRuleRepository, times(1)).create(argThat(argument -> "NAME".equals(argument.getName()) && "DESC".equals(argument.getDescription()) && Integer.valueOf(1).equals(argument.getWeight()) && !argument.getId().isEmpty() && argument.getCreatedAt() != null && argument.getUpdatedAt() != null));
verify(auditService, times(1)).createEnvironmentAuditLog(eq(ImmutableMap.of(QUALITY_RULE, QUALITY_RULE_ID)), eq(QualityRule.AuditEvent.QUALITY_RULE_CREATED), any(Date.class), isNull(), any());
}
use of io.gravitee.repository.management.model.Audit.AuditProperties.QUALITY_RULE in project gravitee-management-rest-api by gravitee-io.
the class QualityRuleServiceTest method shouldUpdate.
@Test
public void shouldUpdate() throws TechnicalException {
final UpdateQualityRuleEntity updateQualityRuleEntity = new UpdateQualityRuleEntity();
updateQualityRuleEntity.setId(QUALITY_RULE_ID);
updateQualityRuleEntity.setName("NAME");
updateQualityRuleEntity.setDescription("DESC");
updateQualityRuleEntity.setWeight(1);
final QualityRule updatedQualityRule = new QualityRule();
updatedQualityRule.setId(QUALITY_RULE_ID);
updatedQualityRule.setName("NAME");
updatedQualityRule.setDescription("DESC");
updatedQualityRule.setWeight(1);
updatedQualityRule.setCreatedAt(new Date());
updatedQualityRule.setUpdatedAt(new Date());
when(qualityRuleRepository.update(any())).thenReturn(updatedQualityRule);
when(qualityRuleRepository.findById(QUALITY_RULE_ID)).thenReturn(of(updatedQualityRule));
final QualityRuleEntity qualityRuleEntity = qualityRuleService.update(updateQualityRuleEntity);
assertNotNull(qualityRuleEntity.getId());
assertEquals("NAME", qualityRuleEntity.getName());
assertEquals("DESC", qualityRuleEntity.getDescription());
assertEquals(1, qualityRuleEntity.getWeight());
assertNotNull(qualityRuleEntity.getCreatedAt());
assertNotNull(qualityRuleEntity.getUpdatedAt());
final QualityRule qualityRule = new QualityRule();
qualityRule.setName("NAME");
qualityRule.setDescription("DESC");
qualityRule.setWeight(1);
verify(qualityRuleRepository, times(1)).update(argThat(argument -> "NAME".equals(argument.getName()) && "DESC".equals(argument.getDescription()) && Integer.valueOf(1).equals(argument.getWeight()) && QUALITY_RULE_ID.equals(argument.getId()) && argument.getCreatedAt() != null && argument.getUpdatedAt() != null));
verify(auditService, times(1)).createEnvironmentAuditLog(eq(ImmutableMap.of(QUALITY_RULE, QUALITY_RULE_ID)), eq(QualityRule.AuditEvent.QUALITY_RULE_UPDATED), any(Date.class), any(), any());
}
Aggregations