method2testcases
stringlengths 118
6.63k
|
---|
### Question:
VariableSearchService implements LiveSearchService<String> { public String getOptionType(String key) { return optionType.get(key); } @Inject VariableSearchService(final ConditionEditorMetadataService metadataService,
final ClientTranslationService translationService); void init(ClientSession session); @Override void search(String pattern, int maxResults, LiveSearchCallback<String> callback); @Override void searchEntry(String key, LiveSearchCallback<String> callback); String getOptionType(String key); void clear(); }### Answer:
@Test public void testGetOptionTypeWithResults() { prepareAndInitSession(); List<Pair<String, String>> checkedVariables = buildExpectedVariableNames(MULTIPLE_INSTANCE_SUBPROCESS, 17); checkedVariables.forEach(variable -> assertEquals("Option type wasn't properly calculated for variable: " + variable, mockedVariableTypes.get(variable.getK1()), searchService.getOptionType(variable.getK1()))); }
@Test public void testGetOptionTypeWithoutResults() { prepareAndInitSession(); prepareAndInitSession(); List<String> checkedVariables = Arrays.asList("not-existing1", "not-existing2", "not-existing3", "and_so_on"); checkedVariables.forEach(checkedVariable -> { String type = searchService.getOptionType(checkedVariable); assertNotEquals(mockedVariableTypes, type); }); } |
### Question:
VariableSearchService implements LiveSearchService<String> { static String unboxDefaultType(String type) { if (type == null) { return null; } switch (type) { case "Short": case "short": return Short.class.getName(); case "Integer": case "int": return Integer.class.getName(); case "Long": case "long": return Long.class.getName(); case "Float": case "float": return Float.class.getName(); case "Double": case "double": return Double.class.getName(); case "Boolean": case "boolean": return Boolean.class.getName(); case "Character": case "char": return Character.class.getName(); case "String": return String.class.getName(); case "Object": return Object.class.getName(); default: return type; } } @Inject VariableSearchService(final ConditionEditorMetadataService metadataService,
final ClientTranslationService translationService); void init(ClientSession session); @Override void search(String pattern, int maxResults, LiveSearchCallback<String> callback); @Override void searchEntry(String key, LiveSearchCallback<String> callback); String getOptionType(String key); void clear(); }### Answer:
@Test public void testUnboxDefaultTypes() { assertEquals(Short.class.getName(), unboxDefaultType("short")); assertEquals(Short.class.getName(), unboxDefaultType("Short")); assertEquals(Integer.class.getName(), unboxDefaultType("int")); assertEquals(Integer.class.getName(), unboxDefaultType("Integer")); assertEquals(Long.class.getName(), unboxDefaultType("long")); assertEquals(Long.class.getName(), unboxDefaultType("Long")); assertEquals(Float.class.getName(), unboxDefaultType("float")); assertEquals(Float.class.getName(), unboxDefaultType("Float")); assertEquals(Double.class.getName(), unboxDefaultType("double")); assertEquals(Double.class.getName(), unboxDefaultType("Double")); assertEquals(Character.class.getName(), unboxDefaultType("char")); assertEquals(Character.class.getName(), unboxDefaultType("Character")); assertEquals(String.class.getName(), unboxDefaultType("String")); assertEquals(Object.class.getName(), unboxDefaultType("Object")); assertEquals("Other_value", unboxDefaultType("Other_value")); assertEquals(null, unboxDefaultType(null)); } |
### Question:
VariableSearchService implements LiveSearchService<String> { public void clear() { options.clear(); typesMetadata.clear(); optionType.clear(); } @Inject VariableSearchService(final ConditionEditorMetadataService metadataService,
final ClientTranslationService translationService); void init(ClientSession session); @Override void search(String pattern, int maxResults, LiveSearchCallback<String> callback); @Override void searchEntry(String key, LiveSearchCallback<String> callback); String getOptionType(String key); void clear(); }### Answer:
@Test @SuppressWarnings("unchecked") public void testClear() { prepareAndInitSession(); List<Pair<String, String>> expectedVariables = buildExpectedVariableNames(MULTIPLE_INSTANCE_SUBPROCESS, 17); for (int i = 0; i < expectedVariables.size(); i++) { searchService.searchEntry(expectedVariables.get(i).getK1(), searchCallback); verify(searchCallback, times(i + 1)).afterSearch(searchResultsCaptor.capture()); verifyContains(searchResultsCaptor.getValue(), expectedVariables.get(i)); assertEquals(mockedVariableTypes.get(expectedVariables.get(i).getK1()), searchService.getOptionType(expectedVariables.get(i).getK1())); } searchService.clear(); int testedSize = expectedVariables.size(); for (int i = 0; i < expectedVariables.size(); i++) { searchService.searchEntry(expectedVariables.get(i).getK1(), searchCallback); verify(searchCallback, times(i + 1 + testedSize)).afterSearch(searchResultsCaptor.capture()); assertEquals(0, searchResultsCaptor.getValue().size()); assertNull(searchService.getOptionType(expectedVariables.get(i).getK1())); } } |
### Question:
ConditionEditorFieldEditorPresenter extends FieldEditorPresenter<ScriptTypeValue> { @PostConstruct public void init() { view.init(this); scriptEditor.setMode(ScriptTypeMode.FLOW_CONDITION); scriptEditor.addChangeHandler(this::onScriptChange); simpleConditionEditor.addChangeHandler(this::onSimpleConditionChange); if (!isServiceAvailable()) { showSimpleConditionEditor(); } else { showScriptEditor(); } } @Inject ConditionEditorFieldEditorPresenter(final View view,
final SimpleConditionEditorPresenter simpleConditionEditor,
final ScriptTypeFieldEditorPresenter scriptEditor,
final ErrorPopupPresenter errorPopup,
final ConditionEditorParsingService conditionEditorParsingService,
final ConditionEditorGeneratorService conditionEditorGeneratorService,
final ClientTranslationService translationService); boolean isServiceAvailable(); @PostConstruct void init(); void init(ClientSession session); @Override void setReadOnly(boolean readOnly); @Override void setValue(ScriptTypeValue value); }### Answer:
@Test public void testInit() { presenter.init(); verify(view).init(presenter); verify(scriptEditor).setMode(ScriptTypeMode.FLOW_CONDITION); verify(scriptEditor).addChangeHandler(any()); verify(simpleConditionEditor).addChangeHandler(any()); verifyShowSimpleConditionEditor(); assertEquals(view, presenter.getView()); }
@Test public void testInitSession() { presenter.init(session); verify(simpleConditionEditor).init(session); }
@Test public void testOnSingleSelection() { when(conditionEditorGeneratorService.isAvailable()).thenReturn(true); presenter = spy(new ConditionEditorFieldEditorPresenter(view, simpleConditionEditor, scriptEditor, errorPopup, conditionEditorParsingService, conditionEditorGeneratorService, translationService)); presenter.init(); verify(view, times(1)).setSingleOptionSelection(); }
@Test public void testNotOnSingleSelection() { when(conditionEditorGeneratorService.isAvailable()).thenReturn(false); presenter = spy(new ConditionEditorFieldEditorPresenter(view, simpleConditionEditor, scriptEditor, errorPopup, conditionEditorParsingService, conditionEditorGeneratorService, translationService)); presenter.init(); verify(view, never()).setSingleOptionSelection(); } |
### Question:
ConditionEditorFieldEditorPresenter extends FieldEditorPresenter<ScriptTypeValue> { @Override public void setValue(ScriptTypeValue value) { super.setValue(value); scriptEditor.setValue(value); simpleConditionEditor.clear(); clearError(); if (value != null) { if (isInDefaultLanguage(value) && !isServiceAvailable()) { if (!isEmpty(value.getScript())) { conditionEditorParsingService .call(value.getScript()) .then(result -> { onSetValue(result); return null; }) .catch_(throwable -> { onSetValueError((Throwable) throwable); return null; }); } else { showSimpleConditionEditor(); } } else { showScriptEditor(); } } else { simpleConditionEditor.setValue(null); showSimpleConditionEditor(); } } @Inject ConditionEditorFieldEditorPresenter(final View view,
final SimpleConditionEditorPresenter simpleConditionEditor,
final ScriptTypeFieldEditorPresenter scriptEditor,
final ErrorPopupPresenter errorPopup,
final ConditionEditorParsingService conditionEditorParsingService,
final ConditionEditorGeneratorService conditionEditorGeneratorService,
final ClientTranslationService translationService); boolean isServiceAvailable(); @PostConstruct void init(); void init(ClientSession session); @Override void setReadOnly(boolean readOnly); @Override void setValue(ScriptTypeValue value); }### Answer:
@Test public void testSetValueNull() { presenter.setValue(null); verifySetValueCommonActions(null); verify(simpleConditionEditor).setValue(null); verifyShowSimpleConditionEditor(); }
@Test public void testSetValueWithScriptNonInJava() { ScriptTypeValue value = new ScriptTypeValue("javascript", SCRIPT_VALUE); presenter.setValue(value); verifySetValueCommonActions(value); verifyShowScriptEditor(); }
@Test public void testSetValueWithScriptInJavaEmpty() { ScriptTypeValue value = new ScriptTypeValue("java", ""); presenter.setValue(value); verifySetValueCommonActions(value); verifyShowSimpleConditionEditor(); }
@Test public void testSetValueWithScriptInJavaParseable() { ScriptTypeValue value = new ScriptTypeValue("java", SCRIPT_VALUE); ParseConditionResult result = mock(ParseConditionResult.class); Condition condition = mock(Condition.class); when(result.hasError()).thenReturn(false); when(result.getCondition()).thenReturn(condition); doReturn(PromiseMock.success(result)) .when(conditionEditorParsingService) .call(eq(SCRIPT_VALUE)); presenter.setValue(value); verifySetValueCommonActions(value); verify(simpleConditionEditor).setValue(condition); verifyShowSimpleConditionEditor(); }
@Test public void testSetValueWithScriptInJavaParseableInClient() { when(conditionEditorGeneratorService.isAvailable()).thenReturn(true); ScriptTypeValue value = new ScriptTypeValue("java", SCRIPT_VALUE); ParseConditionResult result = mock(ParseConditionResult.class); Condition condition = mock(Condition.class); when(result.hasError()).thenReturn(false); when(result.getCondition()).thenReturn(condition); doReturn(PromiseMock.success(result)) .when(conditionEditorParsingService) .call(eq(SCRIPT_VALUE)); presenter.setValue(value); verifySetValueCommonActions(value); verify(simpleConditionEditor, never()).setValue(any()); verifyShowScriptEditor(); }
@Test public void testSetValueWithScriptInJavaNotParseable() { ScriptTypeValue value = new ScriptTypeValue("java", SCRIPT_VALUE); ParseConditionResult result = mock(ParseConditionResult.class); when(result.hasError()).thenReturn(true); doReturn(PromiseMock.success(result)) .when(conditionEditorParsingService) .call(eq(SCRIPT_VALUE)); presenter.setValue(value); verifySetValueCommonActions(value); verify(simpleConditionEditor, never()).setValue(any()); verifyShowScriptEditor(); } |
### Question:
DecisionComponentFilter { Stream<DecisionComponentsItem> query(final Stream<DecisionComponentsItem> stream) { return stream.filter(byDrgElement()).filter(byTerm()); } }### Answer:
@Test public void testQueryWithoutFilters() { final DecisionComponentsItem item1 = item("Can Drive?", new Decision()); final DecisionComponentsItem item2 = item("Is Allowed?", new Decision()); final DecisionComponentsItem item3 = item("Age", new InputData()); final DecisionComponentsItem item4 = item("Name", new InputData()); final Stream<DecisionComponentsItem> stream = Stream.of(item1, item2, item3, item4); final Stream<DecisionComponentsItem> query = filter.query(stream); final List<DecisionComponentsItem> actualResult = query.collect(Collectors.toList()); final List<DecisionComponentsItem> expectedResult = asList(item1, item2, item3, item4); assertEquals(expectedResult, actualResult); } |
### Question:
ConditionEditorFieldEditorPresenter extends FieldEditorPresenter<ScriptTypeValue> { void onScriptEditorSelected() { scriptEditor.setValue(value); clearError(); showScriptEditor(); } @Inject ConditionEditorFieldEditorPresenter(final View view,
final SimpleConditionEditorPresenter simpleConditionEditor,
final ScriptTypeFieldEditorPresenter scriptEditor,
final ErrorPopupPresenter errorPopup,
final ConditionEditorParsingService conditionEditorParsingService,
final ConditionEditorGeneratorService conditionEditorGeneratorService,
final ClientTranslationService translationService); boolean isServiceAvailable(); @PostConstruct void init(); void init(ClientSession session); @Override void setReadOnly(boolean readOnly); @Override void setValue(ScriptTypeValue value); }### Answer:
@Test public void testOnScriptEditorSelected() { presenter.onScriptEditorSelected(); verify(scriptEditor).setValue(any()); verify(view).clearError(); verifyShowScriptEditor(); } |
### Question:
ConditionEditorFieldEditorPresenter extends FieldEditorPresenter<ScriptTypeValue> { void onSimpleConditionChange(Condition oldValue, Condition newValue) { if (simpleConditionEditor.isValid()) { conditionEditorGeneratorService .call(newValue) .then(result -> { onSimpleConditionChange(result); return null; }) .catch_(throwable -> { onSimpleConditionChangeError((Throwable) throwable); return null; }); } else { clearError(); } } @Inject ConditionEditorFieldEditorPresenter(final View view,
final SimpleConditionEditorPresenter simpleConditionEditor,
final ScriptTypeFieldEditorPresenter scriptEditor,
final ErrorPopupPresenter errorPopup,
final ConditionEditorParsingService conditionEditorParsingService,
final ConditionEditorGeneratorService conditionEditorGeneratorService,
final ClientTranslationService translationService); boolean isServiceAvailable(); @PostConstruct void init(); void init(ClientSession session); @Override void setReadOnly(boolean readOnly); @Override void setValue(ScriptTypeValue value); }### Answer:
@Test public void testOnSimpleConditionChangeWithServiceError() { when(translationService.getValue(UNEXPECTED_SCRIPT_GENERATION_ERROR, ERROR)).thenReturn(TRANSLATED_MESSAGE); doReturn(PromiseMock.error(new Throwable(ERROR))) .when(conditionEditorGeneratorService) .call(any()); when(simpleConditionEditor.isValid()).thenReturn(true); presenter.onSimpleConditionChange(mock(Condition.class), mock(Condition.class)); verify(errorPopup).showMessage(TRANSLATED_MESSAGE); verify(changeHandler, never()).onValueChange(any(), any()); } |
### Question:
SimpleConditionEditorPresenter extends FieldEditorPresenter<Condition> { @PostConstruct public void init() { view.init(this); view.getVariableSelectorDropDown().init(variableSearchService, variableSearchSelectionHandler); view.getVariableSelectorDropDown().setOnChange(this::onVariableChange); view.getConditionSelectorDropDown().init(functionSearchService, functionSearchSelectionHandler); view.getConditionSelectorDropDown().setSearchCacheEnabled(false); view.getConditionSelectorDropDown().setOnChange(this::onConditionChange); } @Inject SimpleConditionEditorPresenter(final View view,
final ManagedInstance<ConditionParamPresenter> paramInstance,
final VariableSearchService variableSearchService,
final FunctionSearchService functionSearchService,
final FunctionNamingService functionNamingService,
final ClientTranslationService translationService); @PostConstruct void init(); View getView(); void init(ClientSession session); @Override void setValue(Condition value); @Override void setReadOnly(boolean readOnly); void clear(); boolean isValid(); }### Answer:
@Test public void testInit() { presenter.init(); verify(view).init(presenter); verify(variableSelectorDropDown).init(variableSearchService, variableSearchSelectionHandler); verify(variableSelectorDropDown).setOnChange(any()); verify(conditionSelectorDropDown).init(functionSearchService, functionSearchSelectionHandler); verify(conditionSelectorDropDown).setOnChange(any()); verify(conditionSelectorDropDown).setSearchCacheEnabled(false); }
@Test public void testInitSession() { presenter.init(session); verify(variableSearchService).init(session); verify(functionSearchService).init(session); } |
### Question:
SimpleConditionEditorPresenter extends FieldEditorPresenter<Condition> { public View getView() { return view; } @Inject SimpleConditionEditorPresenter(final View view,
final ManagedInstance<ConditionParamPresenter> paramInstance,
final VariableSearchService variableSearchService,
final FunctionSearchService functionSearchService,
final FunctionNamingService functionNamingService,
final ClientTranslationService translationService); @PostConstruct void init(); View getView(); void init(ClientSession session); @Override void setValue(Condition value); @Override void setReadOnly(boolean readOnly); void clear(); boolean isValid(); }### Answer:
@Test public void setGetView() { assertEquals(view, presenter.getView()); } |
### Question:
DecisionComponentsItem { @PostConstruct public void init() { view.init(this); } @Inject DecisionComponentsItem(final View view); @PostConstruct void init(); View getView(); void setDecisionComponent(final DecisionComponent decisionComponent); void show(); void hide(); DRGElement getDrgElement(); }### Answer:
@Test public void testInit() { item.init(); verify(view).init(item); } |
### Question:
SimpleConditionEditorPresenter extends FieldEditorPresenter<Condition> { @Override public void setValue(Condition value) { super.setValue(value); clear(); if (value != null) { if (value.getParams().size() >= 1) { String type = variableSearchService.getOptionType(value.getParams().get(0)); if (type != null) { functionSearchService.reload(type, () -> onSetValue(value)); } else { view.setVariableError(translationService.getValue(VARIABLE_NOT_FOUND_ERROR, value.getParams().get(0))); } } else { view.setConditionError(translationService.getValue(CONDITION_MAL_FORMED)); } } } @Inject SimpleConditionEditorPresenter(final View view,
final ManagedInstance<ConditionParamPresenter> paramInstance,
final VariableSearchService variableSearchService,
final FunctionSearchService functionSearchService,
final FunctionNamingService functionNamingService,
final ClientTranslationService translationService); @PostConstruct void init(); View getView(); void init(ClientSession session); @Override void setValue(Condition value); @Override void setReadOnly(boolean readOnly); void clear(); boolean isValid(); }### Answer:
@Test public void testSetValueNull() { presenter.setValue(null); verifyClear(); assertNull(presenter.getValue()); verify(paramInstance, never()).get(); }
@Test public void testSetValueWhenConditionMalFormed() { Condition condition = new Condition(); when(translationService.getValue(CONDITION_MAL_FORMED)).thenReturn(TRANSLATED_MESSAGE); presenter.setValue(condition); verify(view).setConditionError(TRANSLATED_MESSAGE); verifyClear(); assertEquals(condition, presenter.getValue()); verify(paramInstance, never()).get(); } |
### Question:
SimpleConditionEditorPresenter extends FieldEditorPresenter<Condition> { public void clear() { variableSearchSelectionHandler.clearSelection(); functionSearchSelectionHandler.clearSelection(); functionSearchService.clear(); removeParams(); clearErrors(); } @Inject SimpleConditionEditorPresenter(final View view,
final ManagedInstance<ConditionParamPresenter> paramInstance,
final VariableSearchService variableSearchService,
final FunctionSearchService functionSearchService,
final FunctionNamingService functionNamingService,
final ClientTranslationService translationService); @PostConstruct void init(); View getView(); void init(ClientSession session); @Override void setValue(Condition value); @Override void setReadOnly(boolean readOnly); void clear(); boolean isValid(); }### Answer:
@Test public void testClear() { presenter.clear(); verifyClear(); } |
### Question:
SimpleConditionEditorPresenter extends FieldEditorPresenter<Condition> { public boolean isValid() { return valid; } @Inject SimpleConditionEditorPresenter(final View view,
final ManagedInstance<ConditionParamPresenter> paramInstance,
final VariableSearchService variableSearchService,
final FunctionSearchService functionSearchService,
final FunctionNamingService functionNamingService,
final ClientTranslationService translationService); @PostConstruct void init(); View getView(); void init(ClientSession session); @Override void setValue(Condition value); @Override void setReadOnly(boolean readOnly); void clear(); boolean isValid(); }### Answer:
@Test public void testOnParamChangeWhenParamsAreValid() { prepareForParamChangeTest(true); paramCommandCaptor.getValue().execute(); verifyConditionWasCreated(); assertTrue(presenter.isValid()); }
@Test public void testOnParamChangeWhenParamsAreNotValid() { prepareForParamChangeTest(false); paramCommandCaptor.getValue().execute(); verifyConditionWasCreated(); assertFalse(presenter.isValid()); } |
### Question:
BPMNDiagramFilterProvider implements StunnerFormElementFilterProvider { @Override public Class<?> getDefinitionType() { return BPMNDiagramImpl.class; } BPMNDiagramFilterProvider(); @Inject BPMNDiagramFilterProvider(final SessionManager sessionManager,
final DiagramTypeClientService diagramTypeService,
final FieldChangeHandlerManager fieldChangeHandlerManager,
final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent); @Override Class<?> getDefinitionType(); @Override Collection<FormElementFilter> provideFilters(String elementUUID, Object definition); }### Answer:
@Test public void getDefinitionType() { assertEquals(tested.getDefinitionType(), BPMNDiagramImpl.class); } |
### Question:
BPMNDiagramFilterProvider implements StunnerFormElementFilterProvider { void onFormFieldChanged(@Observes FormFieldChanged formFieldChanged) { final String adHocFieldName = BPMNDiagramImpl.DIAGRAM_SET + "." + DiagramSet.ADHOC; if (!Objects.equals(formFieldChanged.getName(), adHocFieldName)) { return; } refreshFormPropertiesEvent.fire(new RefreshFormPropertiesEvent(sessionManager.getCurrentSession(), formFieldChanged.getUuid())); } BPMNDiagramFilterProvider(); @Inject BPMNDiagramFilterProvider(final SessionManager sessionManager,
final DiagramTypeClientService diagramTypeService,
final FieldChangeHandlerManager fieldChangeHandlerManager,
final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent); @Override Class<?> getDefinitionType(); @Override Collection<FormElementFilter> provideFilters(String elementUUID, Object definition); }### Answer:
@Test public void onFormFieldChanged() { tested.onFormFieldChanged(formFieldChanged); final ArgumentCaptor<RefreshFormPropertiesEvent> refreshFormPropertiesArgumentCaptor = ArgumentCaptor.forClass(RefreshFormPropertiesEvent.class); verify(refreshFormPropertiesEvent).fire(refreshFormPropertiesArgumentCaptor.capture()); RefreshFormPropertiesEvent refreshEvent = refreshFormPropertiesArgumentCaptor.getValue(); assertEquals(refreshEvent.getUuid(), UUID); assertEquals(refreshEvent.getSession(), session); } |
### Question:
AssociationFilterProvider implements StunnerFormElementFilterProvider { @SuppressWarnings("unchecked") @Override public Collection<FormElementFilter> provideFilters(String elementUUID, Object definition) { FormElementFilter nameFilter = new FormElementFilter("general.name", o -> false); return Collections.singletonList(nameFilter); } AssociationFilterProvider(); @Override Class<?> getDefinitionType(); @SuppressWarnings("unchecked") @Override Collection<FormElementFilter> provideFilters(String elementUUID,
Object definition); }### Answer:
@Test @SuppressWarnings("unchecked") public void testProvideFilters() { String arbitraryElementUUID = "arbitraryElementUUID"; Object arbitraryObject = mock(Object.class); Collection<FormElementFilter> result = filterProvider.provideFilters(arbitraryElementUUID, arbitraryObject); assertEquals(1, result.size()); FormElementFilter filter = result.iterator().next(); assertEquals("general.name", filter.getElementName()); Object arbitraryValue = mock(Object.class); assertFalse(filter.getPredicate().test(arbitraryValue)); assertEquals(DirectionalAssociation.class, filterProvider.getDefinitionType()); } |
### Question:
MultipleInstanceNodeFilterProvider implements StunnerFormElementFilterProvider { void onFormFieldChanged(@Observes final FormFieldChanged formFieldChanged) { applyFormFieldChange(formFieldChanged); } MultipleInstanceNodeFilterProvider(); MultipleInstanceNodeFilterProvider(final SessionManager sessionManager,
final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent); abstract boolean isMultipleInstance(final Object definition); @Override @SuppressWarnings("unchecked") Collection<FormElementFilter> provideFilters(final String elementUUID, final Object definition); }### Answer:
@Test public void testOnFormFieldChangedForMultipleInstance() { FormFieldChanged formFieldChanged = mockFormFieldChanged(IS_MULTIPLE_INSTANCE, UUID); filterProvider.onFormFieldChanged(formFieldChanged); verifyFieldChangeFired(); }
@Test public void testOnFormFieldChangedForOtherThanMultipleInstance() { FormFieldChanged formFieldChanged = mockFormFieldChanged("anyOtherField", "anyOtherUUID"); filterProvider.onFormFieldChanged(formFieldChanged); verify(refreshFormPropertiesEvent, never()).fire(any()); } |
### Question:
DecisionComponentsItem { public View getView() { return view; } @Inject DecisionComponentsItem(final View view); @PostConstruct void init(); View getView(); void setDecisionComponent(final DecisionComponent decisionComponent); void show(); void hide(); DRGElement getDrgElement(); }### Answer:
@Test public void testGetView() { assertEquals(view, item.getView()); } |
### Question:
RuleFlowGroupFormProvider implements SelectorDataProvider { @Override public String getProviderName() { return getClass().getSimpleName(); } @PostConstruct void populateData(); @Override String getProviderName(); @Override SelectorData<String> getSelectorData(final FormRenderingContext context); static void initServerData(); static Event<RequestRuleFlowGroupDataEvent> getRequestRuleFlowGroupDataEventEventSingleton(); }### Answer:
@Test public void testGetProviderName() { assertEquals(tested.getClass().getSimpleName(), tested.getProviderName()); } |
### Question:
RuleFlowGroupFormProvider implements SelectorDataProvider { @Override public SelectorData<String> getSelectorData(final FormRenderingContext context) { requestRuleFlowGroupDataEvent.fire(new RequestRuleFlowGroupDataEvent()); return new SelectorData<>(toMap(dataProvider.getRuleFlowGroupNames()), null); } @PostConstruct void populateData(); @Override String getProviderName(); @Override SelectorData<String> getSelectorData(final FormRenderingContext context); static void initServerData(); static Event<RequestRuleFlowGroupDataEvent> getRequestRuleFlowGroupDataEventEventSingleton(); }### Answer:
@Test @SuppressWarnings("unchecked") public void testGetSelectorData() { RuleFlowGroup group1 = new RuleFlowGroup("g1"); group1.setPathUri("default: RuleFlowGroup group2 = new RuleFlowGroup("g2"); group2.setPathUri("default: RuleFlowGroup group3 = new RuleFlowGroup("g1"); group3.setPathUri("default: List<RuleFlowGroup> groups = Arrays.asList(group1, group2, group3); when(dataProvider.getRuleFlowGroupNames()).thenReturn(groups); FormRenderingContext context = mock(FormRenderingContext.class); SelectorData data = tested.getSelectorData(context); Map<String, String> values = data.getValues(); assertNotNull(values); assertEquals(2, values.size()); assertEquals("g2 [Project1]", values.get(group2.getName())); assertEquals("g1 [Project1, Project2]", values.get(group1.getName())); verify(requestRuleFlowGroupDataEvent, times(1)).fire(any(RequestRuleFlowGroupDataEvent.class)); }
@Test public void testGroupWithSameProject() { RuleFlowGroup group1 = new RuleFlowGroup("g1"); group1.setPathUri("default: RuleFlowGroup group2 = new RuleFlowGroup("g1"); group2.setPathUri("default: RuleFlowGroup group3 = new RuleFlowGroup("g1"); group3.setPathUri("default: List<RuleFlowGroup> groups = Arrays.asList(group1, group2, group3); when(dataProvider.getRuleFlowGroupNames()).thenReturn(groups); FormRenderingContext context = mock(FormRenderingContext.class); SelectorData<String> data = tested.getSelectorData(context); Map<String, String> values = data.getValues(); assertNotNull(values); assertEquals(1, values.size()); assertEquals("g1 [Project1, Project2]", values.get(group1.getName())); verify(requestRuleFlowGroupDataEvent, times(1)).fire(any(RequestRuleFlowGroupDataEvent.class)); } |
### Question:
CalledElementFormProvider implements SelectorDataProvider { @Override public String getProviderName() { return getClass().getSimpleName(); } @Override String getProviderName(); @PostConstruct void populateData(); @Override @SuppressWarnings("unchecked") SelectorData getSelectorData(final FormRenderingContext context); static void initServerData(); static Event<RequestProcessDataEvent> getRequestProcessDataEventSingleton(); }### Answer:
@Test public void testGetProviderName() { assertEquals(tested.getClass().getSimpleName(), tested.getProviderName()); } |
### Question:
CalledElementFormProvider implements SelectorDataProvider { @Override @SuppressWarnings("unchecked") public SelectorData getSelectorData(final FormRenderingContext context) { requestProcessDataEvent.fire(new RequestProcessDataEvent()); return new SelectorData(toMap(dataProvider.getProcessIds()), null); } @Override String getProviderName(); @PostConstruct void populateData(); @Override @SuppressWarnings("unchecked") SelectorData getSelectorData(final FormRenderingContext context); static void initServerData(); static Event<RequestProcessDataEvent> getRequestProcessDataEventSingleton(); }### Answer:
@Test public void testGetSelectorData() { List<String> names = Arrays.asList("p1", "p2", "p3"); when(dataProvider.getProcessIds()).thenReturn(names); FormRenderingContext context = mock(FormRenderingContext.class); SelectorData data = tested.getSelectorData(context); Map values = data.getValues(); assertNotNull(values); assertEquals(3, values.size()); assertTrue(values.containsKey("p1")); assertTrue(values.containsKey("p2")); assertTrue(values.containsKey("p3")); verify(event, times(1)).fire(any(RequestProcessDataEvent.class)); } |
### Question:
RuleFlowGroupDataProvider { void onRuleFlowGroupDataChanged(final @Observes RuleFlowGroupDataEvent event) { setRuleFlowGroupNames(toList(event.getGroups())); } RuleFlowGroupDataProvider(); @Inject RuleFlowGroupDataProvider(final StunnerFormsHandler formsHandler); List<RuleFlowGroup> getRuleFlowGroupNames(); }### Answer:
@Test public void testOnRuleFlowGroupDataChanged() { RuleFlowGroup group1 = new RuleFlowGroup("g1"); RuleFlowGroup group2 = new RuleFlowGroup("g2"); RuleFlowGroupDataEvent event = mock(RuleFlowGroupDataEvent.class); when(event.getGroups()).thenReturn(new RuleFlowGroup[]{group1, group2}); tested.onRuleFlowGroupDataChanged(event); verify(formsHandler, times(1)).refreshCurrentSessionForms(eq(BPMNDefinitionSet.class)); List<RuleFlowGroup> values = tested.getRuleFlowGroupNames(); assertNotNull(values); assertEquals(2, values.size()); assertEquals("g1", values.get(0).getName()); assertEquals("g2", values.get(1).getName()); }
@Test public void testOnRuleFlowGroupDataNotChanged() { RuleFlowGroup group1 = new RuleFlowGroup("g1"); RuleFlowGroup group2 = new RuleFlowGroup("g2"); tested.groups.add(group1); tested.groups.add(group2); RuleFlowGroupDataEvent event = mock(RuleFlowGroupDataEvent.class); when(event.getGroups()).thenReturn(new RuleFlowGroup[]{group1, group2}); tested.onRuleFlowGroupDataChanged(event); verify(formsHandler, never()).refreshCurrentSessionForms(any(Class.class)); } |
### Question:
ExecutionOrderProvider implements SelectorDataProvider { @Override @SuppressWarnings("unchecked") public SelectorData getSelectorData(final FormRenderingContext context) { Map<Object, String> values = new TreeMap<>(Comparator.comparing(o -> valuePosition.get(o))); Arrays.stream(DataProviderOption.values()) .forEach(scope -> values.put(scope.value(), translationService.getValue(scope.i18nKey()))); return new SelectorData(values, DataProviderOption.SEQUENTIAL.value()); } @Inject ExecutionOrderProvider(final ClientTranslationService translationService); @Override String getProviderName(); @Override @SuppressWarnings("unchecked") SelectorData getSelectorData(final FormRenderingContext context); }### Answer:
@Test public void testGetSelectorData() { SelectorData selectorData = provider.getSelectorData(context); assertNotNull(selectorData.getValues()); assertEquals(2, selectorData.getValues().size()); assertEquals(ExecutionOrder.SEQUENTIAL.value(), selectorData.getSelectedValue()); assertEquals(SEQUENTIAL_LABEL, selectorData.getValues().get(ExecutionOrder.SEQUENTIAL.value())); assertEquals(PARALLEL_LABEL, selectorData.getValues().get(ExecutionOrder.PARALLEL.value())); } |
### Question:
ProcessCompensationRefProvider implements SelectorDataProvider { @Override @SuppressWarnings("unchecked") public SelectorData getSelectorData(FormRenderingContext context) { final Diagram diagram = sessionManager.getCurrentSession().getCanvasHandler().getDiagram(); final String rootUUID = diagram.getMetadata().getCanvasRootUUID(); final Node<?, ? extends Edge> selectedNode = getSelectedNode(diagram, sessionManager.getCurrentSession()); final Map<Object, String> values = new TreeMap<>(SafeComparator.TO_STRING_COMPARATOR); if (selectedNode != null) { Node<?, ? extends Edge> currentNode = selectedNode; final List<Node> compensableNodes = new ArrayList<>(); Node<?, ? extends Edge> parentNode; int levels = 0; do { parentNode = GraphUtils.getParent(currentNode).asNode(); compensableNodes.addAll(getCompensableNodes(parentNode)); if (rootUUID.equals(parentNode.getUUID())) { levels = 2; } else if (isSubProcess(parentNode)) { currentNode = parentNode; levels++; } else if (isLane(parentNode)) { currentNode = parentNode; } } while (levels < 2); compensableNodes.stream() .map(node -> buildPair(node.getUUID(), (BPMNDefinition) (((View) node.getContent()).getDefinition()))) .forEach(pair -> values.put(pair.getK1(), pair.getK2())); ActivityRef currentActivityRef = null; if (isEndCompensationEvent(selectedNode)) { currentActivityRef = ((EndCompensationEvent) ((View) selectedNode.getContent()).getDefinition()).getExecutionSet().getActivityRef(); } else if (isIntermediateCompensationEventThrowing(selectedNode)) { currentActivityRef = ((IntermediateCompensationEventThrowing) ((View) selectedNode.getContent()).getDefinition()).getExecutionSet().getActivityRef(); } if (currentActivityRef != null && !isEmpty(currentActivityRef.getValue()) && !values.containsKey(currentActivityRef.getValue())) { Node configured = diagram.getGraph().getNode(currentActivityRef.getValue()); if (configured != null) { Pair<Object, String> pair = buildPair(configured.getUUID(), (BPMNDefinition) ((View) configured.getContent()).getDefinition()); values.put(pair.getK1(), pair.getK2()); } } } return new SelectorData(values, null); } @Inject ProcessCompensationRefProvider(final SessionManager sessionManager); @Override String getProviderName(); @Override @SuppressWarnings("unchecked") SelectorData getSelectorData(FormRenderingContext context); }### Answer:
@Test public void testGetSelectorDataWhenNoNodeSelected() { setSelectedNode(null); SelectorData result = provider.getSelectorData(renderingContext); assertResult(new ArrayList<>(), result); } |
### Question:
DecisionComponentsItem { public void setDecisionComponent(final DecisionComponent decisionComponent) { this.decisionComponent = decisionComponent; setupView(); } @Inject DecisionComponentsItem(final View view); @PostConstruct void init(); View getView(); void setDecisionComponent(final DecisionComponent decisionComponent); void show(); void hide(); DRGElement getDrgElement(); }### Answer:
@Test public void testSetDecisionComponent() { final DecisionComponent decisionComponent = mock(DecisionComponent.class); when(decisionComponent.getIcon()).thenReturn(DECISION_PALETTE); when(decisionComponent.getName()).thenReturn("name"); when(decisionComponent.getFileName()).thenReturn("file"); item.setDecisionComponent(decisionComponent); verify(view).setIcon(DECISION_PALETTE.getUri().asString()); verify(view).setName(decisionComponent.getName()); verify(view).setFile(decisionComponent.getFileName()); } |
### Question:
ProcessTypeProvider extends AbstractProcessFilteredNodeProvider { @Override public String getProviderName() { return getClass().getSimpleName(); } @Inject ProcessTypeProvider(final SessionManager sessionManager); @Override String getProviderName(); @Override Predicate<Node> getFilter(); @Override Function<Node, Pair<Object, String>> getMapper(); @Override @SuppressWarnings("unchecked") SelectorData getSelectorData(final FormRenderingContext context); }### Answer:
@Test public void testGetProviderName() { assertEquals(tested.getClass().getSimpleName(), tested.getProviderName()); } |
### Question:
ProcessTypeProvider extends AbstractProcessFilteredNodeProvider { @Override @SuppressWarnings("unchecked") public SelectorData getSelectorData(final FormRenderingContext context) { return new SelectorData(Arrays.asList(TYPES) .stream() .collect(Collectors.toMap(p -> p, p -> p)), "Public"); } @Inject ProcessTypeProvider(final SessionManager sessionManager); @Override String getProviderName(); @Override Predicate<Node> getFilter(); @Override Function<Node, Pair<Object, String>> getMapper(); @Override @SuppressWarnings("unchecked") SelectorData getSelectorData(final FormRenderingContext context); }### Answer:
@Test public void testGetValues() { SelectorData selectorData = tested.getSelectorData(context); assertEquals(2, selectorData.getValues().size()); assertEquals("Public", selectorData.getSelectedValue()); assertTrue(selectorData.getValues().containsValue("Public")); assertTrue(selectorData.getValues().containsValue("Private")); } |
### Question:
ProcessTypeProvider extends AbstractProcessFilteredNodeProvider { @Override public Predicate<Node> getFilter() { return node -> true; } @Inject ProcessTypeProvider(final SessionManager sessionManager); @Override String getProviderName(); @Override Predicate<Node> getFilter(); @Override Function<Node, Pair<Object, String>> getMapper(); @Override @SuppressWarnings("unchecked") SelectorData getSelectorData(final FormRenderingContext context); }### Answer:
@Test public void testGetFilter() { assertTrue(tested.getFilter().test(new NodeImpl("uuid_1"))); } |
### Question:
ProcessTypeProvider extends AbstractProcessFilteredNodeProvider { @Override public Function<Node, Pair<Object, String>> getMapper() { return null; } @Inject ProcessTypeProvider(final SessionManager sessionManager); @Override String getProviderName(); @Override Predicate<Node> getFilter(); @Override Function<Node, Pair<Object, String>> getMapper(); @Override @SuppressWarnings("unchecked") SelectorData getSelectorData(final FormRenderingContext context); }### Answer:
@Test public void testGetMapper() { assertNull(tested.getMapper()); } |
### Question:
ProcessesDataProvider { void onProcessesUpdatedEvent(final @Observes ProcessDataEvent event) { setProcessIds(toList(event.getProcessIds())); } ProcessesDataProvider(); @Inject ProcessesDataProvider(final StunnerFormsHandler formsHandler); List<String> getProcessIds(); }### Answer:
@Test public void testOnProcessesUpdatedEvent() { ProcessDataEvent event = mock(ProcessDataEvent.class); when(event.getProcessIds()).thenReturn(new String[]{"p1", "p2"}); tested.onProcessesUpdatedEvent(event); verify(formsHandler, times(1)).refreshCurrentSessionForms(eq(BPMNDefinitionSet.class)); List<String> values = tested.getProcessIds(); assertNotNull(values); assertEquals(2, values.size()); assertTrue(values.contains("p1")); assertTrue(values.contains("p2")); } |
### Question:
WorkItemDefinitionClientParser { public static List<WorkItemDefinition> parse(String widStr) { if (empty(widStr)) { return Collections.emptyList(); } List<WorkItemDefinition> widList = new ArrayList<>(); String[] lines = widStr.split("\r\n|\r|\n"); Queue<String> linesQueue = new LinkedList<>(Arrays.asList(lines)); while (!linesQueue.isEmpty()) { String line = linesQueue.peek().trim(); if (!(empty(line) || isStartingObject(line) || isEndingObject(line))) { WorkItemDefinition wid = parseWorkItemDefinitionObject(linesQueue); widList.add(wid); } linesQueue.poll(); } return widList; } static List<WorkItemDefinition> parse(String widStr); }### Answer:
@Test public void emptyWidsTest() { List<WorkItemDefinition> defs = WorkItemDefinitionClientParser.parse(""); assertTrue(defs.isEmpty()); defs = WorkItemDefinitionClientParser.parse("[]"); assertTrue(defs.isEmpty()); defs = WorkItemDefinitionClientParser.parse("[\n]"); assertTrue(defs.isEmpty()); defs = WorkItemDefinitionClientParser.parse(null); assertTrue(defs.isEmpty()); } |
### Question:
BPMNCreateNodeAction extends GeneralCreateNodeAction { public static boolean isAutoMagnetConnection(final Node<View<?>, Edge> sourceNode, final Node<View<?>, Edge> targetNode) { final Object sourceDefinition = null != sourceNode ? sourceNode.getContent().getDefinition() : null; final Object targetDefinition = null != targetNode ? targetNode.getContent().getDefinition() : null; final boolean isSourceGateway = isGateway(sourceDefinition); final boolean isTargetGateway = isGateway(targetDefinition); return !(isSourceGateway || isTargetGateway); } @Inject BPMNCreateNodeAction(final DefinitionUtils definitionUtils,
final ClientFactoryManager clientFactoryManager,
final CanvasLayoutUtils canvasLayoutUtils,
final Event<CanvasSelectionEvent> selectionEvent,
final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
final @Any ManagedInstance<DefaultCanvasCommandFactory> canvasCommandFactories); static boolean isAutoMagnetConnection(final Node<View<?>, Edge> sourceNode,
final Node<View<?>, Edge> targetNode); }### Answer:
@Test @SuppressWarnings("unchecked") public void testIsAutoConnection() { assertFalse(isAutoMagnetConnection(gatewayNode, taskNode)); assertFalse(isAutoMagnetConnection(gatewayNode, eventNode)); assertFalse(isAutoMagnetConnection(taskNode, gatewayNode)); assertFalse(isAutoMagnetConnection(eventNode, gatewayNode)); assertFalse(isAutoMagnetConnection(gatewayNode, gatewayNode)); assertTrue(isAutoMagnetConnection(taskNode, taskNode)); assertTrue(isAutoMagnetConnection(eventNode, taskNode)); assertTrue(isAutoMagnetConnection(taskNode, eventNode)); assertTrue(isAutoMagnetConnection(eventNode, eventNode)); } |
### Question:
StunnerBPMNEntryPoint { @PostConstruct public void init() { PatternFlyBootstrapper.ensureMonacoEditorLoaderIsAvailable(); FormFiltersProviderFactory.registerProvider(new StartEventFilterProvider(sessionManager, StartNoneEvent.class)); FormFiltersProviderFactory.registerProvider(new StartEventFilterProvider(sessionManager, StartCompensationEvent.class)); FormFiltersProviderFactory.registerProvider(new StartEventFilterProvider(sessionManager, StartSignalEvent.class)); FormFiltersProviderFactory.registerProvider(new StartEventFilterProvider(sessionManager, StartMessageEvent.class)); FormFiltersProviderFactory.registerProvider(new StartEventFilterProvider(sessionManager, StartErrorEvent.class)); FormFiltersProviderFactory.registerProvider(new StartEventFilterProvider(sessionManager, StartTimerEvent.class)); FormFiltersProviderFactory.registerProvider(new StartEventFilterProvider(sessionManager, StartConditionalEvent.class)); FormFiltersProviderFactory.registerProvider(new StartEventFilterProvider(sessionManager, StartEscalationEvent.class)); FormFiltersProviderFactory.registerProvider(new CatchingIntermediateEventFilterProvider(sessionManager, IntermediateTimerEvent.class)); FormFiltersProviderFactory.registerProvider(new CatchingIntermediateEventFilterProvider(sessionManager, IntermediateErrorEventCatching.class)); FormFiltersProviderFactory.registerProvider(new CatchingIntermediateEventFilterProvider(sessionManager, IntermediateConditionalEvent.class)); FormFiltersProviderFactory.registerProvider(new CatchingIntermediateEventFilterProvider(sessionManager, IntermediateCompensationEvent.class)); FormFiltersProviderFactory.registerProvider(new CatchingIntermediateEventFilterProvider(sessionManager, IntermediateSignalEventCatching.class)); FormFiltersProviderFactory.registerProvider(new CatchingIntermediateEventFilterProvider(sessionManager, IntermediateLinkEventCatching.class)); FormFiltersProviderFactory.registerProvider(new CatchingIntermediateEventFilterProvider(sessionManager, IntermediateEscalationEvent.class)); FormFiltersProviderFactory.registerProvider(new CatchingIntermediateEventFilterProvider(sessionManager, IntermediateMessageEventCatching.class)); FormFiltersProviderFactory.registerProvider(new AssociationFilterProvider()); managedFilters.forEach(FormFiltersProviderFactory::registerProvider); } @Inject StunnerBPMNEntryPoint(SessionManager sessionManager, ManagedInstance<StunnerFormElementFilterProvider> managedFilters); @PostConstruct void init(); }### Answer:
@Test public void init() { tested.init(); FormFiltersProviderFactory.getFilterForDefinition(UUID, diagramDef); verify(bpmnDiagramFilterProvider).provideFilters(UUID, diagramDef); FormFiltersProviderFactory.getFilterForDefinition(UUID, startEventDef); verify(startEventFilterProvider).provideFilters(UUID, startEventDef); FormFiltersProviderFactory.getFilterForDefinition(UUID, intermediateEventDef); verify(catchingIntermediateEventFilterProvider).provideFilters(UUID, intermediateEventDef); } |
### Question:
BPMNValidatorImpl implements BPMNValidator { @Override public void validate(Diagram diagram, Consumer<Collection<DomainViolation>> resultConsumer) { String rawContent = diagramService.getRawContent(diagram); if (Objects.nonNull(rawContent)) { resultConsumer.accept(validate(rawContent, diagram.getMetadata().getTitle()).stream().collect(Collectors.toSet())); return; } resultConsumer.accept(Collections.emptyList()); } BPMNValidatorImpl(); @Inject BPMNValidatorImpl(final @Default DiagramService diagramService); @Override void validate(Diagram diagram, Consumer<Collection<DomainViolation>> resultConsumer); @Override String getDefinitionSetId(); }### Answer:
@Test public void validateSerialized() { Collection<BPMNViolation> violations = bpmnValidador.validate(getSerializedProcess(BPMN_VALID), PROCESS_UUID); assertTrue(violations.isEmpty()); }
@Test public void validateWithExceptionsOnParsingXML() { final Collection<BPMNViolation> violations = bpmnValidador.validate("INVALID_XML", PROCESS_UUID); assertProcessException(violations); }
@Test public void validateWithException() { when(diagram.getMetadata()).thenThrow(new RuntimeException()); final Collection<BPMNViolation> violations = bpmnValidador.validate(null, PROCESS_UUID); assertProcessException(violations); }
@Test public void validateWithViolation() { when(diagramService.getRawContent(diagram)).thenReturn(getSerializedProcess(BPMN_VALIDATION_ISSUES)); bpmnValidador.validate(diagram, result -> { assertNotNull(result); assertEquals(10, result.size()); assertTrue(result.stream().map(DomainViolation::getViolationType).allMatch(t -> Violation.Type.WARNING.equals(t))); assertEquals(10, result.stream().map(DomainViolation::getUUID).filter(StringUtils::nonEmpty).count()); assertEquals(4, result.stream() .map(DomainViolation::getUUID) .filter("_426E32AD-E08B-4025-B201-9850EEC82254"::equals) .count()); assertEquals(3, result.stream() .map(DomainViolation::getUUID) .filter("_3E6C197E-FF8A-41F4-AEB6-710454E8529C"::equals) .count()); assertEquals(1, result.stream() .map(DomainViolation::getUUID) .filter("_0F455E77-669C-480F-A4A2-C5070EF1A83F"::equals) .count()); assertEquals(2, result.stream() .map(DomainViolation::getUUID) .filter("_5B1068ED-1260-41FD-B7C1-226CB909E569"::equals) .count()); }); }
@Test public void validateNoViolations() { when(diagramService.getRawContent(diagram)).thenReturn(getSerializedProcess(BPMN_VALID)); bpmnValidador.validate(diagram, result -> { assertNotNull(result); assertTrue(result.isEmpty()); }); } |
### Question:
DecisionComponentsItem { public void show() { HiddenHelper.show(getView().getElement()); } @Inject DecisionComponentsItem(final View view); @PostConstruct void init(); View getView(); void setDecisionComponent(final DecisionComponent decisionComponent); void show(); void hide(); DRGElement getDrgElement(); }### Answer:
@Test public void testShow() { final HTMLElement viewElement = mock(HTMLElement.class); when(view.getElement()).thenReturn(viewElement); viewElement.classList = mock(DOMTokenList.class); item.show(); verify(viewElement.classList).remove(HIDDEN_CSS_CLASS); } |
### Question:
BPMNValidatorImpl implements BPMNValidator { @Override public String getDefinitionSetId() { return BindableAdapterUtils.getDefinitionSetId(BPMNDefinitionSet.class); } BPMNValidatorImpl(); @Inject BPMNValidatorImpl(final @Default DiagramService diagramService); @Override void validate(Diagram diagram, Consumer<Collection<DomainViolation>> resultConsumer); @Override String getDefinitionSetId(); }### Answer:
@Test public void getDefinitionSetId() { assertEquals(bpmnValidador.getDefinitionSetId(), BindableAdapterUtils.getDefinitionId(BPMNDefinitionSet.class)); } |
### Question:
BPMNElementDecorators { public static <T extends FlowElement> MarshallingMessageDecorator<T> flowElementDecorator() { return MarshallingMessageDecorator.of(o -> Optional.ofNullable(o.getName()) .orElseGet(o::getId), g -> g.getClass().getSimpleName()); } static MarshallingMessageDecorator<T> flowElementDecorator(); static MarshallingMessageDecorator<T> baseElementDecorator(); static MarshallingMessageDecorator<T> bpmnNodeDecorator(); static MarshallingMessageDecorator<Result> resultBpmnDecorator(); }### Answer:
@Test public void flowElementDecorator() { MarshallingMessageDecorator<FlowElement> decorator = BPMNElementDecorators.flowElementDecorator(); FlowElement element = mock(FlowElement.class); when(element.getName()).thenReturn(NAME); assertEquals(NAME, decorator.getName(element)); assertEquals(element.getClass().getSimpleName(), decorator.getType(element)); } |
### Question:
BPMNElementDecorators { public static <T extends BaseElement> MarshallingMessageDecorator<T> baseElementDecorator() { return MarshallingMessageDecorator.of(BaseElement::getId, g -> g.getClass().getSimpleName()); } static MarshallingMessageDecorator<T> flowElementDecorator(); static MarshallingMessageDecorator<T> baseElementDecorator(); static MarshallingMessageDecorator<T> bpmnNodeDecorator(); static MarshallingMessageDecorator<Result> resultBpmnDecorator(); }### Answer:
@Test public void baseElementDecorator() { MarshallingMessageDecorator<BaseElement> decorator = BPMNElementDecorators.baseElementDecorator(); BaseElement element = mock(FlowElement.class); when(element.getId()).thenReturn(NAME); assertEquals(NAME, decorator.getName(element)); assertEquals(element.getClass().getSimpleName(), decorator.getType(element)); } |
### Question:
BPMNElementDecorators { public static <T extends BpmnNode> MarshallingMessageDecorator<T> bpmnNodeDecorator() { return MarshallingMessageDecorator.of(o -> Optional.ofNullable(o.value() .getContent() .getDefinition() .getGeneral() .getName() .getValue()) .orElseGet(() -> o.value().getUUID()), bpmnNode -> bpmnNode.value() .getContent() .getDefinition() .getClass() .getSimpleName()); } static MarshallingMessageDecorator<T> flowElementDecorator(); static MarshallingMessageDecorator<T> baseElementDecorator(); static MarshallingMessageDecorator<T> bpmnNodeDecorator(); static MarshallingMessageDecorator<Result> resultBpmnDecorator(); }### Answer:
@Test public void bpmnNodeDecorator() { MarshallingMessageDecorator<BpmnNode> decorator = BPMNElementDecorators.bpmnNodeDecorator(); BpmnNode element = mockBpmnNode(); assertEquals(NAME, decorator.getName(element)); assertEquals(element.value().getContent().getDefinition().getClass().getSimpleName(), decorator.getType(element)); } |
### Question:
BPMNElementDecorators { public static MarshallingMessageDecorator<Result> resultBpmnDecorator() { return MarshallingMessageDecorator.of(r -> { BpmnNode o = (BpmnNode) r.value(); return Optional.ofNullable(o.value() .getContent() .getDefinition() .getGeneral() .getName() .getValue()) .orElseGet(() -> o.value().getUUID()); }, r -> { BpmnNode o1 = (BpmnNode) r.value(); return o1.value() .getContent() .getDefinition() .getClass() .getSimpleName(); }); } static MarshallingMessageDecorator<T> flowElementDecorator(); static MarshallingMessageDecorator<T> baseElementDecorator(); static MarshallingMessageDecorator<T> bpmnNodeDecorator(); static MarshallingMessageDecorator<Result> resultBpmnDecorator(); }### Answer:
@Test public void resultBpmnDecorator() { MarshallingMessageDecorator<Result> decorator = BPMNElementDecorators.resultBpmnDecorator(); BpmnNode node = mockBpmnNode(); Result result = Result.success(node); assertEquals(NAME, decorator.getName(result)); assertEquals(node.value().getContent().getDefinition().getClass().getSimpleName(), decorator.getType(result)); } |
### Question:
Match { public <Sub> Match<In, Out> whenExactly(Class<Sub> type, Function<Sub, Out> then) { Function<Sub, Result<Out>> thenWrapped = sub -> Result.of(then.apply(sub)); return whenExactly_(type, thenWrapped); } Match(Class<?> outputType); static Match<In, Out> of(Class<In> inputType, Class<Out> outputType); static Match<In, Node<? extends View<? extends Out>, ?>> ofNode(Class<In> inputType, Class<Out> outputType); static Match<Node<? extends View<? extends In>, ?>, Out> fromNode(Class<In> inputType, Class<Out> outputType); static Match<In, Edge<? extends View<? extends Out>, ?>> ofEdge(Class<In> inputType, Class<Out> outputType); Match<In, Out> when(Class<Sub> type, Function<Sub, Out> then); Match<In, Out> whenExactly(Class<Sub> type, Function<Sub, Out> then); Match<In, Out> missing(Class<Sub> type); Match<In, Out> ignore(Class<Sub> type); Match<In, Out> ignore(Class<Sub> type, Out outValue); Match<In, Out> orElse(Function<In, Out> then); Match<In, Out> inputDecorator(MarshallingMessageDecorator<In> decorator); Match<In, Out> outputDecorator(MarshallingMessageDecorator<Out> decorator); Match<In, Out> defaultValue(Out value); Match<In, Out> mode(Mode mode); Result<Out> apply(In value); }### Answer:
@Test public void whenExactlyTest() { UserTaskImpl element = (UserTaskImpl) Bpmn2Factory.eINSTANCE.createUserTask(); Result<BpmnNode> result = match().apply(element); verify(assertUserTask).apply(element); assertTrue(result.isSuccess()); } |
### Question:
Match { public <Sub> Match<In, Out> when(Class<Sub> type, Function<Sub, Out> then) { Function<Sub, Result<Out>> thenWrapped = sub -> Result.of(then.apply(sub)); return when_(type, thenWrapped); } Match(Class<?> outputType); static Match<In, Out> of(Class<In> inputType, Class<Out> outputType); static Match<In, Node<? extends View<? extends Out>, ?>> ofNode(Class<In> inputType, Class<Out> outputType); static Match<Node<? extends View<? extends In>, ?>, Out> fromNode(Class<In> inputType, Class<Out> outputType); static Match<In, Edge<? extends View<? extends Out>, ?>> ofEdge(Class<In> inputType, Class<Out> outputType); Match<In, Out> when(Class<Sub> type, Function<Sub, Out> then); Match<In, Out> whenExactly(Class<Sub> type, Function<Sub, Out> then); Match<In, Out> missing(Class<Sub> type); Match<In, Out> ignore(Class<Sub> type); Match<In, Out> ignore(Class<Sub> type, Out outValue); Match<In, Out> orElse(Function<In, Out> then); Match<In, Out> inputDecorator(MarshallingMessageDecorator<In> decorator); Match<In, Out> outputDecorator(MarshallingMessageDecorator<Out> decorator); Match<In, Out> defaultValue(Out value); Match<In, Out> mode(Mode mode); Result<Out> apply(In value); }### Answer:
@Test public void whenTest() { EventSubprocess element = Bpmn2Factory.eINSTANCE.createEventSubprocess(); Result<BpmnNode> result = match().apply(element); verify(assertSubProcess).apply(element); assertNotEquals(result.value(), defaultValue); assertTrue(result.isSuccess()); } |
### Question:
DecisionComponentsItem { public void hide() { HiddenHelper.hide(getView().getElement()); } @Inject DecisionComponentsItem(final View view); @PostConstruct void init(); View getView(); void setDecisionComponent(final DecisionComponent decisionComponent); void show(); void hide(); DRGElement getDrgElement(); }### Answer:
@Test public void testHide() { final HTMLElement viewElement = mock(HTMLElement.class); when(view.getElement()).thenReturn(viewElement); viewElement.classList = mock(DOMTokenList.class); item.hide(); verify(viewElement.classList).add(HIDDEN_CSS_CLASS); } |
### Question:
Match { public <Sub> Match<In, Out> missing(Class<Sub> type) { return when_(type, reportMissing(type)); } Match(Class<?> outputType); static Match<In, Out> of(Class<In> inputType, Class<Out> outputType); static Match<In, Node<? extends View<? extends Out>, ?>> ofNode(Class<In> inputType, Class<Out> outputType); static Match<Node<? extends View<? extends In>, ?>, Out> fromNode(Class<In> inputType, Class<Out> outputType); static Match<In, Edge<? extends View<? extends Out>, ?>> ofEdge(Class<In> inputType, Class<Out> outputType); Match<In, Out> when(Class<Sub> type, Function<Sub, Out> then); Match<In, Out> whenExactly(Class<Sub> type, Function<Sub, Out> then); Match<In, Out> missing(Class<Sub> type); Match<In, Out> ignore(Class<Sub> type); Match<In, Out> ignore(Class<Sub> type, Out outValue); Match<In, Out> orElse(Function<In, Out> then); Match<In, Out> inputDecorator(MarshallingMessageDecorator<In> decorator); Match<In, Out> outputDecorator(MarshallingMessageDecorator<Out> decorator); Match<In, Out> defaultValue(Out value); Match<In, Out> mode(Mode mode); Result<Out> apply(In value); }### Answer:
@Test public void missingTest() { ReceiveTask element = Bpmn2Factory.eINSTANCE.createReceiveTask(); Result<BpmnNode> result = match().apply(element); assertEquals(result.value(), defaultValue); assertTrue(result.isFailure()); } |
### Question:
SequenceFlowConverter implements EdgeConverter<org.eclipse.bpmn2.SequenceFlow> { @Override public Result<BpmnEdge> convertEdge(org.eclipse.bpmn2.SequenceFlow seq, Map<String, BpmnNode> nodes) { Edge<View<SequenceFlow>, Node> edge = factoryManager.newEdge(seq.getId(), SequenceFlow.class); SequenceFlow definition = edge.getContent().getDefinition(); SequenceFlowPropertyReader p = propertyReaderFactory.of(seq); definition.setGeneral(new BPMNGeneralSet( new Name(p.getName()), new Documentation(p.getDocumentation()) )); definition.setExecutionSet(new SequenceFlowExecutionSet( new Priority(p.getPriority()), new ConditionExpression(p.getConditionExpression()) )); return result(nodes, edge, p, "Sequence Flow ignored from " + p.getSourceId() + " to " + p.getTargetId(), MarshallingMessageKeys.sequenceFlowIgnored); } SequenceFlowConverter(TypedFactoryManager factoryManager, PropertyReaderFactory propertyReaderFactory); @Override Result<BpmnEdge> convertEdge(org.eclipse.bpmn2.SequenceFlow seq, Map<String, BpmnNode> nodes); }### Answer:
@Test public void convertEdge() { org.eclipse.bpmn2.SequenceFlow sequenceFlow = Bpmn2Factory.eINSTANCE.createSequenceFlow(); FlowNode source = Bpmn2Factory.eINSTANCE.createUserTask(); sequenceFlow.setSourceRef(source); FlowNode target = Bpmn2Factory.eINSTANCE.createBusinessRuleTask(); sequenceFlow.setTargetRef(target); Result<BpmnEdge> result = tested.convertEdge(sequenceFlow, new HashMap<>()); assertTrue(result.isIgnored()); assertNull(result.value()); Map<String, BpmnNode> nodes = new Maps.Builder<String, BpmnNode>() .put(SOURCE_ID, mock(BpmnNode.class)) .put(TARGET_ID, mock(BpmnNode.class)) .build(); result = tested.convertEdge(sequenceFlow, nodes); assertTrue(result.isSuccess()); BpmnEdge.Simple value = (BpmnEdge.Simple) result.value(); assertEquals(edge, value.getEdge()); } |
### Question:
ArtifactsConverter implements NodeConverter<org.eclipse.bpmn2.FlowElement> { @Override public Result<BpmnNode> convert(org.eclipse.bpmn2.FlowElement element) { return Match.of(FlowElement.class, BpmnNode.class) .when(org.eclipse.bpmn2.TextAnnotation.class, this::toTextAnnotation) .when(org.eclipse.bpmn2.DataObjectReference.class, this::toDataObject) .apply(element); } ArtifactsConverter(TypedFactoryManager typedFactoryManager, PropertyReaderFactory propertyReaderFactory); @Override Result<BpmnNode> convert(org.eclipse.bpmn2.FlowElement element); }### Answer:
@Test public void convertTextAnnotation() { TextAnnotation element = Bpmn2Factory.eINSTANCE.createTextAnnotation(); when(typedFactoryManager.newNode(anyString(), eq(org.kie.workbench.common.stunner.bpmn.definition.TextAnnotation.class))).thenReturn(nodeTextAnnotation); when(nodeTextAnnotation.getContent()).thenReturn(contentTextAnnotation); when(contentTextAnnotation.getDefinition()).thenReturn(defTextAnnotation); when(propertyReaderFactory.of(element)).thenReturn(readerTextAnnotation); final Result<BpmnNode> node = tested.convert(element); final Node<? extends View<? extends BPMNViewDefinition>, ?> value = node.value().value(); assertEquals(contentTextAnnotation, value.getContent()); assertEquals(defTextAnnotation, value.getContent().getDefinition()); }
@Test public void convertDataObject() { DataObjectReference element = Bpmn2Factory.eINSTANCE.createDataObjectReference(); when(typedFactoryManager.newNode(anyString(), eq(org.kie.workbench.common.stunner.bpmn.definition.DataObject.class))).thenReturn(nodeDataObject); when(nodeDataObject.getContent()).thenReturn(contentDataObject); when(contentDataObject.getDefinition()).thenReturn(defDataObject); when(propertyReaderFactory.of(element)).thenReturn(readerDataObject); final Result<BpmnNode> node = tested.convert(element); final Node<? extends View<? extends BPMNViewDefinition>, ?> value = node.value().value(); assertEquals(contentDataObject, value.getContent()); assertEquals(defDataObject, value.getContent().getDefinition()); } |
### Question:
CallActivityPropertyReader extends MultipleInstanceActivityPropertyReader { public boolean isCase() { return CustomElement.isCase.of(element).get(); } CallActivityPropertyReader(CallActivity callActivity, BPMNDiagram diagram, DefinitionResolver definitionResolver); String getCalledElement(); boolean isIndependent(); boolean isAbortParent(); boolean isWaitForCompletion(); boolean isAsync(); boolean isCase(); boolean isAdHocAutostart(); String getSlaDueDate(); }### Answer:
@Test public void testIsCase_true() { String id = UUID.randomUUID().toString(); CallActivity callActivity = bpmn2.createCallActivity(); callActivity.setId(id); CustomElement.isCase.of(callActivity).set(Boolean.TRUE); tested = new CallActivityPropertyReader(callActivity, definitionResolver.getDiagram(), definitionResolver); assertTrue(tested.isCase()); }
@Test public void testIsCase_false() { String id = UUID.randomUUID().toString(); CallActivity callActivity = bpmn2.createCallActivity(); callActivity.setId(id); CustomElement.isCase.of(callActivity).set(Boolean.FALSE); tested = new CallActivityPropertyReader(callActivity, definitionResolver.getDiagram(), definitionResolver); assertFalse(tested.isCase()); } |
### Question:
CallActivityPropertyReader extends MultipleInstanceActivityPropertyReader { public boolean isAdHocAutostart() { return CustomElement.autoStart.of(element).get(); } CallActivityPropertyReader(CallActivity callActivity, BPMNDiagram diagram, DefinitionResolver definitionResolver); String getCalledElement(); boolean isIndependent(); boolean isAbortParent(); boolean isWaitForCompletion(); boolean isAsync(); boolean isCase(); boolean isAdHocAutostart(); String getSlaDueDate(); }### Answer:
@Test public void testIsAdHocAutostart_true() { String id = UUID.randomUUID().toString(); CallActivity callActivity = bpmn2.createCallActivity(); callActivity.setId(id); CustomElement.autoStart.of(callActivity).set(Boolean.TRUE); tested = new CallActivityPropertyReader(callActivity, definitionResolver.getDiagram(), definitionResolver); assertTrue(tested.isAdHocAutostart()); }
@Test public void testIsAdHocAutostart_false() { String id = UUID.randomUUID().toString(); CallActivity callActivity = bpmn2.createCallActivity(); callActivity.setId(id); CustomElement.autoStart.of(callActivity).set(Boolean.FALSE); tested = new CallActivityPropertyReader(callActivity, definitionResolver.getDiagram(), definitionResolver); assertFalse(tested.isAdHocAutostart()); } |
### Question:
CallActivityPropertyReader extends MultipleInstanceActivityPropertyReader { public boolean isAsync() { return CustomElement.async.of(element).get(); } CallActivityPropertyReader(CallActivity callActivity, BPMNDiagram diagram, DefinitionResolver definitionResolver); String getCalledElement(); boolean isIndependent(); boolean isAbortParent(); boolean isWaitForCompletion(); boolean isAsync(); boolean isCase(); boolean isAdHocAutostart(); String getSlaDueDate(); }### Answer:
@Test public void testIsAsync() { CallActivity callActivity = bpmn2.createCallActivity(); CustomElement.async.of(callActivity).set(Boolean.TRUE); tested = new CallActivityPropertyReader(callActivity, definitionResolver.getDiagram(), definitionResolver); assertTrue(tested.isAsync()); } |
### Question:
CallActivityPropertyReader extends MultipleInstanceActivityPropertyReader { public String getSlaDueDate() { return CustomElement.slaDueDate.of(element).get(); } CallActivityPropertyReader(CallActivity callActivity, BPMNDiagram diagram, DefinitionResolver definitionResolver); String getCalledElement(); boolean isIndependent(); boolean isAbortParent(); boolean isWaitForCompletion(); boolean isAsync(); boolean isCase(); boolean isAdHocAutostart(); String getSlaDueDate(); }### Answer:
@Test public void testGetSlaDueDate() { String rawSlaDueDate = "12/25/1983"; CallActivity callActivity = bpmn2.createCallActivity(); CustomElement.slaDueDate.of(callActivity).set(rawSlaDueDate); tested = new CallActivityPropertyReader(callActivity, definitionResolver.getDiagram(), definitionResolver); assertTrue(tested.getSlaDueDate().contains(rawSlaDueDate)); } |
### Question:
DecisionComponentsItem { public DRGElement getDrgElement() { return getDecisionComponent().getDrgElement(); } @Inject DecisionComponentsItem(final View view); @PostConstruct void init(); View getView(); void setDecisionComponent(final DecisionComponent decisionComponent); void show(); void hide(); DRGElement getDrgElement(); }### Answer:
@Test public void testGetDrgElement() { final DecisionComponent decisionComponent = mock(DecisionComponent.class); final DRGElement expectedDrgElement = null; when(decisionComponent.getDrgElement()).thenReturn(expectedDrgElement); doReturn(decisionComponent).when(item).getDecisionComponent(); final DRGElement actualDrgElement = item.getDrgElement(); assertEquals(expectedDrgElement, actualDrgElement); } |
### Question:
DataObjectPropertyReader extends BasePropertyReader { public String getName() { return CustomElement.name.of(element).get(); } DataObjectPropertyReader(DataObjectReference ref, BPMNDiagram diagram,
BPMNShape shape,
double resolutionFactor); String getName(); String getType(); }### Answer:
@Test public void getExtendedName() { String name = tested.getName(); assertEquals("custom", name); }
@Test public void getName() { when(dataObject.getExtensionValues()).thenReturn(Collections.emptyList()); String name = tested.getName(); assertEquals("name", name); } |
### Question:
InputAssignmentReader { public AssociationDeclaration getAssociationDeclaration() { return associationDeclaration; } InputAssignmentReader(Assignment assignment, String targetName); InputAssignmentReader(ItemAwareElement source, String targetName); static InputAssignmentReader fromAssociation(DataInputAssociation in); AssociationDeclaration getAssociationDeclaration(); }### Answer:
@Test public void testNullBody() { final Assignment assignment = createAssignment(null); final InputAssignmentReader iar = new InputAssignmentReader(assignment, ID); final AssociationDeclaration associationDeclaration = iar.getAssociationDeclaration(); assertEquals(AssociationDeclaration.Type.FromTo, associationDeclaration.getType()); assertEquals("", associationDeclaration.getSource()); } |
### Question:
PropertyReaderUtils { public static Point2D getSourcePosition(DefinitionResolver definitionResolver, String edgeId, String sourceId) { final double resolutionFactor = definitionResolver.getResolutionFactor(); final Bounds sourceBounds = definitionResolver.getShape(sourceId).getBounds(); final List<Point> waypoint = definitionResolver.getEdge(edgeId).getWaypoint(); return waypoint.isEmpty() ? sourcePosition(sourceBounds, resolutionFactor) : offsetPosition(sourceBounds, waypoint.get(0), resolutionFactor); } static Point2D getSourcePosition(DefinitionResolver definitionResolver,
String edgeId,
String sourceId); static Point2D getTargetPosition(DefinitionResolver definitionResolver,
String edgeId,
String targetId); static List<Point2D> getControlPoints(DefinitionResolver definitionResolver,
String edgeId); static boolean isAutoConnectionSource(BaseElement element); static boolean isAutoConnectionTarget(BaseElement element); static WSDLImport toWSDLImports(Import imp); }### Answer:
@Test public void testGetSourcePositionWithNoWaypoint() { when(edge.getWaypoint()).thenReturn(Collections.emptyList()); Point2D point = PropertyReaderUtils.getSourcePosition(definitionResolver, EDGE_ID, SHAPE_ID); assertPoint(BOUNDS_WIDTH, BOUNDS_HEIGHT / 2, point); }
@Test public void testGetSourcePositionWithWaypoint() { when(edge.getWaypoint()).thenReturn(Collections.singletonList(point)); Point2D point = PropertyReaderUtils.getSourcePosition(definitionResolver, EDGE_ID, SHAPE_ID); assertPoint(WAY_POINT_X - BOUNDS_X, WAY_POINT_Y - BOUNDS_Y, point); } |
### Question:
PropertyReaderUtils { public static Point2D getTargetPosition(DefinitionResolver definitionResolver, String edgeId, String targetId) { final double resolutionFactor = definitionResolver.getResolutionFactor(); final Bounds targetBounds = definitionResolver.getShape(targetId).getBounds(); final List<Point> waypoint = definitionResolver.getEdge(edgeId).getWaypoint(); return waypoint.isEmpty() ? targetPosition(targetBounds, resolutionFactor) : offsetPosition(targetBounds, waypoint.get(waypoint.size() - 1), resolutionFactor); } static Point2D getSourcePosition(DefinitionResolver definitionResolver,
String edgeId,
String sourceId); static Point2D getTargetPosition(DefinitionResolver definitionResolver,
String edgeId,
String targetId); static List<Point2D> getControlPoints(DefinitionResolver definitionResolver,
String edgeId); static boolean isAutoConnectionSource(BaseElement element); static boolean isAutoConnectionTarget(BaseElement element); static WSDLImport toWSDLImports(Import imp); }### Answer:
@Test public void testGetTargetPositionWithNoWaypoint() { when(edge.getWaypoint()).thenReturn(Collections.emptyList()); Point2D point = PropertyReaderUtils.getTargetPosition(definitionResolver, EDGE_ID, SHAPE_ID); assertPoint(0, BOUNDS_HEIGHT / 2, point); }
@Test public void testGetTargetPositionWithWaypoint() { when(edge.getWaypoint()).thenReturn(Collections.singletonList(point)); Point2D point = PropertyReaderUtils.getTargetPosition(definitionResolver, EDGE_ID, SHAPE_ID); assertPoint(WAY_POINT_X - BOUNDS_X, WAY_POINT_Y - BOUNDS_Y, point); } |
### Question:
PropertyReaderUtils { public static List<Point2D> getControlPoints(DefinitionResolver definitionResolver, String edgeId) { final double resolutionFactor = definitionResolver.getResolutionFactor(); final List<Point> waypoint = definitionResolver.getEdge(edgeId).getWaypoint(); final List<Point2D> result = new ArrayList<>(); if (waypoint.size() > 2) { List<Point> points = waypoint.subList(1, waypoint.size() - 1); for (Point p : points) { result.add(createPoint2D(p, resolutionFactor)); } } return result; } static Point2D getSourcePosition(DefinitionResolver definitionResolver,
String edgeId,
String sourceId); static Point2D getTargetPosition(DefinitionResolver definitionResolver,
String edgeId,
String targetId); static List<Point2D> getControlPoints(DefinitionResolver definitionResolver,
String edgeId); static boolean isAutoConnectionSource(BaseElement element); static boolean isAutoConnectionTarget(BaseElement element); static WSDLImport toWSDLImports(Import imp); }### Answer:
@Test public void testGetControlPointsWhenZeroPoints() { when(edge.getWaypoint()).thenReturn(Collections.emptyList()); List<Point2D> result = PropertyReaderUtils.getControlPoints(definitionResolver, EDGE_ID); assertTrue(result.isEmpty()); }
@Test public void testGetControlPointsWhenOnePoints() { List<Point> waypoints = mockPoints(1, 2, 1); when(edge.getWaypoint()).thenReturn(waypoints); List<Point2D> result = PropertyReaderUtils.getControlPoints(definitionResolver, EDGE_ID); assertTrue(result.isEmpty()); }
@Test public void testGetControlPointsWhenTwoPoints() { List<Point> waypoints = mockPoints(1, 2, 2); when(edge.getWaypoint()).thenReturn(waypoints); List<Point2D> result = PropertyReaderUtils.getControlPoints(definitionResolver, EDGE_ID); assertTrue(result.isEmpty()); } |
### Question:
DecisionComponents { @PostConstruct public void init() { view.init(this); } DecisionComponents(); @Inject DecisionComponents(final View view,
final DMNIncludeModelsClient client,
final ManagedInstance<DecisionComponentsItem> itemManagedInstance,
final DecisionComponentFilter filter,
final DMNDiagramsSession dmnDiagramsSession,
final DMNGraphUtils dmnGraphUtils); @PostConstruct void init(); View getView(); void refresh(); void removeAllItems(); }### Answer:
@Test public void testInit() { decisionComponents.init(); verify(view).init(decisionComponents); } |
### Question:
PropertyReaderUtils { public static WSDLImport toWSDLImports(Import imp) { return new WSDLImport(imp.getLocation(), imp.getNamespace()); } static Point2D getSourcePosition(DefinitionResolver definitionResolver,
String edgeId,
String sourceId); static Point2D getTargetPosition(DefinitionResolver definitionResolver,
String edgeId,
String targetId); static List<Point2D> getControlPoints(DefinitionResolver definitionResolver,
String edgeId); static boolean isAutoConnectionSource(BaseElement element); static boolean isAutoConnectionTarget(BaseElement element); static WSDLImport toWSDLImports(Import imp); }### Answer:
@Test public void toWSDLImports() { final String LOCATION = "location"; final String NAMESPACE = "namespace"; WSDLImport wsdlImport = new WSDLImport(LOCATION, NAMESPACE); Import imp = PropertyWriterUtils.toImport(wsdlImport); WSDLImport result = PropertyReaderUtils.toWSDLImports(imp); assertEquals("location", result.getLocation()); assertEquals("namespace", result.getNamespace()); } |
### Question:
SimulationAttributeSets { public static SimulationAttributeSet of(ElementParameters eleType) { TimeParameters timeParams = eleType.getTimeParameters(); if (timeParams == null) { return new SimulationAttributeSet(); } Parameter processingTime = timeParams.getProcessingTime(); if (processingTime == null || processingTime.getParameterValue() == null || processingTime.getParameterValue().isEmpty()) { return new SimulationAttributeSet(); } ParameterValue paramValue = processingTime.getParameterValue().get(0); return Match.of(ParameterValue.class, SimulationAttributeSet.class) .when(NormalDistributionType.class, ndt -> { SimulationAttributeSet simulationSet = new SimulationAttributeSet(); simulationSet.getMean().setValue(ndt.getMean()); simulationSet.getStandardDeviation().setValue(ndt.getStandardDeviation()); simulationSet.getDistributionType().setValue("normal"); return simulationSet; }) .when(UniformDistributionType.class, udt -> { SimulationAttributeSet simulationSet = new SimulationAttributeSet(); simulationSet.getMin().setValue(udt.getMin()); simulationSet.getMax().setValue(udt.getMax()); simulationSet.getDistributionType().setValue("uniform"); return simulationSet; }) .when(PoissonDistributionType.class, pdt -> { SimulationAttributeSet simulationSet = new SimulationAttributeSet(); simulationSet.getMean().setValue(pdt.getMean()); simulationSet.getDistributionType().setValue("poisson"); return simulationSet; }) .apply(paramValue) .asSuccess() .value(); } private SimulationAttributeSets(); static SimulationAttributeSet of(ElementParameters eleType); static ElementParameters toElementParameters(SimulationAttributeSet simulationSet); }### Answer:
@Test public void testNullTimeParameters() { assertEquals(new SimulationAttributeSet(), SimulationAttributeSets.of(simulationParameters)); }
@Test public void testTimeParamsWithNullValue() { TimeParameters timeParameters = factory.createTimeParameters(); simulationParameters.setTimeParameters(timeParameters); assertEquals(new SimulationAttributeSet(), SimulationAttributeSets.of(simulationParameters)); }
@Test public void testTimeParamsWithEmptyParameter() { TimeParameters timeParameters = factory.createTimeParameters(); Parameter parameter = factory.createParameter(); timeParameters.setProcessingTime(parameter); simulationParameters.setTimeParameters(timeParameters); assertEquals(new SimulationAttributeSet(), SimulationAttributeSets.of(simulationParameters)); } |
### Question:
LanePropertyReader extends BasePropertyReader { public String getName() { String extendedName = CustomElement.name.of(element).get(); return extendedName.isEmpty() ? Optional.ofNullable(lane.getName()).orElse("") : extendedName; } LanePropertyReader(Lane el, BPMNDiagram diagram, BPMNShape shape, BPMNShape parentLaneShape, double resolutionFactor); LanePropertyReader(Lane el, BPMNDiagram diagram, BPMNShape shape, double resolutionFactor); String getName(); @Override RectangleDimensionsSet getRectangleDimensionsSet(); }### Answer:
@Test public void JBPM_7523_shouldPreserveNameChars() { PropertyReaderFactory factory = new PropertyReaderFactory( new TestDefinitionsWriter().getDefinitionResolver()); Lane lane = bpmn2.createLane(); PropertyWriterFactory writerFactory = new PropertyWriterFactory(); LanePropertyWriter w = writerFactory.of(lane); String aWeirdName = " XXX !!@@ <><> "; String aWeirdDoc = " XXX !!@@ <><> Docs "; w.setName(aWeirdName); w.setDocumentation(aWeirdDoc); LanePropertyReader r = factory.of(lane); assertThat(r.getName()).isEqualTo(asCData(aWeirdName)); assertThat(r.getDocumentation()).isEqualTo(asCData(aWeirdDoc)); }
@Test public void testGetNameFromExtensionElement() { List<ExtensionAttributeValue> extensionValues = mockExtensionValues(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, METADATA_ELEMENT_NAME, NAME); when(lane.getName()).thenReturn(null); when(lane.getExtensionValues()).thenReturn(extensionValues); LanePropertyReader propertyReader = new LanePropertyReader(lane, diagram, shape, RESOLUTION_FACTOR); assertEquals(NAME, propertyReader.getName()); }
@Test public void testGetNameFromNameValue() { LanePropertyReader propertyReader = new LanePropertyReader(lane, diagram, shape, RESOLUTION_FACTOR); when(lane.getExtensionValues()).thenReturn(null); when(lane.getName()).thenReturn(NAME); assertEquals(NAME, propertyReader.getName()); }
@Test public void testGetNameFromExtensionElement() { EList<ExtensionAttributeValue> extensionValues = mockExtensionValues(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, METADATA_ELEMENT_NAME, NAME); when(lane.getName()).thenReturn(null); when(lane.getExtensionValues()).thenReturn(extensionValues); LanePropertyReader propertyReader = new LanePropertyReader(lane, diagram, shape, RESOLUTION_FACTOR); assertEquals(NAME, propertyReader.getName()); } |
### Question:
LanePropertyReader extends BasePropertyReader { @Override public RectangleDimensionsSet getRectangleDimensionsSet() { if (shape == null || parentLaneShape == null) { return super.getRectangleDimensionsSet(); } org.eclipse.dd.dc.Bounds bounds = shape.getBounds(); return new RectangleDimensionsSet(parentLaneShape.getBounds().getWidth() * resolutionFactor, bounds.getHeight() * resolutionFactor); } LanePropertyReader(Lane el, BPMNDiagram diagram, BPMNShape shape, BPMNShape parentLaneShape, double resolutionFactor); LanePropertyReader(Lane el, BPMNDiagram diagram, BPMNShape shape, double resolutionFactor); String getName(); @Override RectangleDimensionsSet getRectangleDimensionsSet(); }### Answer:
@Test public void testGetRectangleDimensionsSet() { LanePropertyReader propertyReader = new LanePropertyReader(lane, diagram, shape, RESOLUTION_FACTOR); RectangleDimensionsSet dimensionsSet = propertyReader.getRectangleDimensionsSet(); assertRectangleDimensions(WIDTH * RESOLUTION_FACTOR, HEIGHT * RESOLUTION_FACTOR, dimensionsSet); }
@Test public void testGetRectangleDimensionsSetWithParentShape() { LanePropertyReader propertyReader = new LanePropertyReader(lane, diagram, shape, parentLaneShape, RESOLUTION_FACTOR); RectangleDimensionsSet dimensionsSet = propertyReader.getRectangleDimensionsSet(); assertRectangleDimensions(PARENT_WIDTH * RESOLUTION_FACTOR, HEIGHT * RESOLUTION_FACTOR, dimensionsSet); } |
### Question:
TextAnnotationPropertyReader extends BasePropertyReader { public String getName() { String extendedName = CustomElement.name.of(element).get(); return StringUtils.isEmpty(extendedName) ? Optional.ofNullable(element.getText()).orElse("") : extendedName; } TextAnnotationPropertyReader(TextAnnotation element, BPMNDiagram diagram,
BPMNShape shape,
double resolutionFactor); String getName(); }### Answer:
@Test public void getExtendedName() { String name = tested.getName(); assertEquals("custom", name); }
@Test public void getName() { when(element.getExtensionValues()).thenReturn(Collections.emptyList()); String name = tested.getName(); assertEquals("name", name); }
@Test public void getTextName() { when(element.getExtensionValues()).thenReturn(Collections.emptyList()); when(element.getName()).thenReturn(null); String name = tested.getName(); assertEquals("text", name); }
@Test public void getNameNull() { when(element.getExtensionValues()).thenReturn(Collections.emptyList()); when(element.getName()).thenReturn(null); when(element.getText()).thenReturn(null); String name = tested.getName(); assertEquals("", name); } |
### Question:
DecisionComponents { public View getView() { return view; } DecisionComponents(); @Inject DecisionComponents(final View view,
final DMNIncludeModelsClient client,
final ManagedInstance<DecisionComponentsItem> itemManagedInstance,
final DecisionComponentFilter filter,
final DMNDiagramsSession dmnDiagramsSession,
final DMNGraphUtils dmnGraphUtils); @PostConstruct void init(); View getView(); void refresh(); void removeAllItems(); }### Answer:
@Test public void testGetView() { assertEquals(view, decisionComponents.getView()); } |
### Question:
PropertyReaderFactory { public FlowElementPropertyReader of(FlowElement el) { return new FlowElementPropertyReader(el, diagram, definitionResolver.getShape(el.getId()), definitionResolver.getResolutionFactor()); } PropertyReaderFactory(DefinitionResolver definitionResolver); FlowElementPropertyReader of(FlowElement el); LanePropertyReader of(Lane el); LanePropertyReader of(Lane el, Lane elParent); SequenceFlowPropertyReader of(SequenceFlow el); AssociationPropertyReader of(Association el); GatewayPropertyReader of(Gateway el); TaskPropertyReader of(Task el); UserTaskPropertyReader of(UserTask el); ScriptTaskPropertyReader of(ScriptTask el); GenericServiceTaskPropertyReader of(ServiceTask el); BusinessRuleTaskPropertyReader of(BusinessRuleTask el); Optional<ServiceTaskPropertyReader> ofCustom(Task el); CallActivityPropertyReader of(CallActivity el); CatchEventPropertyReader of(CatchEvent el); ThrowEventPropertyReader of(ThrowEvent el); SubProcessPropertyReader of(SubProcess el); AdHocSubProcessPropertyReader of(AdHocSubProcess el); MultipleInstanceSubProcessPropertyReader ofMultipleInstance(SubProcess el); ProcessPropertyReader of(Process el); TextAnnotationPropertyReader of(TextAnnotation el); DefinitionsPropertyReader of(Definitions el); DataObjectPropertyReader of(DataObjectReference el); }### Answer:
@Test public void ofDefinition() { assertTrue(tested.of(definitions) instanceof DefinitionsPropertyReader); } |
### Question:
ItemNameReader { public String getName() { return name; } private ItemNameReader(ItemAwareElement element); static ItemNameReader from(ItemAwareElement element); String getName(); }### Answer:
@Test public void testGetPropertyName() { when(property.getName()).thenReturn(NAME); when(property.getId()).thenReturn(ID); testGetName(NAME, property); }
@Test public void testGetPropertyID() { when(property.getName()).thenReturn(null); when(property.getId()).thenReturn(ID); testGetName(ID, property); }
@Test public void testGetDataInputName() { when(dataInput.getName()).thenReturn(NAME); when(dataInput.getId()).thenReturn(ID); testGetName(NAME, dataInput); }
@Test public void testGetDataInputID() { when(dataInput.getName()).thenReturn(null); when(dataInput.getId()).thenReturn(ID); testGetName(ID, dataInput); }
@Test public void testGetDataOutputName() { when(dataOutput.getName()).thenReturn(NAME); when(dataOutput.getId()).thenReturn(ID); testGetName(NAME, dataOutput); }
@Test public void testGetDataOutputID() { when(dataOutput.getName()).thenReturn(null); when(dataOutput.getId()).thenReturn(ID); testGetName(ID, dataOutput); }
@Test public void testGetDataObject() { when(dataObject.getName()).thenReturn(null); when(dataObject.getId()).thenReturn(ID); testGetName(ID, dataObject); } |
### Question:
DecisionComponents { public void refresh() { if (!dmnDiagramsSession.isSessionStatePresent()) { return; } if (!isIncludedNodeListsUpdated()) { refreshIncludedNodesList(); } loadModelComponents(); } DecisionComponents(); @Inject DecisionComponents(final View view,
final DMNIncludeModelsClient client,
final ManagedInstance<DecisionComponentsItem> itemManagedInstance,
final DecisionComponentFilter filter,
final DMNDiagramsSession dmnDiagramsSession,
final DMNGraphUtils dmnGraphUtils); @PostConstruct void init(); View getView(); void refresh(); void removeAllItems(); }### Answer:
@Test public void testRefresh() { final Consumer<List<DMNIncludedNode>> listConsumer = (list) -> {}; final List<DMNIncludedModel> includedModels = new ArrayList<>(); includedModels.add(makeDMNIncludedModel(": includedModels.add(makeDMNIncludedModel(": doReturn(includedModels).when(decisionComponents).getDMNIncludedModels(); doReturn(listConsumer).when(decisionComponents).getNodesConsumer(); decisionComponents.refreshIncludedNodesList(); verify(decisionComponents).startLoading(); verify(client).loadNodesFromImports(includedModels, listConsumer); assertEquals(includedModels, decisionComponents.getLatestIncludedModelsLoaded()); } |
### Question:
MultipleInstanceActivityPropertyReader extends ActivityPropertyReader { public String getCollectionInput() { String ieDataInputId = getLoopDataInputRefId(); return super.getDataInputAssociations().stream() .filter(dia -> hasTargetRef(dia, ieDataInputId)) .filter(MultipleInstanceActivityPropertyReader::hasSourceRefs) .map(dia -> ItemNameReader.from(dia.getSourceRef().get(0)).getName()) .findFirst() .orElse(null); } MultipleInstanceActivityPropertyReader(Activity activity, BPMNDiagram diagram, DefinitionResolver definitionResolver); boolean isMultipleInstance(); String getCollectionInput(); String getCollectionOutput(); String getDataInput(); String getDataOutput(); String getCompletionCondition(); boolean isSequential(); }### Answer:
@Test public void testGetCollectionInput() { ItemAwareElement item = mockItemAwareElement(ITEM_ID); when(miloop.getLoopDataInputRef()).thenReturn(item); List<DataInputAssociation> inputAssociations = Collections.singletonList(mockDataInputAssociation(ITEM_ID, PROPERTY_ID)); when(activity.getDataInputAssociations()).thenReturn(inputAssociations); assertEquals(PROPERTY_ID, reader.getCollectionInput()); }
@Test public void testGetCollectionInput() { ItemAwareElement item = mockItemAwareElement(ITEM_ID); when(miloop.getLoopDataInputRef()).thenReturn(item); EList<DataInputAssociation> inputAssociations = ECollections.singletonEList(mockDataInputAssociation(ITEM_ID, PROPERTY_ID)); when(activity.getDataInputAssociations()).thenReturn(inputAssociations); assertEquals(PROPERTY_ID, reader.getCollectionInput()); } |
### Question:
MultipleInstanceActivityPropertyReader extends ActivityPropertyReader { public String getDataInput() { return getMultiInstanceLoopCharacteristics() .map(MultiInstanceLoopCharacteristics::getInputDataItem) .map(MultipleInstanceActivityPropertyReader::createInputVariable) .orElse(""); } MultipleInstanceActivityPropertyReader(Activity activity, BPMNDiagram diagram, DefinitionResolver definitionResolver); boolean isMultipleInstance(); String getCollectionInput(); String getCollectionOutput(); String getDataInput(); String getDataOutput(); String getCompletionCondition(); boolean isSequential(); }### Answer:
@Test public void testGetDataInput() { DataInput item = mockDataInput(ITEM_ID, PROPERTY_ID); when(miloop.getInputDataItem()).thenReturn(item); assertEquals(PROPERTY_ID + DELIMITER + DATA_TYPE, reader.getDataInput()); }
@Test public void testGetEmptyDataInput() { DataInput item = mockDataInput(ITEM_ID, null); when(miloop.getInputDataItem()).thenReturn(item); assertEquals(ITEM_ID + DELIMITER + DATA_TYPE, reader.getDataInput()); } |
### Question:
MultipleInstanceActivityPropertyReader extends ActivityPropertyReader { public String getDataOutput() { return getMultiInstanceLoopCharacteristics() .map(MultiInstanceLoopCharacteristics::getOutputDataItem) .map(MultipleInstanceActivityPropertyReader::createOutputVariable) .orElse(""); } MultipleInstanceActivityPropertyReader(Activity activity, BPMNDiagram diagram, DefinitionResolver definitionResolver); boolean isMultipleInstance(); String getCollectionInput(); String getCollectionOutput(); String getDataInput(); String getDataOutput(); String getCompletionCondition(); boolean isSequential(); }### Answer:
@Test public void testGetEmptyDataOutput() { DataOutput item = mockDataOutput(ITEM_ID, null); when(miloop.getOutputDataItem()).thenReturn(item); assertEquals(ITEM_ID + DELIMITER + DATA_TYPE, reader.getDataOutput()); }
@Test public void testGetDataOutput() { DataOutput item = mockDataOutput(ITEM_ID, PROPERTY_ID); when(miloop.getOutputDataItem()).thenReturn(item); assertEquals(PROPERTY_ID + DELIMITER + DATA_TYPE, reader.getDataOutput()); } |
### Question:
MultipleInstanceActivityPropertyReader extends ActivityPropertyReader { public String getCollectionOutput() { String ieDataOutputId = getLoopDataOutputRefId(); return super.getDataOutputAssociations().stream() .filter(doa -> hasSourceRef(doa, ieDataOutputId)) .map(doa -> ItemNameReader.from(doa.getTargetRef()).getName()) .findFirst() .orElse(null); } MultipleInstanceActivityPropertyReader(Activity activity, BPMNDiagram diagram, DefinitionResolver definitionResolver); boolean isMultipleInstance(); String getCollectionInput(); String getCollectionOutput(); String getDataInput(); String getDataOutput(); String getCompletionCondition(); boolean isSequential(); }### Answer:
@Test public void testGetCollectionOutput() { ItemAwareElement item = mockItemAwareElement(ITEM_ID); when(miloop.getLoopDataOutputRef()).thenReturn(item); List<DataOutputAssociation> outputAssociations = Collections.singletonList(mockDataOutputAssociation(ITEM_ID, PROPERTY_ID)); when(activity.getDataOutputAssociations()).thenReturn(outputAssociations); assertEquals(PROPERTY_ID, reader.getCollectionOutput()); }
@Test public void testGetCollectionOutput() { ItemAwareElement item = mockItemAwareElement(ITEM_ID); when(miloop.getLoopDataOutputRef()).thenReturn(item); EList<DataOutputAssociation> outputAssociations = ECollections.singletonEList(mockDataOutputAssociation(ITEM_ID, PROPERTY_ID)); when(activity.getDataOutputAssociations()).thenReturn(outputAssociations); assertEquals(PROPERTY_ID, reader.getCollectionOutput()); } |
### Question:
MultipleInstanceActivityPropertyReader extends ActivityPropertyReader { public String getCompletionCondition() { return getMultiInstanceLoopCharacteristics() .map(miloop -> (FormalExpression) miloop.getCompletionCondition()) .map(FormalExpression::getBody) .orElse(""); } MultipleInstanceActivityPropertyReader(Activity activity, BPMNDiagram diagram, DefinitionResolver definitionResolver); boolean isMultipleInstance(); String getCollectionInput(); String getCollectionOutput(); String getDataInput(); String getDataOutput(); String getCompletionCondition(); boolean isSequential(); }### Answer:
@Test public void getGetCompletionCondition() { FormalExpression expression = mock(FormalExpression.class); when(expression.getBody()).thenReturn(EXPRESSION); when(miloop.getCompletionCondition()).thenReturn(expression); assertEquals(EXPRESSION, reader.getCompletionCondition()); } |
### Question:
GenericServiceTaskPropertyReader extends MultipleInstanceActivityPropertyReader { public GenericServiceTaskValue getGenericServiceTask() { GenericServiceTaskValue value = new GenericServiceTaskValue(); final String implementation = Optional.ofNullable(CustomAttribute.serviceImplementation.of(task).get()) .filter(StringUtils::nonEmpty) .orElseGet(() -> task.getImplementation()); value.setServiceImplementation(getServiceImplementation(implementation)); final String operation = Optional.ofNullable(CustomAttribute.serviceOperation.of(task).get()) .filter(StringUtils::nonEmpty) .orElseGet(() -> Optional .ofNullable(task.getOperationRef()) .map(Operation::getName) .orElse(null)); value.setServiceOperation(operation); value.setInMessageStructure(Optional.ofNullable(task.getOperationRef()) .map(Operation::getInMessageRef) .map(Message::getItemRef) .map(ItemDefinition::getStructureRef) .orElse(null)); value.setOutMessagetructure(Optional.ofNullable(task.getOperationRef()) .map(Operation::getOutMessageRef) .map(Message::getItemRef) .map(ItemDefinition::getStructureRef) .orElse(null)); final String serviceInterface = Optional.ofNullable(CustomAttribute.serviceInterface.of(task).get()) .filter(StringUtils::nonEmpty) .orElseGet(() -> Optional .ofNullable(task.getOperationRef()) .map(Operation::eContainer) .filter(container -> container instanceof Interface) .map(container -> (Interface) container) .map(Interface::getName) .orElse(null)); value.setServiceInterface(serviceInterface); return value; } GenericServiceTaskPropertyReader(ServiceTask task, BPMNDiagram diagram, DefinitionResolver definitionResolver); GenericServiceTaskValue getGenericServiceTask(); static String getServiceImplementation(String implementation); boolean isAsync(); boolean isAdHocAutostart(); String getSLADueDate(); static final String JAVA; static final String WEB_SERVICE; }### Answer:
@Test public void getGenericServiceTask() { GenericServiceTaskValue task = reader.getGenericServiceTask(); assertEquals("Java", task.getServiceImplementation()); assertEquals("serviceOperation", task.getServiceOperation()); assertEquals("serviceInterface", task.getServiceInterface()); assertEquals("inMessageStructure", task.getInMessageStructure()); assertEquals("outMessageStructure", task.getOutMessagetructure()); assertEquals(SLA_DUE_DATE_CDATA, reader.getSLADueDate()); assertEquals(false, reader.isAsync()); assertEquals(true, reader.isAdHocAutostart()); assertNotNull(reader.getOnEntryAction()); assertNotNull(reader.getOnExitAction()); assertNotNull(reader.getAssignmentsInfo()); }
@Test public void getGenericServiceTask() { GenericServiceTaskValue task = reader.getGenericServiceTask(); assertEquals("Java", task.getServiceImplementation()); assertEquals("serviceOperation", task.getServiceOperation()); assertEquals("serviceInterface", task.getServiceInterface()); assertEquals(SLA_DUE_DATE_CDATA, reader.getSLADueDate()); assertEquals(false, reader.isAsync()); assertEquals(true, reader.isAdHocAutostart()); assertNotNull(reader.getOnEntryAction()); assertNotNull(reader.getOnExitAction()); assertNotNull(reader.getAssignmentsInfo()); } |
### Question:
ProcessVariableReader { static String getProcessVariables(List<Property> properties) { return properties .stream() .filter(ProcessVariableReader::isProcessVariable) .map(ProcessVariableReader::toProcessVariableString) .collect(Collectors.joining(",")); } static String getProcessVariableName(Property p); static boolean isProcessVariable(Property p); }### Answer:
@Test public void getProcessVariables() { String result = ProcessVariableReader.getProcessVariables(properties); assertEquals("PV1:Boolean:<![CDATA[internal;input;customTag]]>,PV2::[],PV3::[]", result); } |
### Question:
DecisionComponents { void loadModelComponents() { final String dmnModelName = dmnGraphUtils.getModelDefinitions().getName().getValue(); final List<DRGElement> dmnModelDRGElements = dmnDiagramsSession.getModelDRGElements(); getModelDRGElements().clear(); dmnModelDRGElements.forEach(drgElement -> { getModelDRGElements().add(makeDecisionComponent(dmnModelName, drgElement)); }); refreshView(); } DecisionComponents(); @Inject DecisionComponents(final View view,
final DMNIncludeModelsClient client,
final ManagedInstance<DecisionComponentsItem> itemManagedInstance,
final DecisionComponentFilter filter,
final DMNDiagramsSession dmnDiagramsSession,
final DMNGraphUtils dmnGraphUtils); @PostConstruct void init(); View getView(); void refresh(); void removeAllItems(); }### Answer:
@Test public void testLoadModelComponents() { final String dmnModelName = "ModelName"; final DRGElement drgElement1 = mock(DRGElement.class); final DRGElement drgElement2 = mock(DRGElement.class); final DecisionComponent decisionComponent1 = mock(DecisionComponent.class); final DecisionComponent decisionComponent2 = mock(DecisionComponent.class); final List<DecisionComponent> decisionComponentsList = new ArrayList<>(); final Definitions definitions = mock(Definitions.class); when(definitions.getName()).thenReturn(new Name(dmnModelName)); when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions); when(dmnDiagramsSession.getModelDRGElements()).thenReturn(Arrays.asList(drgElement1, drgElement2)); when(drgElement1.getName()).thenReturn(new Name("Decision-1")); when(drgElement2.getName()).thenReturn(new Name("Decision-2")); when(decisionComponent1.getName()).thenReturn("Decision-1"); when(decisionComponent2.getName()).thenReturn("Decision-2"); doReturn(decisionComponent1).when(decisionComponents).makeDecisionComponent(dmnModelName, drgElement1); doReturn(decisionComponent2).when(decisionComponents).makeDecisionComponent(dmnModelName, drgElement2); doReturn(decisionComponentsList).when(decisionComponents).getModelDRGElements(); doNothing().when(decisionComponents).refreshView(); decisionComponents.loadModelComponents(); assertTrue(decisionComponentsList.contains(decisionComponent1)); assertTrue(decisionComponentsList.contains(decisionComponent2)); assertEquals(2, decisionComponentsList.size()); verify(decisionComponents).refreshView(); } |
### Question:
ProcessVariableReader { public static String getProcessVariableName(Property p) { String name = p.getName(); return name == null || name.isEmpty() ? p.getId() : name; } static String getProcessVariableName(Property p); static boolean isProcessVariable(Property p); }### Answer:
@Test public void getProcessVariableName() { assertEquals("PV1", ProcessVariableReader.getProcessVariableName(property1)); assertEquals("PV2", ProcessVariableReader.getProcessVariableName(property2)); assertEquals("PV3", ProcessVariableReader.getProcessVariableName(property3)); assertEquals("caseFile_CV4", ProcessVariableReader.getProcessVariableName(property4)); assertEquals("caseFile_CV5", ProcessVariableReader.getProcessVariableName(property5)); } |
### Question:
ProcessVariableReader { public static boolean isProcessVariable(Property p) { return !CaseFileVariableReader.isCaseFileVariable(p); } static String getProcessVariableName(Property p); static boolean isProcessVariable(Property p); }### Answer:
@Test public void isProcessVariable() { assertTrue(ProcessVariableReader.isProcessVariable(property1)); assertTrue(ProcessVariableReader.isProcessVariable(property2)); assertTrue(ProcessVariableReader.isProcessVariable(property3)); assertFalse(ProcessVariableReader.isProcessVariable(property4)); assertFalse(ProcessVariableReader.isProcessVariable(property5)); } |
### Question:
BasePropertyReader implements PropertyReader { @Override public Bounds getBounds() { if (shape == null) { return Bounds.create(); } return computeBounds(shape.getBounds()); } BasePropertyReader(final BaseElement element,
final BPMNDiagram diagram,
final BPMNShape shape,
final double resolutionFactor); @Override String getDocumentation(); @Override String getDescription(); @Override FontSet getFontSet(); @Override BackgroundSet getBackgroundSet(); @Override Bounds getBounds(); @Override CircleDimensionSet getCircleDimensionSet(); @Override RectangleDimensionsSet getRectangleDimensionsSet(); @Override boolean isExpanded(); @Override BaseElement getElement(); @Override BPMNShape getShape(); }### Answer:
@Test public void testBounds() { Bounds bounds = tested.getBounds(); assertTrue(bounds.hasLowerRight()); assertTrue(bounds.hasUpperLeft()); assertEquals(0.7150000154972077d, bounds.getUpperLeft().getX(), 0d); assertEquals(1.4300000309944154d, bounds.getUpperLeft().getY(), 0d); assertEquals(65.71500001549721d, bounds.getLowerRight().getX(), 0d); assertEquals(355.9010174870491d, bounds.getLowerRight().getY(), 0d); } |
### Question:
BasePropertyReader implements PropertyReader { @Override public CircleDimensionSet getCircleDimensionSet() { if (shape == null) { return new CircleDimensionSet(); } return new CircleDimensionSet(new Radius( shape.getBounds().getWidth() * resolutionFactor / 2d)); } BasePropertyReader(final BaseElement element,
final BPMNDiagram diagram,
final BPMNShape shape,
final double resolutionFactor); @Override String getDocumentation(); @Override String getDescription(); @Override FontSet getFontSet(); @Override BackgroundSet getBackgroundSet(); @Override Bounds getBounds(); @Override CircleDimensionSet getCircleDimensionSet(); @Override RectangleDimensionsSet getRectangleDimensionsSet(); @Override boolean isExpanded(); @Override BaseElement getElement(); @Override BPMNShape getShape(); }### Answer:
@Test public void testGetCircleDimensionSet() { CircleDimensionSet circleDimensionSet = tested.getCircleDimensionSet(); assertEquals(32.5d, circleDimensionSet.getRadius().getValue(), 0d); } |
### Question:
BasePropertyReader implements PropertyReader { @Override public RectangleDimensionsSet getRectangleDimensionsSet() { if (shape == null) { return new RectangleDimensionsSet(); } org.eclipse.dd.dc.Bounds bounds = shape.getBounds(); return new RectangleDimensionsSet(bounds.getWidth() * resolutionFactor, bounds.getHeight() * resolutionFactor); } BasePropertyReader(final BaseElement element,
final BPMNDiagram diagram,
final BPMNShape shape,
final double resolutionFactor); @Override String getDocumentation(); @Override String getDescription(); @Override FontSet getFontSet(); @Override BackgroundSet getBackgroundSet(); @Override Bounds getBounds(); @Override CircleDimensionSet getCircleDimensionSet(); @Override RectangleDimensionsSet getRectangleDimensionsSet(); @Override boolean isExpanded(); @Override BaseElement getElement(); @Override BPMNShape getShape(); }### Answer:
@Test public void testGetRectangleDimensionsSet() { RectangleDimensionsSet rectangleDimensionsSet = tested.getRectangleDimensionsSet(); assertEquals(65.0d, rectangleDimensionsSet.getWidth().getValue(), 0d); assertEquals(354.4710174560547d, rectangleDimensionsSet.getHeight().getValue(), 0d); } |
### Question:
BasePropertyReader implements PropertyReader { @Override public boolean isExpanded() { return shape.isIsExpanded(); } BasePropertyReader(final BaseElement element,
final BPMNDiagram diagram,
final BPMNShape shape,
final double resolutionFactor); @Override String getDocumentation(); @Override String getDescription(); @Override FontSet getFontSet(); @Override BackgroundSet getBackgroundSet(); @Override Bounds getBounds(); @Override CircleDimensionSet getCircleDimensionSet(); @Override RectangleDimensionsSet getRectangleDimensionsSet(); @Override boolean isExpanded(); @Override BaseElement getElement(); @Override BPMNShape getShape(); }### Answer:
@Test public void testIsExpandedTrue() { when(shape.isIsExpanded()).thenReturn(true); assertTrue(tested.isExpanded()); } |
### Question:
BasePropertyReader implements PropertyReader { @Override public BaseElement getElement() { return element; } BasePropertyReader(final BaseElement element,
final BPMNDiagram diagram,
final BPMNShape shape,
final double resolutionFactor); @Override String getDocumentation(); @Override String getDescription(); @Override FontSet getFontSet(); @Override BackgroundSet getBackgroundSet(); @Override Bounds getBounds(); @Override CircleDimensionSet getCircleDimensionSet(); @Override RectangleDimensionsSet getRectangleDimensionsSet(); @Override boolean isExpanded(); @Override BaseElement getElement(); @Override BPMNShape getShape(); }### Answer:
@Test public void testGetElement() { assertEquals(element, tested.getElement()); } |
### Question:
BasePropertyReader implements PropertyReader { @Override public BPMNShape getShape() { return shape; } BasePropertyReader(final BaseElement element,
final BPMNDiagram diagram,
final BPMNShape shape,
final double resolutionFactor); @Override String getDocumentation(); @Override String getDescription(); @Override FontSet getFontSet(); @Override BackgroundSet getBackgroundSet(); @Override Bounds getBounds(); @Override CircleDimensionSet getCircleDimensionSet(); @Override RectangleDimensionsSet getRectangleDimensionsSet(); @Override boolean isExpanded(); @Override BaseElement getElement(); @Override BPMNShape getShape(); }### Answer:
@Test public void testGetShape() { assertEquals(shape, tested.getShape()); } |
### Question:
AssociationPropertyReader extends BasePropertyReader implements EdgePropertyReader { @Override public String getSourceId() { return association.getSourceRef().getId(); } AssociationPropertyReader(Association association,
BPMNDiagram diagram,
DefinitionResolver definitionResolver); @Override String getSourceId(); @Override String getTargetId(); Class<? extends org.kie.workbench.common.stunner.bpmn.definition.Association> getAssociationByDirection(); @Override Connection getSourceConnection(); @Override Connection getTargetConnection(); @Override List<Point2D> getControlPoints(); @Override DefinitionResolver getDefinitionResolver(); }### Answer:
@Test public void testGetSourceId() { assertEquals(SOURCE_ID, propertyReader.getSourceId()); } |
### Question:
AssociationPropertyReader extends BasePropertyReader implements EdgePropertyReader { @Override public String getTargetId() { return association.getTargetRef().getId(); } AssociationPropertyReader(Association association,
BPMNDiagram diagram,
DefinitionResolver definitionResolver); @Override String getSourceId(); @Override String getTargetId(); Class<? extends org.kie.workbench.common.stunner.bpmn.definition.Association> getAssociationByDirection(); @Override Connection getSourceConnection(); @Override Connection getTargetConnection(); @Override List<Point2D> getControlPoints(); @Override DefinitionResolver getDefinitionResolver(); }### Answer:
@Test public void testGetTargetId() { assertEquals(TARGET_ID, propertyReader.getTargetId()); } |
### Question:
DecisionComponents { List<DMNIncludedModel> getDMNIncludedModels() { return dmnDiagramsSession .getModelImports() .stream() .filter(anImport -> Objects.equals(DMNImportTypes.DMN, determineImportType(anImport.getImportType()))) .map(this::asDMNIncludedModel) .collect(Collectors.toList()); } DecisionComponents(); @Inject DecisionComponents(final View view,
final DMNIncludeModelsClient client,
final ManagedInstance<DecisionComponentsItem> itemManagedInstance,
final DecisionComponentFilter filter,
final DMNDiagramsSession dmnDiagramsSession,
final DMNGraphUtils dmnGraphUtils); @PostConstruct void init(); View getView(); void refresh(); void removeAllItems(); }### Answer:
@Test public void testGetDMNIncludedModelsOnlyIncludesDMN() { final ImportDMN dmnImport = new ImportDMN(); final ImportPMML pmmlImport = new ImportPMML(); dmnImport.getName().setValue("dmn"); dmnImport.setImportType(DMNImportTypes.DMN.getDefaultNamespace()); pmmlImport.setImportType(DMNImportTypes.PMML.getDefaultNamespace()); when(dmnDiagramsSession.getModelImports()).thenReturn(asList(dmnImport, pmmlImport)); final List<DMNIncludedModel> includedModels = decisionComponents.getDMNIncludedModels(); assertThat(includedModels).hasSize(1); assertThat(includedModels.get(0).getModelName()).isEqualTo("dmn"); assertThat(includedModels.get(0).getImportType()).isEqualTo(DMNImportTypes.DMN.getDefaultNamespace()); } |
### Question:
AssociationPropertyReader extends BasePropertyReader implements EdgePropertyReader { @Override public Connection getSourceConnection() { Point2D sourcePosition = PropertyReaderUtils.getSourcePosition(definitionResolver, element.getId(), getSourceId()); return MagnetConnection.Builder .at(sourcePosition.getX(), sourcePosition.getY()) .setAuto(PropertyReaderUtils.isAutoConnectionSource(element)); } AssociationPropertyReader(Association association,
BPMNDiagram diagram,
DefinitionResolver definitionResolver); @Override String getSourceId(); @Override String getTargetId(); Class<? extends org.kie.workbench.common.stunner.bpmn.definition.Association> getAssociationByDirection(); @Override Connection getSourceConnection(); @Override Connection getTargetConnection(); @Override List<Point2D> getControlPoints(); @Override DefinitionResolver getDefinitionResolver(); }### Answer:
@Test public void testGetSourceConnection() { mockStatic(PropertyReaderUtils.class); PowerMockito.when(PropertyReaderUtils.getSourcePosition(definitionResolver, ASSOCIATION_ID, SOURCE_ID)).thenReturn(position); boolean arbitraryBoolean = true; PowerMockito.when(PropertyReaderUtils.isAutoConnectionSource(association)).thenReturn(arbitraryBoolean); Connection result = propertyReader.getSourceConnection(); assertEquals(X, result.getLocation().getX(), 0); assertEquals(Y, result.getLocation().getY(), 0); } |
### Question:
AssociationPropertyReader extends BasePropertyReader implements EdgePropertyReader { @Override public Connection getTargetConnection() { Point2D targetPosition = PropertyReaderUtils.getTargetPosition(definitionResolver, element.getId(), getTargetId()); return MagnetConnection.Builder .at(targetPosition.getX(), targetPosition.getY()) .setAuto(PropertyReaderUtils.isAutoConnectionTarget(element)); } AssociationPropertyReader(Association association,
BPMNDiagram diagram,
DefinitionResolver definitionResolver); @Override String getSourceId(); @Override String getTargetId(); Class<? extends org.kie.workbench.common.stunner.bpmn.definition.Association> getAssociationByDirection(); @Override Connection getSourceConnection(); @Override Connection getTargetConnection(); @Override List<Point2D> getControlPoints(); @Override DefinitionResolver getDefinitionResolver(); }### Answer:
@Test public void testGetTargetConnection() { mockStatic(PropertyReaderUtils.class); PowerMockito.when(PropertyReaderUtils.getTargetPosition(definitionResolver, ASSOCIATION_ID, TARGET_ID)).thenReturn(position); boolean arbitraryBoolean = true; PowerMockito.when(PropertyReaderUtils.isAutoConnectionSource(association)).thenReturn(arbitraryBoolean); Connection result = propertyReader.getTargetConnection(); assertEquals(X, result.getLocation().getX(), 0); assertEquals(Y, result.getLocation().getY(), 0); } |
### Question:
AssociationPropertyReader extends BasePropertyReader implements EdgePropertyReader { public Class<? extends org.kie.workbench.common.stunner.bpmn.definition.Association> getAssociationByDirection() { return Optional.ofNullable(association.getAssociationDirection()) .filter(d -> !AssociationDirection.NONE.equals(d)) .<Class<? extends org.kie.workbench.common.stunner.bpmn.definition.Association>>map(d -> DirectionalAssociation.class) .orElse(NonDirectionalAssociation.class); } AssociationPropertyReader(Association association,
BPMNDiagram diagram,
DefinitionResolver definitionResolver); @Override String getSourceId(); @Override String getTargetId(); Class<? extends org.kie.workbench.common.stunner.bpmn.definition.Association> getAssociationByDirection(); @Override Connection getSourceConnection(); @Override Connection getTargetConnection(); @Override List<Point2D> getControlPoints(); @Override DefinitionResolver getDefinitionResolver(); }### Answer:
@Test public void testGetAssociationByDirection() { final Association association = Bpmn2Factory.eINSTANCE.createAssociation(); association.setAssociationDirection(null); propertyReader = new AssociationPropertyReader(association, bpmnDiagram, definitionResolver); assertEquals(NonDirectionalAssociation.class, propertyReader.getAssociationByDirection()); association.setAssociationDirection(AssociationDirection.NONE); assertEquals(NonDirectionalAssociation.class, propertyReader.getAssociationByDirection()); association.setAssociationDirection(AssociationDirection.ONE); assertEquals(DirectionalAssociation.class, propertyReader.getAssociationByDirection()); } |
### Question:
AssociationPropertyReader extends BasePropertyReader implements EdgePropertyReader { @Override public List<Point2D> getControlPoints() { return PropertyReaderUtils.getControlPoints(definitionResolver, element.getId()); } AssociationPropertyReader(Association association,
BPMNDiagram diagram,
DefinitionResolver definitionResolver); @Override String getSourceId(); @Override String getTargetId(); Class<? extends org.kie.workbench.common.stunner.bpmn.definition.Association> getAssociationByDirection(); @Override Connection getSourceConnection(); @Override Connection getTargetConnection(); @Override List<Point2D> getControlPoints(); @Override DefinitionResolver getDefinitionResolver(); }### Answer:
@Test @SuppressWarnings("unchecked") public void testGetControlPoints() { List<Point2D> controlPoints = mock(List.class); mockStatic(PropertyReaderUtils.class); PowerMockito.when(PropertyReaderUtils.getControlPoints(definitionResolver, ASSOCIATION_ID)).thenReturn(controlPoints); assertEquals(controlPoints, propertyReader.getControlPoints()); } |
### Question:
CaseFileVariableReader { static String getCaseFileVariables(List<Property> properties) { return properties .stream() .filter(CaseFileVariableReader::isCaseFileVariable) .map(CaseFileVariableReader::toCaseFileVariableString) .collect(Collectors.joining(",")); } static boolean isCaseFileVariable(Property p); }### Answer:
@Test public void getCaseFileVariables() { String caseFileVariables = CaseFileVariableReader.getCaseFileVariables(properties); assertEquals(caseFileVariables, "CFV1:Boolean,CFV2:Boolean"); } |
### Question:
CaseFileVariableReader { public static boolean isCaseFileVariable(Property p) { String name = getCaseFileVariableName(p); return name.startsWith(CaseFileVariables.CASE_FILE_PREFIX); } static boolean isCaseFileVariable(Property p); }### Answer:
@Test public void isCaseFileVariable() { boolean isCaseFile1 = CaseFileVariableReader.isCaseFileVariable(property1); assertTrue(isCaseFile1); boolean isCaseFile2 = CaseFileVariableReader.isCaseFileVariable(property2); assertTrue(isCaseFile2); boolean isCaseFile3 = CaseFileVariableReader.isCaseFileVariable(property3); assertFalse(isCaseFile3); boolean isCaseFile4 = CaseFileVariableReader.isCaseFileVariable(property4); assertFalse(isCaseFile4); } |
### Question:
AssignmentsInfos { public static ParsedAssignmentsInfo parsed( List<DataInput> datainput, List<DataInputAssociation> inputAssociations, List<DataOutput> dataoutput, List<DataOutputAssociation> outputAssociations, boolean alternativeEncoding) { DeclarationList inputs = dataInputDeclarations(datainput); DeclarationList outputs = dataOutputDeclarations(dataoutput); AssociationList associations = new AssociationList( inAssociationDeclarations(inputAssociations), outAssociationDeclarations(outputAssociations)); return new ParsedAssignmentsInfo( inputs, outputs, associations, alternativeEncoding); } static AssignmentsInfo of(
final List<DataInput> datainput,
final List<DataInputAssociation> inputAssociations,
final List<DataOutput> dataoutput,
final List<DataOutputAssociation> outputAssociations,
boolean alternativeEncoding); static ParsedAssignmentsInfo parsed(
List<DataInput> datainput,
List<DataInputAssociation> inputAssociations,
List<DataOutput> dataoutput,
List<DataOutputAssociation> outputAssociations,
boolean alternativeEncoding); static boolean isReservedDeclaration(DataInput o); static boolean isReservedIdentifier(String targetName); }### Answer:
@Test public void JBPM_7447_shouldNotFilterOutDataOutputsWithEmptyType() { DataInput dataInput = bpmn2.createDataInput(); dataInput.setName("InputName"); dataInput.setId("InputID"); DataOutput dataOutput = bpmn2.createDataOutput(); dataOutput.setName("OutputName"); dataOutput.setId("OutputID"); ParsedAssignmentsInfo result = AssignmentsInfos.parsed( Collections.singletonList(dataInput), Collections.emptyList(), Collections.singletonList(dataOutput), Collections.emptyList(), false ); assertThat(result.getOutputs().getDeclarations()).isNotEmpty(); }
@Test public void JBPM_7447_shouldNotFilterOutDataOutputsWithEmptyType() { DataInput dataInput = bpmn2.createDataInput(); dataInput.setName("InputName"); dataInput.setId("InputID"); DataOutput dataOutput = bpmn2.createDataOutput(); dataOutput.setName("OutputName"); dataOutput.setId("OutputID"); ParsedAssignmentsInfo result = AssignmentsInfos.parsed( Collections.singletonList(dataInput), Collections.emptyList(), Collections.singletonList(dataOutput), Collections.emptyList(), false ); assertFalse(result.getOutputs().getDeclarations().isEmpty()); } |
### Question:
DefinitionsPropertyReader extends BasePropertyReader { public List<WSDLImport> getWSDLImports() { return definitions.getImports().stream() .map(PropertyReaderUtils::toWSDLImports) .collect(Collectors.toList()); } DefinitionsPropertyReader(Definitions element, BPMNDiagram diagram, BPMNShape shape, double resolutionFactor); List<WSDLImport> getWSDLImports(); }### Answer:
@Test public void getWSDLImports() { final String LOCATION = "location"; final String NAMESPACE = "namespace"; final int QTY = 10; for (int i = 0; i < QTY; i++) { Import imp = PropertyWriterUtils.toImport(new WSDLImport(LOCATION + i, NAMESPACE + i)); definitions.getImports().add(imp); } List<WSDLImport> wsdlImports = tested.getWSDLImports(); assertEquals(QTY, wsdlImports.size()); for (int i = 0; i < QTY; i++) { assertEquals(LOCATION + i, wsdlImports.get(i).getLocation()); assertEquals(NAMESPACE + i, wsdlImports.get(i).getNamespace()); } } |
### Question:
ProcessPropertyReader extends BasePropertyReader { public List<DefaultImport> getDefaultImports() { return CustomElement.defaultImports.of(process).get(); } ProcessPropertyReader(Process element, BPMNDiagram diagram, BPMNShape shape, double resolutionFactor); String getPackage(); String getProcessType(); String getVersion(); boolean isAdHoc(); @Override Bounds getBounds(); String getProcessVariables(); String getCaseIdPrefix(); String getCaseFileVariables(); String getCaseRoles(); FlowElement getFlowElement(String id); String getGlobalVariables(); String getMetaDataAttributes(); List<DefaultImport> getDefaultImports(); String getSlaDueDate(); }### Answer:
@Test public void getDefaultImports() { final String CLASS_NAME = "className"; final int QTY = 10; List<DefaultImport> defaultImports = new ArrayList<>(); for (int i = 0; i < QTY; i++) { defaultImports.add(new DefaultImport(CLASS_NAME + i)); } CustomElement.defaultImports.of(process).set(defaultImports); List<DefaultImport> result = tested.getDefaultImports(); assertEquals(QTY, result.size()); for (int i = 0; i < result.size(); i++) { assertEquals(CLASS_NAME + i, result.get(i).getClassName()); } } |
### Question:
ProcessPropertyReader extends BasePropertyReader { public String getProcessType() { return process.getProcessType().getName(); } ProcessPropertyReader(Process element, BPMNDiagram diagram, BPMNShape shape, double resolutionFactor); String getPackage(); String getProcessType(); String getVersion(); boolean isAdHoc(); @Override Bounds getBounds(); String getProcessVariables(); String getCaseIdPrefix(); String getCaseFileVariables(); String getCaseRoles(); FlowElement getFlowElement(String id); String getGlobalVariables(); String getMetaDataAttributes(); List<DefaultImport> getDefaultImports(); String getSlaDueDate(); }### Answer:
@Test public void getProcessType() { ProcessPropertyWriter writer = new ProcessPropertyWriter( bpmn2.createProcess(), null, null); writer.setType(ProcessType.PRIVATE.getName()); tested = new ProcessPropertyReader(writer.getProcess(), definitionResolver.getDiagram(), definitionResolver.getShape(process.getId()), definitionResolver.getResolutionFactor()); assertEquals(tested.getProcessType(), ProcessType.PRIVATE.getName()); writer.setType(ProcessType.PUBLIC.getName()); tested = new ProcessPropertyReader(writer.getProcess(), definitionResolver.getDiagram(), definitionResolver.getShape(process.getId()), definitionResolver.getResolutionFactor()); assertEquals(tested.getProcessType(), ProcessType.PUBLIC.getName()); writer.setType(ProcessType.NONE.getName()); tested = new ProcessPropertyReader(writer.getProcess(), definitionResolver.getDiagram(), definitionResolver.getShape(process.getId()), definitionResolver.getResolutionFactor()); assertEquals(tested.getProcessType(), ProcessType.NONE.getName()); } |
### Question:
DecisionComponents { void applyTermFilter(final String value) { getFilter().setTerm(value); applyFilter(); } DecisionComponents(); @Inject DecisionComponents(final View view,
final DMNIncludeModelsClient client,
final ManagedInstance<DecisionComponentsItem> itemManagedInstance,
final DecisionComponentFilter filter,
final DMNDiagramsSession dmnDiagramsSession,
final DMNGraphUtils dmnGraphUtils); @PostConstruct void init(); View getView(); void refresh(); void removeAllItems(); }### Answer:
@Test public void testApplyTermFilter() { final String value = "value"; doNothing().when(decisionComponents).applyFilter(); decisionComponents.applyTermFilter(value); verify(filter).setTerm(value); verify(decisionComponents).applyFilter(); } |
### Question:
ScriptTaskPropertyReader extends TaskPropertyReader { public ScriptTypeValue getScript() { return new ScriptTypeValue( Scripts.scriptLanguageFromUri(task.getScriptFormat(), Scripts.LANGUAGE.JAVA.language()), Optional.ofNullable(task.getScript()).orElse(null) ); } ScriptTaskPropertyReader(ScriptTask task, BPMNDiagram diagram, DefinitionResolver definitionResolver); ScriptTypeValue getScript(); boolean isAsync(); boolean isAdHocAutoStart(); }### Answer:
@Test public void testGetScript() { for (Scripts.LANGUAGE language : Scripts.LANGUAGE.values()) { testGetScript(new ScriptTypeValue(language.language(), SCRIPT), language.format(), SCRIPT); } } |
### Question:
AdHocSubProcessPropertyReader extends SubProcessPropertyReader { public ScriptTypeValue getAdHocCompletionCondition() { if (process.getCompletionCondition() instanceof FormalExpression) { FormalExpression completionCondition = (FormalExpression) process.getCompletionCondition(); return new ScriptTypeValue( Scripts.scriptLanguageFromUri(completionCondition.getLanguage(), Scripts.LANGUAGE.MVEL.language()), completionCondition.getBody() ); } else { return new ScriptTypeValue(Scripts.LANGUAGE.MVEL.language(), "autocomplete"); } } AdHocSubProcessPropertyReader(AdHocSubProcess element, BPMNDiagram diagram, DefinitionResolver definitionResolver); String getAdHocActivationCondition(); ScriptTypeValue getAdHocCompletionCondition(); String getAdHocOrdering(); boolean isAdHocAutostart(); }### Answer:
@Test public void testGetAdHocCompletionConditionWithoutFormalExpression() { when(process.getCompletionCondition()).thenReturn(null); assertEquals(new ScriptTypeValue(Scripts.LANGUAGE.MVEL.language(), "autocomplete"), propertyReader.getAdHocCompletionCondition()); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.