use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.di.JSIStyle in project kie-wb-common by kiegroup.
the class StunnerConverterTest method testDecision.
@Test
public void testDecision() {
final StylingSet decisionStylingSet = mock(StylingSet.class);
final Decision decision = spy(new Decision());
when(decision.getStylingSet()).thenReturn(decisionStylingSet);
final JSITDecision jsitDecision = mock(JSITDecision.class);
when(jsitDecision.getTYPE_NAME()).thenReturn(JSITDecision.TYPE);
final JSIStyle style = mock(JSIStyle.class);
final JSIDMNShape shape = mock(JSIDMNShape.class);
final JSIDMNStyle dmnStyleOfDrgShape = mock(JSIDMNStyle.class);
when(shape.getStyle()).thenReturn(style);
doReturn(style).when(converter).getUnwrappedJSIStyle(style);
doReturn(true).when(converter).isJSIDMNStyle(style);
doReturn(dmnStyleOfDrgShape).when(converter).getJSIDmnStyle(style);
final NodeEntry nodeEntry = mock(NodeEntry.class);
when(nodeEntry.getDmnElement()).thenReturn(jsitDecision);
when(nodeEntry.getId()).thenReturn("_id");
when(nodeEntry.getDmnShape()).thenReturn(shape);
final Element graphElement = mock(Element.class);
final Node graphNode = mock(Node.class);
final View content = mock(View.class);
when(factoryManager.newElement(anyString(), anyString())).thenReturn(graphElement);
when(graphElement.asNode()).thenReturn(graphNode);
when(graphNode.getContent()).thenReturn(content);
when(content.getDefinition()).thenReturn(decision);
final JSIColor randomColor = mock(JSIColor.class);
when(randomColor.getRed()).thenReturn(12);
when(randomColor.getGreen()).thenReturn(34);
when(randomColor.getBlue()).thenReturn(56);
when(dmnStyleOfDrgShape.getFontColor()).thenReturn(randomColor);
when(dmnStyleOfDrgShape.getStrokeColor()).thenReturn(randomColor);
when(dmnStyleOfDrgShape.getFillColor()).thenReturn(randomColor);
when(dmnStyleOfDrgShape.getFontSize()).thenReturn(11d);
converter.make(nodeEntry);
verify(decisionStylingSet).setFontSize(fontSizeArgumentCaptor.capture());
Assertions.assertThat(fontSizeArgumentCaptor.getValue().getValue()).isEqualTo(11d);
verify(decisionStylingSet).setBorderColour(borderColourArgumentCaptor.capture());
Assertions.assertThat(borderColourArgumentCaptor.getValue().getValue()).isEqualTo("#0c2238");
verify(decisionStylingSet).setBgColour(bgColourArgumentCaptor.capture());
Assertions.assertThat(bgColourArgumentCaptor.getValue().getValue()).isEqualTo("#0c2238");
verify(decisionStylingSet).setFontColour(fontColourArgumentCaptor.capture());
Assertions.assertThat(fontColourArgumentCaptor.getValue().getValue()).isEqualTo("#0c2238");
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.di.JSIStyle in project kie-wb-common by kiegroup.
the class StunnerConverter method internalAugmentStyles.
private void internalAugmentStyles(final JSIDMNShape drgShape, final StylingSet stylingSet) {
final JSIStyle jsiStyle = drgShape.getStyle();
if (Objects.isNull(jsiStyle)) {
return;
}
final JSIStyle drgStyle = getUnwrappedJSIStyle(jsiStyle);
final JSIDMNStyle dmnStyleOfDrgShape = isJSIDMNStyle(drgStyle) ? getJSIDmnStyle(drgStyle) : null;
if (Objects.nonNull(dmnStyleOfDrgShape)) {
if (Objects.nonNull(dmnStyleOfDrgShape.getFillColor())) {
stylingSet.setBgColour(new BgColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getFillColor())));
}
if (Objects.nonNull(dmnStyleOfDrgShape.getStrokeColor())) {
stylingSet.setBorderColour(new BorderColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getStrokeColor())));
}
}
final StylingSet fontStylingSet = new StylingSet();
if (Objects.nonNull(dmnStyleOfDrgShape)) {
mergeFontStylingSet(fontStylingSet, FontStylingSetPropertyConverter.wbFromDMN(dmnStyleOfDrgShape));
}
if (Objects.nonNull(drgShape.getDMNLabel())) {
final JSIDMNShape jsiLabel = Js.uncheckedCast(drgShape.getDMNLabel());
final JSIStyle jsiLabelStyle = jsiLabel.getStyle();
final Object jsiLabelSharedStyle = Js.uncheckedCast(jsiLabel.getSharedStyle());
if (Objects.nonNull(jsiLabelSharedStyle) && JSIDMNStyle.instanceOf(jsiLabelSharedStyle)) {
mergeFontStylingSet(fontStylingSet, FontStylingSetPropertyConverter.wbFromDMN((Js.uncheckedCast(jsiLabelSharedStyle))));
}
if (Objects.nonNull(jsiLabelStyle) && isJSIDMNStyle(jsiLabelStyle)) {
mergeFontStylingSet(fontStylingSet, FontStylingSetPropertyConverter.wbFromDMN(Js.uncheckedCast(jsiLabelStyle)));
}
}
mergeFontStylingSet(stylingSet, fontStylingSet);
}
Aggregations