Search in sources :

Example 11 with QualityRule

use of io.gravitee.repository.management.model.QualityRule in project gravitee-management-rest-api by gravitee-io.

the class QualityRuleServiceTest method shouldNotFindById.

@Test(expected = QualityRuleNotFoundException.class)
public void shouldNotFindById() throws TechnicalException {
    final QualityRule qualityRule = mock(QualityRule.class);
    when(qualityRuleRepository.findById(QUALITY_RULE_ID)).thenReturn(empty());
    qualityRuleService.findById(QUALITY_RULE_ID);
}
Also used : QualityRule(io.gravitee.repository.management.model.QualityRule) Test(org.junit.Test)

Example 12 with QualityRule

use of io.gravitee.repository.management.model.QualityRule in project gravitee-management-rest-api by gravitee-io.

the class QualityRuleServiceTest method shouldFindById.

@Test
public void shouldFindById() throws TechnicalException {
    final QualityRule qualityRule = mock(QualityRule.class);
    when(qualityRule.getId()).thenReturn(QUALITY_RULE_ID);
    when(qualityRule.getName()).thenReturn("NAME");
    when(qualityRule.getDescription()).thenReturn("DESC");
    when(qualityRule.getWeight()).thenReturn(1);
    when(qualityRule.getCreatedAt()).thenReturn(new Date(1));
    when(qualityRule.getUpdatedAt()).thenReturn(new Date(2));
    when(qualityRuleRepository.findById(QUALITY_RULE_ID)).thenReturn(of(qualityRule));
    final QualityRuleEntity qualityRuleEntity = qualityRuleService.findById(QUALITY_RULE_ID);
    assertEquals(QUALITY_RULE_ID, qualityRuleEntity.getId());
    assertEquals("NAME", qualityRuleEntity.getName());
    assertEquals("DESC", qualityRuleEntity.getDescription());
    assertEquals(1, qualityRuleEntity.getWeight());
    assertEquals(new Date(1), qualityRuleEntity.getCreatedAt());
    assertEquals(new Date(2), qualityRuleEntity.getUpdatedAt());
}
Also used : QualityRule(io.gravitee.repository.management.model.QualityRule) Date(java.util.Date) Test(org.junit.Test)

Aggregations

QualityRule (io.gravitee.repository.management.model.QualityRule)12 Date (java.util.Date)8 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)6 Test (org.junit.Test)6 QualityRuleNotFoundException (io.gravitee.rest.api.service.exceptions.QualityRuleNotFoundException)4 TechnicalManagementException (io.gravitee.rest.api.service.exceptions.TechnicalManagementException)4 ImmutableMap (com.google.common.collect.ImmutableMap)2 ApiQualityRuleRepository (io.gravitee.repository.management.api.ApiQualityRuleRepository)2 QualityRuleRepository (io.gravitee.repository.management.api.QualityRuleRepository)2 QUALITY_RULE (io.gravitee.repository.management.model.Audit.AuditProperties.QUALITY_RULE)2 io.gravitee.rest.api.model.quality (io.gravitee.rest.api.model.quality)2 QualityRuleServiceImpl (io.gravitee.rest.api.service.impl.QualityRuleServiceImpl)2 Collections.singleton (java.util.Collections.singleton)2 List (java.util.List)2 Optional.empty (java.util.Optional.empty)2 Optional.of (java.util.Optional.of)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertNotNull (org.junit.Assert.assertNotNull)2 RunWith (org.junit.runner.RunWith)2 InjectMocks (org.mockito.InjectMocks)2