use of io.gravitee.repository.management.model.Theme in project gravitee-management-rest-api by gravitee-io.
the class ThemeServiceTest method shouldGetLogo.
@Test
public void shouldGetLogo() throws TechnicalException {
final Theme theme = mock(Theme.class, withSettings().lenient());
Mockito.lenient().when(theme.getReferenceType()).thenReturn(ENVIRONMENT.name());
when(theme.getReferenceId()).thenReturn("DEFAULT");
when(theme.getLogo()).thenReturn(themeServiceImpl.getDefaultLogo());
PictureEntity logo = themeService.getLogo(THEME_ID);
assertNotNull(logo);
assertTrue(logo instanceof InlinePictureEntity);
}
use of io.gravitee.repository.management.model.Theme in project gravitee-management-rest-api by gravitee-io.
the class ThemeServiceTest method shouldNotUpdate.
@Test
public void shouldNotUpdate() throws TechnicalException {
final UpdateThemeEntity updateThemeEntity = new UpdateThemeEntity();
updateThemeEntity.setId(THEME_ID);
when(themeRepository.findById(THEME_ID)).thenReturn(empty());
final Theme theme = mock(Theme.class);
when(theme.getId()).thenReturn(THEME_ID);
when(theme.getName()).thenReturn("NAME");
when(theme.getDefinition()).thenReturn(themeServiceImpl.getDefaultDefinition());
when(themeRepository.create(any())).thenReturn(theme);
themeService.update(updateThemeEntity);
verify(themeRepository).create(any());
}
use of io.gravitee.repository.management.model.Theme in project gravitee-management-rest-api by gravitee-io.
the class ThemeServiceTest method shouldThrowDuplicateThemeNameExceptionOnCreate.
@Test(expected = DuplicateThemeNameException.class)
public void shouldThrowDuplicateThemeNameExceptionOnCreate() throws TechnicalException {
final Theme theme = mock(Theme.class);
when(theme.getId()).thenReturn(THEME_ID);
when(theme.getName()).thenReturn("NAME");
when(theme.getDefinition()).thenReturn(themeServiceImpl.getDefaultDefinition());
when(themeRepository.findByReferenceIdAndReferenceType(GraviteeContext.getCurrentEnvironment(), ENVIRONMENT.name())).thenReturn(singleton(theme));
final NewThemeEntity newThemeEntity = new NewThemeEntity();
newThemeEntity.setName("NAME");
themeService.create(newThemeEntity);
}
use of io.gravitee.repository.management.model.Theme in project gravitee-management-rest-api by gravitee-io.
the class ThemeServiceTest method shouldDelete.
@Test
public void shouldDelete() throws TechnicalException {
final Theme theme = mock(Theme.class);
when(themeRepository.findById(THEME_ID)).thenReturn(of(theme));
themeService.delete(THEME_ID);
verify(themeRepository, times(1)).delete(THEME_ID);
verify(auditService, times(1)).createEnvironmentAuditLog(eq(ImmutableMap.of(THEME, THEME_ID)), eq(Theme.AuditEvent.THEME_DELETED), any(Date.class), isNull(), eq(theme));
}
Aggregations