Search in sources :

Example 6 with ProjectEntity

use of net.nemerosa.ontrack.model.structure.ProjectEntity in project ontrack by nemerosa.

the class DecorationServiceImplTest method error_decoration_generates_default_error_decoration.

@Test
public void error_decoration_generates_default_error_decoration() {
    ProjectEntity projectEntity = mock(ProjectEntity.class);
    DecorationExtension decorator = mock(DecorationExtension.class);
    when(decorator.getDecorations(any(ProjectEntity.class))).thenThrow(new RuntimeException("Error while generating the decoration"));
    ExtensionManager extensionManager = mock(ExtensionManager.class);
    when(extensionManager.getExtensions(DecorationExtension.class)).thenReturn(Collections.singletonList(decorator));
    SecurityService securityService = mock(SecurityService.class);
    DecorationServiceImpl service = new DecorationServiceImpl(extensionManager, securityService);
    @SuppressWarnings("unchecked") List<? extends Decoration> decorations = service.getDecorations(projectEntity, decorator);
    assertNotNull(decorations);
    assertEquals(1, decorations.size());
    Decoration decoration = decorations.get(0);
    assertNull(decoration.getData());
    assertEquals("Problem while getting decoration", decoration.getError());
}
Also used : ProjectEntity(net.nemerosa.ontrack.model.structure.ProjectEntity) ExtensionManager(net.nemerosa.ontrack.extension.api.ExtensionManager) SecurityService(net.nemerosa.ontrack.model.security.SecurityService) DecorationExtension(net.nemerosa.ontrack.extension.api.DecorationExtension) Decoration(net.nemerosa.ontrack.model.structure.Decoration) Test(org.junit.Test)

Aggregations

ProjectEntity (net.nemerosa.ontrack.model.structure.ProjectEntity)6 ExtensionManager (net.nemerosa.ontrack.extension.api.ExtensionManager)3 ProjectEntityType (net.nemerosa.ontrack.model.structure.ProjectEntityType)3 DecorationExtension (net.nemerosa.ontrack.extension.api.DecorationExtension)2 SecurityService (net.nemerosa.ontrack.model.security.SecurityService)2 Decoration (net.nemerosa.ontrack.model.structure.Decoration)2 Test (org.junit.Test)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 EntityInformationExtension (net.nemerosa.ontrack.extension.api.EntityInformationExtension)1 ProjectEntityActionExtension (net.nemerosa.ontrack.extension.api.ProjectEntityActionExtension)1 EntityInformation (net.nemerosa.ontrack.extension.api.model.EntityInformation)1 Event (net.nemerosa.ontrack.model.events.Event)1 ID (net.nemerosa.ontrack.model.structure.ID)1 Signature (net.nemerosa.ontrack.model.structure.Signature)1 StructureService (net.nemerosa.ontrack.model.structure.StructureService)1