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());
}
Aggregations