Search in sources :

Example 21 with Theme

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);
}
Also used : Theme(io.gravitee.repository.management.model.Theme) InlinePictureEntity(io.gravitee.rest.api.model.InlinePictureEntity) PictureEntity(io.gravitee.rest.api.model.PictureEntity) UrlPictureEntity(io.gravitee.rest.api.model.UrlPictureEntity) InlinePictureEntity(io.gravitee.rest.api.model.InlinePictureEntity) Test(org.junit.Test)

Example 22 with Theme

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());
}
Also used : Theme(io.gravitee.repository.management.model.Theme) Test(org.junit.Test)

Example 23 with Theme

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);
}
Also used : Theme(io.gravitee.repository.management.model.Theme) Test(org.junit.Test)

Example 24 with Theme

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));
}
Also used : Theme(io.gravitee.repository.management.model.Theme) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Theme (io.gravitee.repository.management.model.Theme)24 Test (org.junit.Test)17 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)10 Date (java.util.Date)10 InlinePictureEntity (io.gravitee.rest.api.model.InlinePictureEntity)8 PictureEntity (io.gravitee.rest.api.model.PictureEntity)8 UrlPictureEntity (io.gravitee.rest.api.model.UrlPictureEntity)8 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)7 DuplicateThemeNameException (io.gravitee.rest.api.service.exceptions.DuplicateThemeNameException)7 ThemeDefinitionMapper (io.gravitee.rest.api.service.impl.ThemeServiceImpl.ThemeDefinitionMapper)7 TechnicalManagementException (io.gravitee.rest.api.service.exceptions.TechnicalManagementException)6 ThemeNotFoundException (io.gravitee.rest.api.service.exceptions.ThemeNotFoundException)6 IOException (java.io.IOException)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 ThemeRepository (io.gravitee.repository.management.api.ThemeRepository)5 THEME (io.gravitee.repository.management.model.Audit.AuditProperties.THEME)5 io.gravitee.rest.api.model.theme (io.gravitee.rest.api.model.theme)5 GraviteeContext (io.gravitee.rest.api.service.common.GraviteeContext)5 HashSet (java.util.HashSet)5 ImmutableMap (com.google.common.collect.ImmutableMap)4