target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void testShow() { editor.bind(bound, 0, 0); editor.show(); verify(view).show(Optional.empty()); }
@Override public void show() { binding.ifPresent(b -> view.show(Optional.ofNullable(getPopoverTitle()))); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void show() { binding.ifPresent(b -> view.show(Optional.ofNullable(getPopoverTitle()))); } }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void show() { binding.ifPresent(b -> view.show(Optional.ofNullable(getPopoverTitle()))); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void show() { binding.ifPresent(b -> view.show(Optional.ofNullable(getPopoverTitle()))); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void show() { binding.ifPresent(b -> view.show(Optional.ofNullable(getPopoverTitle()))); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
@Test public void testHide() { editor.bind(bound, 0, 0); editor.hide(); verify(view).hide(); }
@Override public void hide() { binding.ifPresent(b -> view.hide()); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void hide() { binding.ifPresent(b -> view.hide()); } }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void hide() { binding.ifPresent(b -> view.hide()); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void hide() { binding.ifPresent(b -> view.hide()); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void hide() { binding.ifPresent(b -> view.hide()); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
@Test public void testBind() { editor.bind(bound, 0, 0); verify(view).setDMNModel(eq(decision)); verify(view).initValue(eq(NAME)); verify(view).initSelectedTypeRef(eq(typeRef)); editor.show(); verify(view).show(Optional.empty()); }
@Override public void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex) { binding = Optional.ofNullable(bound); refresh(); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex) { binding = Optional.ofNullable(bound); refresh(); } }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex) { binding = Optional.ofNullable(bound); refresh(); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex) { binding = Optional.ofNullable(bound); refresh(); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex) { binding = Optional.ofNullable(bound); refresh(); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
@Test public void testSetTypeRef() { editor.bind(bound, 0, 0); editor.setTypeRef(typeRef); verify(bound).setTypeRef(eq(typeRef)); }
@Override public void setTypeRef(final QName typeRef) { binding.ifPresent(b -> b.setTypeRef(typeRef)); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void setTypeRef(final QName typeRef) { binding.ifPresent(b -> b.setTypeRef(typeRef)); } }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void setTypeRef(final QName typeRef) { binding.ifPresent(b -> b.setTypeRef(typeRef)); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void setTypeRef(final QName typeRef) { binding.ifPresent(b -> b.setTypeRef(typeRef)); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void setTypeRef(final QName typeRef) { binding.ifPresent(b -> b.setTypeRef(typeRef)); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
@Test @SuppressWarnings("unchecked") public void testSetOnClosedByKeyboardCallback_WhenNotBound() { final Consumer callback = mock(Consumer.class); editor.setOnClosedByKeyboardCallback(callback); verify(view, never()).setOnClosedByKeyboardCallback(any(Consumer.class)); }
@Override public void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback) { binding.ifPresent(b -> view.setOnClosedByKeyboardCallback(callback)); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback) { binding.ifPresent(b -> view.setOnClosedByKeyboardCallback(callback)); } }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback) { binding.ifPresent(b -> view.setOnClosedByKeyboardCallback(callback)); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback) { binding.ifPresent(b -> view.setOnClosedByKeyboardCallback(callback)); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback) { binding.ifPresent(b -> view.setOnClosedByKeyboardCallback(callback)); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
@Test public void testGetValueLabel_WhenNotBound() { final Throwable thrown = catchThrowable(() -> editor.getValueLabel()); assertThat(thrown).isInstanceOf(IllegalStateException.class) .hasMessageContaining(BINDING_EXCEPTION); }
@Override public String getValueLabel() { return binding.orElseThrow(() -> new IllegalStateException(BINDING_EXCEPTION)).getValueLabel(); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public String getValueLabel() { return binding.orElseThrow(() -> new IllegalStateException(BINDING_EXCEPTION)).getValueLabel(); } }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public String getValueLabel() { return binding.orElseThrow(() -> new IllegalStateException(BINDING_EXCEPTION)).getValueLabel(); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public String getValueLabel() { return binding.orElseThrow(() -> new IllegalStateException(BINDING_EXCEPTION)).getValueLabel(); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public String getValueLabel() { return binding.orElseThrow(() -> new IllegalStateException(BINDING_EXCEPTION)).getValueLabel(); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
@Test public void testNormaliseValue_WhenNotBound() { final Throwable thrown = catchThrowable(() -> editor.normaliseValue(NAME)); assertThat(thrown).isInstanceOf(IllegalStateException.class) .hasMessageContaining(BINDING_EXCEPTION); }
@Override public String normaliseValue(final String value) { return binding.orElseThrow(() -> new IllegalStateException(BINDING_EXCEPTION)).normaliseValue(value); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public String normaliseValue(final String value) { return binding.orElseThrow(() -> new IllegalStateException(BINDING_EXCEPTION)).normaliseValue(value); } }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public String normaliseValue(final String value) { return binding.orElseThrow(() -> new IllegalStateException(BINDING_EXCEPTION)).normaliseValue(value); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public String normaliseValue(final String value) { return binding.orElseThrow(() -> new IllegalStateException(BINDING_EXCEPTION)).normaliseValue(value); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
ValueAndDataTypePopoverImpl implements ValueAndDataTypePopoverView.Presenter { @Override public String normaliseValue(final String value) { return binding.orElseThrow(() -> new IllegalStateException(BINDING_EXCEPTION)).normaliseValue(value); } ValueAndDataTypePopoverImpl(); @Inject ValueAndDataTypePopoverImpl(final ValueAndDataTypePopoverView view); @Override HTMLElement getElement(); @Override String getPopoverTitle(); @Override void bind(final HasValueAndTypeRef bound, final int uiRowIndex, final int uiColumnIndex); @Override @SuppressWarnings("unchecked") void setValue(final String value); @Override void setTypeRef(final QName typeRef); @Override String getValueLabel(); @Override String normaliseValue(final String value); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback); @Override void show(); @Override void hide(); void onDataTypePageNavTabActiveEvent(final @Observes DataTypePageTabActiveEvent event); }
@Test public void testIsValid() { final DataType dataType = mock(DataType.class); doReturn(false).when(validator).isBlank(dataType); doReturn(false).when(validator).isNotUnique(dataType); doReturn(false).when(validator).isDefault(dataType); final boolean isValid = validator.isValid(dataType); verify(flashMessageEvent, never()).fire(any()); verify(flashMessageEvent, never()).fire(any()); assertTrue(isValid); }
public boolean isValid(final DataType dataType) { if (isBlank(dataType)) { flashMessageEvent.fire(blankErrorMessage.getFlashMessage(dataType)); return false; } if (isNotUnique(dataType)) { flashMessageEvent.fire(notUniqueErrorMessage.getFlashMessage(dataType)); return false; } if (isDefault(dataType)) { flashMessageEvent.fire(nameIsDefaultTypeMessage.getFlashMessage(dataType)); return false; } return true; }
DataTypeNameValidator { public boolean isValid(final DataType dataType) { if (isBlank(dataType)) { flashMessageEvent.fire(blankErrorMessage.getFlashMessage(dataType)); return false; } if (isNotUnique(dataType)) { flashMessageEvent.fire(notUniqueErrorMessage.getFlashMessage(dataType)); return false; } if (isDefault(dataType)) { flashMessageEvent.fire(nameIsDefaultTypeMessage.getFlashMessage(dataType)); return false; } return true; } }
DataTypeNameValidator { public boolean isValid(final DataType dataType) { if (isBlank(dataType)) { flashMessageEvent.fire(blankErrorMessage.getFlashMessage(dataType)); return false; } if (isNotUnique(dataType)) { flashMessageEvent.fire(notUniqueErrorMessage.getFlashMessage(dataType)); return false; } if (isDefault(dataType)) { flashMessageEvent.fire(nameIsDefaultTypeMessage.getFlashMessage(dataType)); return false; } return true; } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); }
DataTypeNameValidator { public boolean isValid(final DataType dataType) { if (isBlank(dataType)) { flashMessageEvent.fire(blankErrorMessage.getFlashMessage(dataType)); return false; } if (isNotUnique(dataType)) { flashMessageEvent.fire(notUniqueErrorMessage.getFlashMessage(dataType)); return false; } if (isDefault(dataType)) { flashMessageEvent.fire(nameIsDefaultTypeMessage.getFlashMessage(dataType)); return false; } return true; } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
DataTypeNameValidator { public boolean isValid(final DataType dataType) { if (isBlank(dataType)) { flashMessageEvent.fire(blankErrorMessage.getFlashMessage(dataType)); return false; } if (isNotUnique(dataType)) { flashMessageEvent.fire(notUniqueErrorMessage.getFlashMessage(dataType)); return false; } if (isDefault(dataType)) { flashMessageEvent.fire(nameIsDefaultTypeMessage.getFlashMessage(dataType)); return false; } return true; } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
@Test public void testIsNotBlankWhenNameIsBlank() { final DataType dataType = makeDataType("uuid", ""); assertTrue(validator.isBlank(dataType)); }
boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); }
DataTypeNameValidator { boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); } }
DataTypeNameValidator { boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); }
DataTypeNameValidator { boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
DataTypeNameValidator { boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
@Test public void testDMNFromWBWithNullValue() { assertNull(ExpressionLanguagePropertyConverter.dmnFromWB(new ExpressionLanguage(null))); }
public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } }
ExpressionLanguagePropertyConverter { public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } } }
ExpressionLanguagePropertyConverter { public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } } }
ExpressionLanguagePropertyConverter { public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } } static ExpressionLanguage wbFromDMN(final String language); static String dmnFromWB(final ExpressionLanguage language); }
ExpressionLanguagePropertyConverter { public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } } static ExpressionLanguage wbFromDMN(final String language); static String dmnFromWB(final ExpressionLanguage language); }
@Test public void testIsNotBlankWhenNameIsNull() { final DataType dataType = makeDataType("uuid", null); assertTrue(validator.isBlank(dataType)); }
boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); }
DataTypeNameValidator { boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); } }
DataTypeNameValidator { boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); }
DataTypeNameValidator { boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
DataTypeNameValidator { boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
@Test public void testIsNotBlankWhenNameIsNotBlank() { final DataType dataType = makeDataType("uuid", "tCity"); assertFalse(validator.isBlank(dataType)); }
boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); }
DataTypeNameValidator { boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); } }
DataTypeNameValidator { boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); }
DataTypeNameValidator { boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
DataTypeNameValidator { boolean isBlank(final DataType dataType) { return isEmpty(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
@Test public void testIsDefaultWhenItReturnsTrue() { final DataType dataType = mock(DataType.class); when(dataType.getName()).thenReturn("string"); assertTrue(validator.isDefault(dataType)); }
boolean isDefault(final DataType dataType) { return BuiltInTypeUtils.isBuiltInType(dataType.getName()); }
DataTypeNameValidator { boolean isDefault(final DataType dataType) { return BuiltInTypeUtils.isBuiltInType(dataType.getName()); } }
DataTypeNameValidator { boolean isDefault(final DataType dataType) { return BuiltInTypeUtils.isBuiltInType(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); }
DataTypeNameValidator { boolean isDefault(final DataType dataType) { return BuiltInTypeUtils.isBuiltInType(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
DataTypeNameValidator { boolean isDefault(final DataType dataType) { return BuiltInTypeUtils.isBuiltInType(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
@Test public void testIsDefaultWhenItReturnsFalse() { final DataType dataType = mock(DataType.class); when(dataType.getName()).thenReturn("tCity"); assertFalse(validator.isDefault(dataType)); }
boolean isDefault(final DataType dataType) { return BuiltInTypeUtils.isBuiltInType(dataType.getName()); }
DataTypeNameValidator { boolean isDefault(final DataType dataType) { return BuiltInTypeUtils.isBuiltInType(dataType.getName()); } }
DataTypeNameValidator { boolean isDefault(final DataType dataType) { return BuiltInTypeUtils.isBuiltInType(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); }
DataTypeNameValidator { boolean isDefault(final DataType dataType) { return BuiltInTypeUtils.isBuiltInType(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
DataTypeNameValidator { boolean isDefault(final DataType dataType) { return BuiltInTypeUtils.isBuiltInType(dataType.getName()); } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
@Test public void testSiblingsWhenDataTypeDoesNotHaveParent() { final DataType dataType = mock(DataType.class); final List<DataType> expectedSiblings = Collections.singletonList(mock(DataType.class)); when(dataTypeStore.getTopLevelDataTypes()).thenReturn(expectedSiblings); final List<DataType> actualSiblings = validator.siblings(dataType); assertEquals(expectedSiblings, actualSiblings); }
public List<DataType> siblings(final DataType dataType) { final Optional<DataType> parent = Optional.ofNullable(dataTypeStore.get(dataType.getParentUUID())); if (parent.isPresent()) { return parent.get().getSubDataTypes(); } else { return dataTypeStore.getTopLevelDataTypes(); } }
DataTypeNameValidator { public List<DataType> siblings(final DataType dataType) { final Optional<DataType> parent = Optional.ofNullable(dataTypeStore.get(dataType.getParentUUID())); if (parent.isPresent()) { return parent.get().getSubDataTypes(); } else { return dataTypeStore.getTopLevelDataTypes(); } } }
DataTypeNameValidator { public List<DataType> siblings(final DataType dataType) { final Optional<DataType> parent = Optional.ofNullable(dataTypeStore.get(dataType.getParentUUID())); if (parent.isPresent()) { return parent.get().getSubDataTypes(); } else { return dataTypeStore.getTopLevelDataTypes(); } } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); }
DataTypeNameValidator { public List<DataType> siblings(final DataType dataType) { final Optional<DataType> parent = Optional.ofNullable(dataTypeStore.get(dataType.getParentUUID())); if (parent.isPresent()) { return parent.get().getSubDataTypes(); } else { return dataTypeStore.getTopLevelDataTypes(); } } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
DataTypeNameValidator { public List<DataType> siblings(final DataType dataType) { final Optional<DataType> parent = Optional.ofNullable(dataTypeStore.get(dataType.getParentUUID())); if (parent.isPresent()) { return parent.get().getSubDataTypes(); } else { return dataTypeStore.getTopLevelDataTypes(); } } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
@Test public void testSiblingsWhenDataTypeHasParent() { final DataType dataType = mock(DataType.class); final DataType parent = mock(DataType.class); final String parentUUID = "parentUUID"; final List<DataType> expectedSiblings = Collections.singletonList(mock(DataType.class)); when(dataType.getParentUUID()).thenReturn(parentUUID); when(parent.getSubDataTypes()).thenReturn(expectedSiblings); when(dataTypeStore.get(parentUUID)).thenReturn(parent); final List<DataType> actualSiblings = validator.siblings(dataType); assertEquals(expectedSiblings, actualSiblings); }
public List<DataType> siblings(final DataType dataType) { final Optional<DataType> parent = Optional.ofNullable(dataTypeStore.get(dataType.getParentUUID())); if (parent.isPresent()) { return parent.get().getSubDataTypes(); } else { return dataTypeStore.getTopLevelDataTypes(); } }
DataTypeNameValidator { public List<DataType> siblings(final DataType dataType) { final Optional<DataType> parent = Optional.ofNullable(dataTypeStore.get(dataType.getParentUUID())); if (parent.isPresent()) { return parent.get().getSubDataTypes(); } else { return dataTypeStore.getTopLevelDataTypes(); } } }
DataTypeNameValidator { public List<DataType> siblings(final DataType dataType) { final Optional<DataType> parent = Optional.ofNullable(dataTypeStore.get(dataType.getParentUUID())); if (parent.isPresent()) { return parent.get().getSubDataTypes(); } else { return dataTypeStore.getTopLevelDataTypes(); } } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); }
DataTypeNameValidator { public List<DataType> siblings(final DataType dataType) { final Optional<DataType> parent = Optional.ofNullable(dataTypeStore.get(dataType.getParentUUID())); if (parent.isPresent()) { return parent.get().getSubDataTypes(); } else { return dataTypeStore.getTopLevelDataTypes(); } } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
DataTypeNameValidator { public List<DataType> siblings(final DataType dataType) { final Optional<DataType> parent = Optional.ofNullable(dataTypeStore.get(dataType.getParentUUID())); if (parent.isPresent()) { return parent.get().getSubDataTypes(); } else { return dataTypeStore.getTopLevelDataTypes(); } } @Inject DataTypeNameValidator(final Event<FlashMessage> flashMessageEvent, final DataTypeNameIsBlankErrorMessage blankErrorMessage, final DataTypeNameIsNotUniqueErrorMessage notUniqueErrorMessage, final DataTypeNameIsDefaultTypeMessage nameIsDefaultTypeMessage, final DataTypeStore dataTypeStore); boolean isValid(final DataType dataType); boolean isNotUnique(final DataType dataType); List<DataType> siblings(final DataType dataType); }
@Test public void testGetWhenItReturnsNull() { assertNull(store.get("456")); }
public ItemDefinition get(final String uuid) { return itemDefinitions.get(uuid); }
ItemDefinitionStore { public ItemDefinition get(final String uuid) { return itemDefinitions.get(uuid); } }
ItemDefinitionStore { public ItemDefinition get(final String uuid) { return itemDefinitions.get(uuid); } }
ItemDefinitionStore { public ItemDefinition get(final String uuid) { return itemDefinitions.get(uuid); } ItemDefinition get(final String uuid); void index(final String uuid, final ItemDefinition itemDefinition); void clear(); void unIndex(final String uuid); }
ItemDefinitionStore { public ItemDefinition get(final String uuid) { return itemDefinitions.get(uuid); } ItemDefinition get(final String uuid); void index(final String uuid, final ItemDefinition itemDefinition); void clear(); void unIndex(final String uuid); }
@Test public void testGetWhenItDoesNotReturnNull() { assertNotNull(store.get(uuid)); assertEquals(itemDefinition, store.get(uuid)); }
public ItemDefinition get(final String uuid) { return itemDefinitions.get(uuid); }
ItemDefinitionStore { public ItemDefinition get(final String uuid) { return itemDefinitions.get(uuid); } }
ItemDefinitionStore { public ItemDefinition get(final String uuid) { return itemDefinitions.get(uuid); } }
ItemDefinitionStore { public ItemDefinition get(final String uuid) { return itemDefinitions.get(uuid); } ItemDefinition get(final String uuid); void index(final String uuid, final ItemDefinition itemDefinition); void clear(); void unIndex(final String uuid); }
ItemDefinitionStore { public ItemDefinition get(final String uuid) { return itemDefinitions.get(uuid); } ItemDefinition get(final String uuid); void index(final String uuid, final ItemDefinition itemDefinition); void clear(); void unIndex(final String uuid); }
@Test public void testIndex() { final ItemDefinition itemDefinition = mock(ItemDefinition.class); final String uuid = "789"; store.index(uuid, itemDefinition); assertEquals(itemDefinition, store.get(uuid)); }
public void index(final String uuid, final ItemDefinition itemDefinition) { itemDefinitions.put(uuid, itemDefinition); }
ItemDefinitionStore { public void index(final String uuid, final ItemDefinition itemDefinition) { itemDefinitions.put(uuid, itemDefinition); } }
ItemDefinitionStore { public void index(final String uuid, final ItemDefinition itemDefinition) { itemDefinitions.put(uuid, itemDefinition); } }
ItemDefinitionStore { public void index(final String uuid, final ItemDefinition itemDefinition) { itemDefinitions.put(uuid, itemDefinition); } ItemDefinition get(final String uuid); void index(final String uuid, final ItemDefinition itemDefinition); void clear(); void unIndex(final String uuid); }
ItemDefinitionStore { public void index(final String uuid, final ItemDefinition itemDefinition) { itemDefinitions.put(uuid, itemDefinition); } ItemDefinition get(final String uuid); void index(final String uuid, final ItemDefinition itemDefinition); void clear(); void unIndex(final String uuid); }
@Test public void testClear() { store.clear(); assertEquals(0, store.size()); }
public void clear() { itemDefinitions.clear(); }
ItemDefinitionStore { public void clear() { itemDefinitions.clear(); } }
ItemDefinitionStore { public void clear() { itemDefinitions.clear(); } }
ItemDefinitionStore { public void clear() { itemDefinitions.clear(); } ItemDefinition get(final String uuid); void index(final String uuid, final ItemDefinition itemDefinition); void clear(); void unIndex(final String uuid); }
ItemDefinitionStore { public void clear() { itemDefinitions.clear(); } ItemDefinition get(final String uuid); void index(final String uuid, final ItemDefinition itemDefinition); void clear(); void unIndex(final String uuid); }
@Test public void testDMNFromWBWithEmptyValue() { assertNull(ExpressionLanguagePropertyConverter.dmnFromWB(new ExpressionLanguage())); }
public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } }
ExpressionLanguagePropertyConverter { public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } } }
ExpressionLanguagePropertyConverter { public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } } }
ExpressionLanguagePropertyConverter { public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } } static ExpressionLanguage wbFromDMN(final String language); static String dmnFromWB(final ExpressionLanguage language); }
ExpressionLanguagePropertyConverter { public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } } static ExpressionLanguage wbFromDMN(final String language); static String dmnFromWB(final ExpressionLanguage language); }
@Test public void testUnIndex() { store.unIndex(uuid); assertNull(store.get(uuid)); }
public void unIndex(final String uuid) { itemDefinitions.remove(uuid); }
ItemDefinitionStore { public void unIndex(final String uuid) { itemDefinitions.remove(uuid); } }
ItemDefinitionStore { public void unIndex(final String uuid) { itemDefinitions.remove(uuid); } }
ItemDefinitionStore { public void unIndex(final String uuid) { itemDefinitions.remove(uuid); } ItemDefinition get(final String uuid); void index(final String uuid, final ItemDefinition itemDefinition); void clear(); void unIndex(final String uuid); }
ItemDefinitionStore { public void unIndex(final String uuid) { itemDefinitions.remove(uuid); } ItemDefinition get(final String uuid); void index(final String uuid, final ItemDefinition itemDefinition); void clear(); void unIndex(final String uuid); }
@Test public void testMakeName() { final DataType dataType = mock(DataType.class); final String expectedName = "name"; when(dataType.getName()).thenReturn(expectedName); final Name name = handler.makeName(dataType); assertEquals(expectedName, name.getValue()); }
Name makeName(final DataType dataType) { return new Name(dataType.getName()); }
ItemDefinitionUpdateHandler { Name makeName(final DataType dataType) { return new Name(dataType.getName()); } }
ItemDefinitionUpdateHandler { Name makeName(final DataType dataType) { return new Name(dataType.getName()); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); }
ItemDefinitionUpdateHandler { Name makeName(final DataType dataType) { return new Name(dataType.getName()); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); void update(final DataType dataType, final ItemDefinition itemDefinition); }
ItemDefinitionUpdateHandler { Name makeName(final DataType dataType) { return new Name(dataType.getName()); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); void update(final DataType dataType, final ItemDefinition itemDefinition); }
@Test public void testMakeQNameWhenDataTypeIsDefault() { final DataType dataType = mock(DataType.class); final String expectedName = "string"; when(dataType.getType()).thenReturn(expectedName); final QName name = handler.makeQName(dataType); final String actualName = name.getLocalPart(); assertEquals(expectedName, actualName); assertEquals(QName.NULL_NS_URI, name.getNamespaceURI()); }
QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); }
ItemDefinitionUpdateHandler { QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); } }
ItemDefinitionUpdateHandler { QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); }
ItemDefinitionUpdateHandler { QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); void update(final DataType dataType, final ItemDefinition itemDefinition); }
ItemDefinitionUpdateHandler { QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); void update(final DataType dataType, final ItemDefinition itemDefinition); }
@Test public void testMakeQNameWhenDataTypeIsNotDefault() { final DataType dataType = mock(DataType.class); final String expectedName = "tAddress"; when(dataType.getType()).thenReturn(expectedName); final QName name = handler.makeQName(dataType); final String actual = name.toString(); final String expected = "tAddress"; assertEquals(expected, actual); assertEquals(QName.NULL_NS_URI, name.getNamespaceURI()); }
QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); }
ItemDefinitionUpdateHandler { QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); } }
ItemDefinitionUpdateHandler { QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); }
ItemDefinitionUpdateHandler { QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); void update(final DataType dataType, final ItemDefinition itemDefinition); }
ItemDefinitionUpdateHandler { QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); void update(final DataType dataType, final ItemDefinition itemDefinition); }
@Test public void testMakeQNameWithItemDefinition() { final ItemDefinition itemDefinition = mock(ItemDefinition.class); final Name itemDefinitionName = mock(Name.class); final String expectedName = "tAddress"; when(itemDefinitionName.getValue()).thenReturn(expectedName); when(itemDefinition.getName()).thenReturn(itemDefinitionName); final QName name = handler.makeQName(itemDefinition); final String actual = name.toString(); final String expected = "tAddress"; assertEquals(expected, actual); assertEquals(QName.NULL_NS_URI, name.getNamespaceURI()); }
QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); }
ItemDefinitionUpdateHandler { QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); } }
ItemDefinitionUpdateHandler { QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); }
ItemDefinitionUpdateHandler { QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); void update(final DataType dataType, final ItemDefinition itemDefinition); }
ItemDefinitionUpdateHandler { QName makeQName(final DataType dataType) { return normaliseTypeRef(makeQName(dataType.getType())); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); void update(final DataType dataType, final ItemDefinition itemDefinition); }
@Test public void testMakeAllowedValuesWhenDataTypeConstraintIsBlank() { final DataType dataType = mock(DataType.class); final ItemDefinition itemDefinition = mock(ItemDefinition.class); when(dataType.getConstraint()).thenReturn(""); final UnaryTests actualAllowedValues = handler.makeAllowedValues(dataType, itemDefinition); assertNull(actualAllowedValues); }
UnaryTests makeAllowedValues(final DataType dataType, final ItemDefinition itemDefinition) { final String constraint = dataType.getConstraint(); if (isEmpty(constraint)) { return null; } if (!Objects.equals(constraint, getText(itemDefinition))) { return new UnaryTests(new Id(), new Description(), new Text(constraint), null, dataType.getConstraintType()); } return itemDefinition.getAllowedValues(); }
ItemDefinitionUpdateHandler { UnaryTests makeAllowedValues(final DataType dataType, final ItemDefinition itemDefinition) { final String constraint = dataType.getConstraint(); if (isEmpty(constraint)) { return null; } if (!Objects.equals(constraint, getText(itemDefinition))) { return new UnaryTests(new Id(), new Description(), new Text(constraint), null, dataType.getConstraintType()); } return itemDefinition.getAllowedValues(); } }
ItemDefinitionUpdateHandler { UnaryTests makeAllowedValues(final DataType dataType, final ItemDefinition itemDefinition) { final String constraint = dataType.getConstraint(); if (isEmpty(constraint)) { return null; } if (!Objects.equals(constraint, getText(itemDefinition))) { return new UnaryTests(new Id(), new Description(), new Text(constraint), null, dataType.getConstraintType()); } return itemDefinition.getAllowedValues(); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); }
ItemDefinitionUpdateHandler { UnaryTests makeAllowedValues(final DataType dataType, final ItemDefinition itemDefinition) { final String constraint = dataType.getConstraint(); if (isEmpty(constraint)) { return null; } if (!Objects.equals(constraint, getText(itemDefinition))) { return new UnaryTests(new Id(), new Description(), new Text(constraint), null, dataType.getConstraintType()); } return itemDefinition.getAllowedValues(); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); void update(final DataType dataType, final ItemDefinition itemDefinition); }
ItemDefinitionUpdateHandler { UnaryTests makeAllowedValues(final DataType dataType, final ItemDefinition itemDefinition) { final String constraint = dataType.getConstraint(); if (isEmpty(constraint)) { return null; } if (!Objects.equals(constraint, getText(itemDefinition))) { return new UnaryTests(new Id(), new Description(), new Text(constraint), null, dataType.getConstraintType()); } return itemDefinition.getAllowedValues(); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); void update(final DataType dataType, final ItemDefinition itemDefinition); }
@Test public void testMakeAllowedValuesWhenDataTypeConstraintIsNull() { final DataType dataType = mock(DataType.class); final ItemDefinition itemDefinition = mock(ItemDefinition.class); when(dataType.getConstraint()).thenReturn(null); when(dataType.getConstraintType()).thenReturn(null); final UnaryTests actualAllowedValues = handler.makeAllowedValues(dataType, itemDefinition); assertNull(actualAllowedValues); }
UnaryTests makeAllowedValues(final DataType dataType, final ItemDefinition itemDefinition) { final String constraint = dataType.getConstraint(); if (isEmpty(constraint)) { return null; } if (!Objects.equals(constraint, getText(itemDefinition))) { return new UnaryTests(new Id(), new Description(), new Text(constraint), null, dataType.getConstraintType()); } return itemDefinition.getAllowedValues(); }
ItemDefinitionUpdateHandler { UnaryTests makeAllowedValues(final DataType dataType, final ItemDefinition itemDefinition) { final String constraint = dataType.getConstraint(); if (isEmpty(constraint)) { return null; } if (!Objects.equals(constraint, getText(itemDefinition))) { return new UnaryTests(new Id(), new Description(), new Text(constraint), null, dataType.getConstraintType()); } return itemDefinition.getAllowedValues(); } }
ItemDefinitionUpdateHandler { UnaryTests makeAllowedValues(final DataType dataType, final ItemDefinition itemDefinition) { final String constraint = dataType.getConstraint(); if (isEmpty(constraint)) { return null; } if (!Objects.equals(constraint, getText(itemDefinition))) { return new UnaryTests(new Id(), new Description(), new Text(constraint), null, dataType.getConstraintType()); } return itemDefinition.getAllowedValues(); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); }
ItemDefinitionUpdateHandler { UnaryTests makeAllowedValues(final DataType dataType, final ItemDefinition itemDefinition) { final String constraint = dataType.getConstraint(); if (isEmpty(constraint)) { return null; } if (!Objects.equals(constraint, getText(itemDefinition))) { return new UnaryTests(new Id(), new Description(), new Text(constraint), null, dataType.getConstraintType()); } return itemDefinition.getAllowedValues(); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); void update(final DataType dataType, final ItemDefinition itemDefinition); }
ItemDefinitionUpdateHandler { UnaryTests makeAllowedValues(final DataType dataType, final ItemDefinition itemDefinition) { final String constraint = dataType.getConstraint(); if (isEmpty(constraint)) { return null; } if (!Objects.equals(constraint, getText(itemDefinition))) { return new UnaryTests(new Id(), new Description(), new Text(constraint), null, dataType.getConstraintType()); } return itemDefinition.getAllowedValues(); } @Inject ItemDefinitionUpdateHandler(final DataTypeManager dataTypeManager, final ItemDefinitionUtils itemDefinitionUtils, final PropertiesPanelNotifier panelNotifier, final Event<DataTypeChangedEvent> dataTypeChangedEvent); void update(final DataType dataType, final ItemDefinition itemDefinition); }
@Test public void testDestroy() { final String uuid = "uuid"; final String oldItemDefinitionName = "oldItemDefinitionName"; final DataType dataType = mock(DataType.class); final Name name = mock(Name.class); final ItemDefinition itemDefinition = makeItemDefinition(); final ItemDefinition itemDefinitionParent = makeItemDefinition(itemDefinition); final List<ItemDefinition> itemDefinitions = new ArrayList<ItemDefinition>() {{ add(itemDefinition); }}; when(name.getValue()).thenReturn(oldItemDefinitionName); when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition); when(dataType.getUUID()).thenReturn(uuid); doReturn(Optional.of(itemDefinitionParent)).when(handler).findItemDefinitionParent(dataType); doReturn(name).when(itemDefinition).getName(); doReturn(itemDefinitions).when(handler).itemDefinitions(); doNothing().when(handler).notifyPropertiesPanel(anyString()); handler.destroy(dataType, true); assertEquals(emptyList(), itemDefinitionParent.getItemComponent()); assertEquals(emptyList(), itemDefinitions); verify(handler).notifyPropertiesPanel(oldItemDefinitionName); }
public void destroy(final DataType dataType, final boolean notifyPropertiesPanel) { final ItemDefinition itemDefinition = findItemDefinition(dataType); final String destroyedItemDefinition = itemDefinition.getName().getValue(); final Optional<ItemDefinition> itemDefinitionParent = findItemDefinitionParent(dataType); itemDefinitionParent.ifPresent(parent -> { parent.getItemComponent().remove(itemDefinition); }); itemDefinitions().remove(itemDefinition); itemDefinitionStore.unIndex(dataType.getUUID()); if (notifyPropertiesPanel) { notifyPropertiesPanel(destroyedItemDefinition); } }
ItemDefinitionDestroyHandler { public void destroy(final DataType dataType, final boolean notifyPropertiesPanel) { final ItemDefinition itemDefinition = findItemDefinition(dataType); final String destroyedItemDefinition = itemDefinition.getName().getValue(); final Optional<ItemDefinition> itemDefinitionParent = findItemDefinitionParent(dataType); itemDefinitionParent.ifPresent(parent -> { parent.getItemComponent().remove(itemDefinition); }); itemDefinitions().remove(itemDefinition); itemDefinitionStore.unIndex(dataType.getUUID()); if (notifyPropertiesPanel) { notifyPropertiesPanel(destroyedItemDefinition); } } }
ItemDefinitionDestroyHandler { public void destroy(final DataType dataType, final boolean notifyPropertiesPanel) { final ItemDefinition itemDefinition = findItemDefinition(dataType); final String destroyedItemDefinition = itemDefinition.getName().getValue(); final Optional<ItemDefinition> itemDefinitionParent = findItemDefinitionParent(dataType); itemDefinitionParent.ifPresent(parent -> { parent.getItemComponent().remove(itemDefinition); }); itemDefinitions().remove(itemDefinition); itemDefinitionStore.unIndex(dataType.getUUID()); if (notifyPropertiesPanel) { notifyPropertiesPanel(destroyedItemDefinition); } } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); }
ItemDefinitionDestroyHandler { public void destroy(final DataType dataType, final boolean notifyPropertiesPanel) { final ItemDefinition itemDefinition = findItemDefinition(dataType); final String destroyedItemDefinition = itemDefinition.getName().getValue(); final Optional<ItemDefinition> itemDefinitionParent = findItemDefinitionParent(dataType); itemDefinitionParent.ifPresent(parent -> { parent.getItemComponent().remove(itemDefinition); }); itemDefinitions().remove(itemDefinition); itemDefinitionStore.unIndex(dataType.getUUID()); if (notifyPropertiesPanel) { notifyPropertiesPanel(destroyedItemDefinition); } } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel); }
ItemDefinitionDestroyHandler { public void destroy(final DataType dataType, final boolean notifyPropertiesPanel) { final ItemDefinition itemDefinition = findItemDefinition(dataType); final String destroyedItemDefinition = itemDefinition.getName().getValue(); final Optional<ItemDefinition> itemDefinitionParent = findItemDefinitionParent(dataType); itemDefinitionParent.ifPresent(parent -> { parent.getItemComponent().remove(itemDefinition); }); itemDefinitions().remove(itemDefinition); itemDefinitionStore.unIndex(dataType.getUUID()); if (notifyPropertiesPanel) { notifyPropertiesPanel(destroyedItemDefinition); } } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel); }
@Test public void testNotifyPropertiesPanel() { final String destroyedItemDefinition = "destroyedItemDefinition"; when(panelNotifier.withOldLocalPart(destroyedItemDefinition)).thenReturn(panelNotifier); when(panelNotifier.withNewQName(eq(new QName()))).thenReturn(panelNotifier); handler.notifyPropertiesPanel(destroyedItemDefinition); verify(panelNotifier).notifyPanel(); }
void notifyPropertiesPanel(final String destroyedItemDefinition) { panelNotifier .withOldLocalPart(destroyedItemDefinition) .withNewQName(new QName()) .notifyPanel(); }
ItemDefinitionDestroyHandler { void notifyPropertiesPanel(final String destroyedItemDefinition) { panelNotifier .withOldLocalPart(destroyedItemDefinition) .withNewQName(new QName()) .notifyPanel(); } }
ItemDefinitionDestroyHandler { void notifyPropertiesPanel(final String destroyedItemDefinition) { panelNotifier .withOldLocalPart(destroyedItemDefinition) .withNewQName(new QName()) .notifyPanel(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); }
ItemDefinitionDestroyHandler { void notifyPropertiesPanel(final String destroyedItemDefinition) { panelNotifier .withOldLocalPart(destroyedItemDefinition) .withNewQName(new QName()) .notifyPanel(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel); }
ItemDefinitionDestroyHandler { void notifyPropertiesPanel(final String destroyedItemDefinition) { panelNotifier .withOldLocalPart(destroyedItemDefinition) .withNewQName(new QName()) .notifyPanel(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel); }
@Test public void testFindItemDefinitionParentWhenParentDoesNotExist() { final DataType dataType = mock(DataType.class); final String parentUUID = "parentUUID"; when(dataType.getParentUUID()).thenReturn(parentUUID); when(itemDefinitionStore.get(parentUUID)).thenReturn(null); final Optional<ItemDefinition> expectedParent = Optional.empty(); final Optional<ItemDefinition> actualParent = handler.findItemDefinitionParent(dataType); assertEquals(expectedParent, actualParent); }
Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); }
ItemDefinitionDestroyHandler { Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); } }
ItemDefinitionDestroyHandler { Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); }
ItemDefinitionDestroyHandler { Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel); }
ItemDefinitionDestroyHandler { Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel); }
@Test public void testDMNFromWBWithNonNullValue() { assertEquals(EXPRESSION_LANGUAGE, ExpressionLanguagePropertyConverter.dmnFromWB(new ExpressionLanguage(EXPRESSION_LANGUAGE))); }
public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } }
ExpressionLanguagePropertyConverter { public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } } }
ExpressionLanguagePropertyConverter { public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } } }
ExpressionLanguagePropertyConverter { public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } } static ExpressionLanguage wbFromDMN(final String language); static String dmnFromWB(final ExpressionLanguage language); }
ExpressionLanguagePropertyConverter { public static String dmnFromWB(final ExpressionLanguage language) { if (language == null) { return null; } else if (StringUtils.isEmpty(language.getValue())) { return null; } else { return language.getValue(); } } static ExpressionLanguage wbFromDMN(final String language); static String dmnFromWB(final ExpressionLanguage language); }
@Test public void testFindItemDefinitionParentWhenParentDoesNotHaveTypeRef() { final DataType dataType = mock(DataType.class); final ItemDefinition parent = makeItemDefinition(); final String parentUUID = "parentUUID"; when(parent.getTypeRef()).thenReturn(null); when(dataType.getParentUUID()).thenReturn(parentUUID); when(itemDefinitionStore.get(parentUUID)).thenReturn(parent); final Optional<ItemDefinition> expectedParent = Optional.of(parent); final Optional<ItemDefinition> actualParent = handler.findItemDefinitionParent(dataType); assertEquals(expectedParent, actualParent); }
Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); }
ItemDefinitionDestroyHandler { Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); } }
ItemDefinitionDestroyHandler { Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); }
ItemDefinitionDestroyHandler { Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel); }
ItemDefinitionDestroyHandler { Optional<ItemDefinition> findItemDefinitionParent(final DataType dataType) { final Optional<ItemDefinition> itemDefinitionParent = Optional.ofNullable(itemDefinitionStore.get(dataType.getParentUUID())); if (itemDefinitionParent.isPresent()) { final ItemDefinition parent = itemDefinitionParent.get(); if (parent.getTypeRef() == null) { return Optional.of(parent); } else { for (final ItemDefinition itemDefinition : itemDefinitions()) { if (Objects.equals(itemDefinition.getName().getValue(), parent.getTypeRef().getLocalPart())) { return Optional.of(itemDefinition); } } } } return Optional.empty(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel); }
@Test public void testItemDefinitions() { final Definitions definitions = mock(Definitions.class); final ItemDefinition itemDefinition = makeItemDefinition(); final List<ItemDefinition> expectedItemDefinitions = singletonList(itemDefinition); when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions); when(definitions.getItemDefinition()).thenReturn(expectedItemDefinitions); final List<ItemDefinition> actualItemDefinitions = handler.itemDefinitions(); assertEquals(expectedItemDefinitions, actualItemDefinitions); }
List<ItemDefinition> itemDefinitions() { final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); if (definitions.isPresent()) { return definitions.get().getItemDefinition(); } return new ArrayList<>(); }
ItemDefinitionDestroyHandler { List<ItemDefinition> itemDefinitions() { final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); if (definitions.isPresent()) { return definitions.get().getItemDefinition(); } return new ArrayList<>(); } }
ItemDefinitionDestroyHandler { List<ItemDefinition> itemDefinitions() { final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); if (definitions.isPresent()) { return definitions.get().getItemDefinition(); } return new ArrayList<>(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); }
ItemDefinitionDestroyHandler { List<ItemDefinition> itemDefinitions() { final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); if (definitions.isPresent()) { return definitions.get().getItemDefinition(); } return new ArrayList<>(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel); }
ItemDefinitionDestroyHandler { List<ItemDefinition> itemDefinitions() { final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); if (definitions.isPresent()) { return definitions.get().getItemDefinition(); } return new ArrayList<>(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel); }
@Test public void testItemDefinitionsWhenDefinitionsIsNull() { final List<ItemDefinition> expectedItemDefinitions = emptyList(); when(dmnGraphUtils.getModelDefinitions()).thenReturn(null); final List<ItemDefinition> actualItemDefinitions = handler.itemDefinitions(); assertEquals(expectedItemDefinitions, actualItemDefinitions); }
List<ItemDefinition> itemDefinitions() { final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); if (definitions.isPresent()) { return definitions.get().getItemDefinition(); } return new ArrayList<>(); }
ItemDefinitionDestroyHandler { List<ItemDefinition> itemDefinitions() { final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); if (definitions.isPresent()) { return definitions.get().getItemDefinition(); } return new ArrayList<>(); } }
ItemDefinitionDestroyHandler { List<ItemDefinition> itemDefinitions() { final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); if (definitions.isPresent()) { return definitions.get().getItemDefinition(); } return new ArrayList<>(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); }
ItemDefinitionDestroyHandler { List<ItemDefinition> itemDefinitions() { final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); if (definitions.isPresent()) { return definitions.get().getItemDefinition(); } return new ArrayList<>(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel); }
ItemDefinitionDestroyHandler { List<ItemDefinition> itemDefinitions() { final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); if (definitions.isPresent()) { return definitions.get().getItemDefinition(); } return new ArrayList<>(); } @Inject ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore, final DMNGraphUtils dmnGraphUtils, final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel); }
@Test public void testAppend() { final DataType dataType = mock(DataType.class); final DataType dataTypeWithoutName = mock(DataType.class); final DataType updatedDataType = mock(DataType.class); final DataTypeManager withDataType = mock(DataTypeManager.class); final DataTypeManager withNoName = mock(DataTypeManager.class); final ItemDefinition itemDefinition = mock(ItemDefinition.class); final List<DataType> expectedAffectedDataTypes = asList(mock(DataType.class), mock(DataType.class)); when(dataTypeManager.withDataType(dataType)).thenReturn(withDataType); when(withDataType.withNoName()).thenReturn(withNoName); when(withNoName.get()).thenReturn(dataTypeWithoutName); when(recordEngine.update(updatedDataType)).thenReturn(expectedAffectedDataTypes); doReturn(updatedDataType).when(handler).updateDataTypeProperties(dataTypeWithoutName, TOP_LEVEL_PARENT_UUID, itemDefinition); final List<DataType> actualAffectedDataTypes = handler.append(dataType, itemDefinition); assertEquals(expectedAffectedDataTypes, actualAffectedDataTypes); }
public List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition) { final DataType named; if (Strings.isNullOrEmpty(dataType.getName())) { named = withNoName(dataType); } else { named = dataType; } final DataType updateDataType = updateDataTypeProperties(named, TOP_LEVEL_PARENT_UUID, itemDefinition); return recordEngine.update(updateDataType); }
DataTypeCreateHandler extends DataTypeHandler { public List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition) { final DataType named; if (Strings.isNullOrEmpty(dataType.getName())) { named = withNoName(dataType); } else { named = dataType; } final DataType updateDataType = updateDataTypeProperties(named, TOP_LEVEL_PARENT_UUID, itemDefinition); return recordEngine.update(updateDataType); } }
DataTypeCreateHandler extends DataTypeHandler { public List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition) { final DataType named; if (Strings.isNullOrEmpty(dataType.getName())) { named = withNoName(dataType); } else { named = dataType; } final DataType updateDataType = updateDataTypeProperties(named, TOP_LEVEL_PARENT_UUID, itemDefinition); return recordEngine.update(updateDataType); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeCreateHandler extends DataTypeHandler { public List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition) { final DataType named; if (Strings.isNullOrEmpty(dataType.getName())) { named = withNoName(dataType); } else { named = dataType; } final DataType updateDataType = updateDataTypeProperties(named, TOP_LEVEL_PARENT_UUID, itemDefinition); return recordEngine.update(updateDataType); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType, final DataType reference, final ItemDefinition itemDefinition); }
DataTypeCreateHandler extends DataTypeHandler { public List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition) { final DataType named; if (Strings.isNullOrEmpty(dataType.getName())) { named = withNoName(dataType); } else { named = dataType; } final DataType updateDataType = updateDataTypeProperties(named, TOP_LEVEL_PARENT_UUID, itemDefinition); return recordEngine.update(updateDataType); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType, final DataType reference, final ItemDefinition itemDefinition); }
@Test public void testInsertNotNested() { final DataType dataType = mock(DataType.class); final DataType reference = mock(DataType.class); final ItemDefinition itemDefinition = mock(ItemDefinition.class); final List<DataType> expectedAffectedDataTypes = asList(mock(DataType.class), mock(DataType.class)); final CreationType creationType = ABOVE; doReturn(expectedAffectedDataTypes).when(handler).insertSibling(dataType, reference, creationType, itemDefinition); final List<DataType> actualAffectedDataTypes = handler.insertSibling(dataType, reference, creationType, itemDefinition); assertEquals(expectedAffectedDataTypes, actualAffectedDataTypes); }
public List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition) { final Optional<DataType> parentOptional = lookupAbsoluteParent(reference); if (parentOptional.isPresent()) { final DataType parent = parentOptional.get(); final List<DataType> siblings = parent.getSubDataTypes(); final DataType updatedDataType = updateDataTypeProperties(dataType, parent.getUUID(), itemDefinition); final DataType parentReference = findParentReference(reference, siblings); siblings.add(siblings.indexOf(parentReference) + creationType.getIndexIncrement(), updatedDataType); recordEngine.doUpdate(dataType, itemDefinition); return recordEngine.update(parent); } else { final DataType updatedDataType = updateDataTypeProperties(dataType, reference.getParentUUID(), itemDefinition); recordEngine.doUpdate(updatedDataType, itemDefinition); return new ArrayList<>(); } }
DataTypeCreateHandler extends DataTypeHandler { public List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition) { final Optional<DataType> parentOptional = lookupAbsoluteParent(reference); if (parentOptional.isPresent()) { final DataType parent = parentOptional.get(); final List<DataType> siblings = parent.getSubDataTypes(); final DataType updatedDataType = updateDataTypeProperties(dataType, parent.getUUID(), itemDefinition); final DataType parentReference = findParentReference(reference, siblings); siblings.add(siblings.indexOf(parentReference) + creationType.getIndexIncrement(), updatedDataType); recordEngine.doUpdate(dataType, itemDefinition); return recordEngine.update(parent); } else { final DataType updatedDataType = updateDataTypeProperties(dataType, reference.getParentUUID(), itemDefinition); recordEngine.doUpdate(updatedDataType, itemDefinition); return new ArrayList<>(); } } }
DataTypeCreateHandler extends DataTypeHandler { public List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition) { final Optional<DataType> parentOptional = lookupAbsoluteParent(reference); if (parentOptional.isPresent()) { final DataType parent = parentOptional.get(); final List<DataType> siblings = parent.getSubDataTypes(); final DataType updatedDataType = updateDataTypeProperties(dataType, parent.getUUID(), itemDefinition); final DataType parentReference = findParentReference(reference, siblings); siblings.add(siblings.indexOf(parentReference) + creationType.getIndexIncrement(), updatedDataType); recordEngine.doUpdate(dataType, itemDefinition); return recordEngine.update(parent); } else { final DataType updatedDataType = updateDataTypeProperties(dataType, reference.getParentUUID(), itemDefinition); recordEngine.doUpdate(updatedDataType, itemDefinition); return new ArrayList<>(); } } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeCreateHandler extends DataTypeHandler { public List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition) { final Optional<DataType> parentOptional = lookupAbsoluteParent(reference); if (parentOptional.isPresent()) { final DataType parent = parentOptional.get(); final List<DataType> siblings = parent.getSubDataTypes(); final DataType updatedDataType = updateDataTypeProperties(dataType, parent.getUUID(), itemDefinition); final DataType parentReference = findParentReference(reference, siblings); siblings.add(siblings.indexOf(parentReference) + creationType.getIndexIncrement(), updatedDataType); recordEngine.doUpdate(dataType, itemDefinition); return recordEngine.update(parent); } else { final DataType updatedDataType = updateDataTypeProperties(dataType, reference.getParentUUID(), itemDefinition); recordEngine.doUpdate(updatedDataType, itemDefinition); return new ArrayList<>(); } } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType, final DataType reference, final ItemDefinition itemDefinition); }
DataTypeCreateHandler extends DataTypeHandler { public List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition) { final Optional<DataType> parentOptional = lookupAbsoluteParent(reference); if (parentOptional.isPresent()) { final DataType parent = parentOptional.get(); final List<DataType> siblings = parent.getSubDataTypes(); final DataType updatedDataType = updateDataTypeProperties(dataType, parent.getUUID(), itemDefinition); final DataType parentReference = findParentReference(reference, siblings); siblings.add(siblings.indexOf(parentReference) + creationType.getIndexIncrement(), updatedDataType); recordEngine.doUpdate(dataType, itemDefinition); return recordEngine.update(parent); } else { final DataType updatedDataType = updateDataTypeProperties(dataType, reference.getParentUUID(), itemDefinition); recordEngine.doUpdate(updatedDataType, itemDefinition); return new ArrayList<>(); } } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType, final DataType reference, final ItemDefinition itemDefinition); }
@Test public void testLookupAbsoluteParentWhenReferenceDoesNotHaveParent() { final DataType reference = mock(DataType.class); final String parentUUID = "parentUUID"; when(reference.getParentUUID()).thenReturn(parentUUID); when(dataTypeStore.get(parentUUID)).thenReturn(null); final Optional<DataType> absoluteParent = handler.lookupAbsoluteParent(reference); assertFalse(absoluteParent.isPresent()); }
Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType, final DataType reference, final ItemDefinition itemDefinition); }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType, final DataType reference, final ItemDefinition itemDefinition); }
@Test public void testLookupAbsoluteParentWhenReferenceTypeIsStructure() { final DataType reference = mock(DataType.class); final DataType expectedParent = mock(DataType.class); final String parentUUID = "parentUUID"; final String structure = "Structure"; when(reference.getParentUUID()).thenReturn(parentUUID); when(expectedParent.getType()).thenReturn(structure); when(dataTypeStore.get(parentUUID)).thenReturn(expectedParent); when(dataTypeManager.structure()).thenReturn(structure); final Optional<DataType> actualParent = handler.lookupAbsoluteParent(reference); assertEquals(Optional.of(expectedParent), actualParent); }
Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType, final DataType reference, final ItemDefinition itemDefinition); }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType, final DataType reference, final ItemDefinition itemDefinition); }
@Test public void testLookupAbsoluteParentWhenReferenceTypeIsNotStructure() { final DataType reference = mock(DataType.class); final DataType expectedParent = mock(DataType.class); final DataType tCityTopLevel = mock(DataType.class); final String parentUUID = "parentUUID"; final String structure = "Structure"; final String type = "tCity"; when(reference.getParentUUID()).thenReturn(parentUUID); when(expectedParent.getType()).thenReturn(type); when(tCityTopLevel.getName()).thenReturn(type); when(dataTypeStore.get(parentUUID)).thenReturn(expectedParent); when(dataTypeManager.structure()).thenReturn(structure); when(dataTypeStore.getTopLevelDataTypes()).thenReturn(singletonList(tCityTopLevel)); final Optional<DataType> actualParent = handler.lookupAbsoluteParent(reference); assertEquals(Optional.of(tCityTopLevel), actualParent); }
Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType, final DataType reference, final ItemDefinition itemDefinition); }
DataTypeCreateHandler extends DataTypeHandler { Optional<DataType> lookupAbsoluteParent(final DataType reference) { final Optional<DataType> optionalParent = Optional.ofNullable(parent(reference)); if (optionalParent.isPresent()) { return fetchTopLevelDataType(optionalParent.get()); } return Optional.empty(); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType, final DataType reference, final ItemDefinition itemDefinition); }
@Test public void testUpdateDataType() { final String parentUUID = "parentUUID"; final DataType dataType = mock(DataType.class); final DataType expectedUpdateDataType = mock(DataType.class); final ItemDefinition itemDefinition = mock(ItemDefinition.class); final DataTypeManager dataTypeManagerWithDataType = mock(DataTypeManager.class); final DataTypeManager dataTypeManagerWithParentUUID = mock(DataTypeManager.class); final DataTypeManager dataTypeManagerWithItemDefinition = mock(DataTypeManager.class); final DataTypeManager dataTypeManagerWithIndexedItemDefinition = mock(DataTypeManager.class); final DataTypeManager dataTypeManagerWithItemDefinitionSubDataTypes = mock(DataTypeManager.class); final DataTypeManager dataTypeManagerWithUniqueName = mock(DataTypeManager.class); when(dataTypeManager.withDataType(dataType)).thenReturn(dataTypeManagerWithDataType); when(dataTypeManagerWithDataType.withParentUUID(parentUUID)).thenReturn(dataTypeManagerWithParentUUID); when(dataTypeManagerWithParentUUID.withItemDefinition(itemDefinition)).thenReturn(dataTypeManagerWithItemDefinition); when(dataTypeManagerWithItemDefinition.withIndexedItemDefinition()).thenReturn(dataTypeManagerWithIndexedItemDefinition); when(dataTypeManagerWithIndexedItemDefinition.withItemDefinitionSubDataTypes()).thenReturn(dataTypeManagerWithItemDefinitionSubDataTypes); when(dataTypeManagerWithItemDefinitionSubDataTypes.withUniqueName()).thenReturn(dataTypeManagerWithUniqueName); when(dataTypeManagerWithUniqueName.get()).thenReturn(expectedUpdateDataType); final DataType actualUpdatedDataType = handler.updateDataTypeProperties(dataType, parentUUID, itemDefinition); assertEquals(expectedUpdateDataType, actualUpdatedDataType); }
DataType updateDataTypeProperties(final DataType dataType, final String newParentUUID, final ItemDefinition newItemDefinition) { return dataTypeManager .withDataType(dataType) .withParentUUID(newParentUUID) .withItemDefinition(newItemDefinition) .withIndexedItemDefinition() .withItemDefinitionSubDataTypes() .withUniqueName() .get(); }
DataTypeCreateHandler extends DataTypeHandler { DataType updateDataTypeProperties(final DataType dataType, final String newParentUUID, final ItemDefinition newItemDefinition) { return dataTypeManager .withDataType(dataType) .withParentUUID(newParentUUID) .withItemDefinition(newItemDefinition) .withIndexedItemDefinition() .withItemDefinitionSubDataTypes() .withUniqueName() .get(); } }
DataTypeCreateHandler extends DataTypeHandler { DataType updateDataTypeProperties(final DataType dataType, final String newParentUUID, final ItemDefinition newItemDefinition) { return dataTypeManager .withDataType(dataType) .withParentUUID(newParentUUID) .withItemDefinition(newItemDefinition) .withIndexedItemDefinition() .withItemDefinitionSubDataTypes() .withUniqueName() .get(); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeCreateHandler extends DataTypeHandler { DataType updateDataTypeProperties(final DataType dataType, final String newParentUUID, final ItemDefinition newItemDefinition) { return dataTypeManager .withDataType(dataType) .withParentUUID(newParentUUID) .withItemDefinition(newItemDefinition) .withIndexedItemDefinition() .withItemDefinitionSubDataTypes() .withUniqueName() .get(); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType, final DataType reference, final ItemDefinition itemDefinition); }
DataTypeCreateHandler extends DataTypeHandler { DataType updateDataTypeProperties(final DataType dataType, final String newParentUUID, final ItemDefinition newItemDefinition) { return dataTypeManager .withDataType(dataType) .withParentUUID(newParentUUID) .withItemDefinition(newItemDefinition) .withIndexedItemDefinition() .withItemDefinitionSubDataTypes() .withUniqueName() .get(); } @Inject DataTypeCreateHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); List<DataType> append(final DataType dataType, final ItemDefinition itemDefinition); List<DataType> insertSibling(final DataType dataType, final DataType reference, final CreationType creationType, final ItemDefinition itemDefinition); List<DataType> insertNested(final DataType dataType, final DataType reference, final ItemDefinition itemDefinition); }
@Test public void testInit() { final ItemDefinitionRecordEngine expectedRecordEngine = mock(ItemDefinitionRecordEngine.class); handler.init(expectedRecordEngine); final ItemDefinitionRecordEngine actualRecordEngine = handler.getRecordEngine(); assertEquals(expectedRecordEngine, actualRecordEngine); }
public void init(final ItemDefinitionRecordEngine recordEngine) { this.recordEngine = recordEngine; }
DataTypeHandler { public void init(final ItemDefinitionRecordEngine recordEngine) { this.recordEngine = recordEngine; } }
DataTypeHandler { public void init(final ItemDefinitionRecordEngine recordEngine) { this.recordEngine = recordEngine; } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeHandler { public void init(final ItemDefinitionRecordEngine recordEngine) { this.recordEngine = recordEngine; } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
DataTypeHandler { public void init(final ItemDefinitionRecordEngine recordEngine) { this.recordEngine = recordEngine; } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
@Test public void testWbFromDMN() { final org.kie.dmn.model.api.ItemDefinition itemDefinition = new TItemDefinition(); final org.kie.dmn.model.api.ItemDefinition itemComponent1 = new TItemDefinition(); final org.kie.dmn.model.api.ItemDefinition itemComponent2 = new TItemDefinition(); final org.kie.dmn.model.api.ItemDefinition itemComponent3 = new TItemDefinition(); itemDefinition.setName("tPerson"); itemDefinition.setTypeRef(null); itemDefinition.getItemComponent().addAll(asList(itemComponent1, itemComponent2, itemComponent3)); itemComponent1.setName("id"); itemComponent1.setTypeRef(new QName("tUUID")); itemComponent2.setName("name"); itemComponent2.setTypeRef(new QName("string")); itemComponent3.setName("age"); itemComponent3.setTypeRef(new QName("number")); final ItemDefinition actualItemDefinition = ImportedItemDefinitionConverter.wbFromDMN(itemDefinition, "model"); assertEquals("model.tPerson", actualItemDefinition.getName().getValue()); assertNull(actualItemDefinition.getTypeRef()); assertTrue(actualItemDefinition.isAllowOnlyVisualChange()); assertEquals(3, actualItemDefinition.getItemComponent().size()); final ItemDefinition actualItemDefinition1 = actualItemDefinition.getItemComponent().get(0); assertEquals("model.id", actualItemDefinition1.getName().getValue()); assertEquals("model.tUUID", actualItemDefinition1.getTypeRef().getLocalPart()); assertTrue(actualItemDefinition1.isAllowOnlyVisualChange()); final ItemDefinition actualItemDefinition2 = actualItemDefinition.getItemComponent().get(1); assertEquals("model.name", actualItemDefinition2.getName().getValue()); assertEquals("string", actualItemDefinition2.getTypeRef().getLocalPart()); assertTrue(actualItemDefinition2.isAllowOnlyVisualChange()); final ItemDefinition actualItemDefinition3 = actualItemDefinition.getItemComponent().get(2); assertEquals("model.age", actualItemDefinition3.getName().getValue()); assertEquals("number", actualItemDefinition3.getTypeRef().getLocalPart()); assertTrue(actualItemDefinition3.isAllowOnlyVisualChange()); }
public static ItemDefinition wbFromDMN(final org.kie.dmn.model.api.ItemDefinition dmnItemDefinition, final String prefix) { final org.kie.dmn.model.api.ItemDefinition dmnItemDefinitionWithNamespace = withNamespace(dmnItemDefinition, prefix); final ItemDefinition wbItemDefinition = ItemDefinitionPropertyConverter.wbFromDMN(dmnItemDefinitionWithNamespace); allowOnlyVisualChange(wbItemDefinition); return wbItemDefinition; }
ImportedItemDefinitionConverter { public static ItemDefinition wbFromDMN(final org.kie.dmn.model.api.ItemDefinition dmnItemDefinition, final String prefix) { final org.kie.dmn.model.api.ItemDefinition dmnItemDefinitionWithNamespace = withNamespace(dmnItemDefinition, prefix); final ItemDefinition wbItemDefinition = ItemDefinitionPropertyConverter.wbFromDMN(dmnItemDefinitionWithNamespace); allowOnlyVisualChange(wbItemDefinition); return wbItemDefinition; } }
ImportedItemDefinitionConverter { public static ItemDefinition wbFromDMN(final org.kie.dmn.model.api.ItemDefinition dmnItemDefinition, final String prefix) { final org.kie.dmn.model.api.ItemDefinition dmnItemDefinitionWithNamespace = withNamespace(dmnItemDefinition, prefix); final ItemDefinition wbItemDefinition = ItemDefinitionPropertyConverter.wbFromDMN(dmnItemDefinitionWithNamespace); allowOnlyVisualChange(wbItemDefinition); return wbItemDefinition; } }
ImportedItemDefinitionConverter { public static ItemDefinition wbFromDMN(final org.kie.dmn.model.api.ItemDefinition dmnItemDefinition, final String prefix) { final org.kie.dmn.model.api.ItemDefinition dmnItemDefinitionWithNamespace = withNamespace(dmnItemDefinition, prefix); final ItemDefinition wbItemDefinition = ItemDefinitionPropertyConverter.wbFromDMN(dmnItemDefinitionWithNamespace); allowOnlyVisualChange(wbItemDefinition); return wbItemDefinition; } static ItemDefinition wbFromDMN(final org.kie.dmn.model.api.ItemDefinition dmnItemDefinition, final String prefix); static org.kie.dmn.model.api.ItemDefinition withNamespace(final org.kie.dmn.model.api.ItemDefinition itemDefinition, final String prefix); }
ImportedItemDefinitionConverter { public static ItemDefinition wbFromDMN(final org.kie.dmn.model.api.ItemDefinition dmnItemDefinition, final String prefix) { final org.kie.dmn.model.api.ItemDefinition dmnItemDefinitionWithNamespace = withNamespace(dmnItemDefinition, prefix); final ItemDefinition wbItemDefinition = ItemDefinitionPropertyConverter.wbFromDMN(dmnItemDefinitionWithNamespace); allowOnlyVisualChange(wbItemDefinition); return wbItemDefinition; } static ItemDefinition wbFromDMN(final org.kie.dmn.model.api.ItemDefinition dmnItemDefinition, final String prefix); static org.kie.dmn.model.api.ItemDefinition withNamespace(final org.kie.dmn.model.api.ItemDefinition itemDefinition, final String prefix); }
@Test public void testGetPMMLDocumentsPathsWhenWorkspaceProjectIsNull() { doTestGetPathsWhenWorkspaceProjectIsNull(workspaceProject1 -> pathsHelper.getPMMLModelsPaths(null)); }
@Override public List<Path> getPMMLModelsPaths(final WorkspaceProject workspaceProject) { if (workspaceProject != null) { return getPathsByWorkspaceProject(pmmlQueryTerms(workspaceProject.getRootPath().toURI())); } else { return getStandalonePaths(pmmlDocumentFilter()); } }
DMNPathsHelperImpl implements DMNPathsHelper { @Override public List<Path> getPMMLModelsPaths(final WorkspaceProject workspaceProject) { if (workspaceProject != null) { return getPathsByWorkspaceProject(pmmlQueryTerms(workspaceProject.getRootPath().toURI())); } else { return getStandalonePaths(pmmlDocumentFilter()); } } }
DMNPathsHelperImpl implements DMNPathsHelper { @Override public List<Path> getPMMLModelsPaths(final WorkspaceProject workspaceProject) { if (workspaceProject != null) { return getPathsByWorkspaceProject(pmmlQueryTerms(workspaceProject.getRootPath().toURI())); } else { return getStandalonePaths(pmmlDocumentFilter()); } } DMNPathsHelperImpl(); @Inject DMNPathsHelperImpl(final RefactoringQueryService refactoringQueryService, final DMNImportTypesHelper importTypesHelper, final @Named("ioStrategy") IOService ioService); }
DMNPathsHelperImpl implements DMNPathsHelper { @Override public List<Path> getPMMLModelsPaths(final WorkspaceProject workspaceProject) { if (workspaceProject != null) { return getPathsByWorkspaceProject(pmmlQueryTerms(workspaceProject.getRootPath().toURI())); } else { return getStandalonePaths(pmmlDocumentFilter()); } } DMNPathsHelperImpl(); @Inject DMNPathsHelperImpl(final RefactoringQueryService refactoringQueryService, final DMNImportTypesHelper importTypesHelper, final @Named("ioStrategy") IOService ioService); @Override List<Path> getModelsPaths(final WorkspaceProject workspaceProject); @Override List<Path> getDMNModelsPaths(final WorkspaceProject workspaceProject); @Override List<Path> getPMMLModelsPaths(final WorkspaceProject workspaceProject); @Override String getRelativeURI(final Path dmnModelPath, final Path includedModelPath); }
DMNPathsHelperImpl implements DMNPathsHelper { @Override public List<Path> getPMMLModelsPaths(final WorkspaceProject workspaceProject) { if (workspaceProject != null) { return getPathsByWorkspaceProject(pmmlQueryTerms(workspaceProject.getRootPath().toURI())); } else { return getStandalonePaths(pmmlDocumentFilter()); } } DMNPathsHelperImpl(); @Inject DMNPathsHelperImpl(final RefactoringQueryService refactoringQueryService, final DMNImportTypesHelper importTypesHelper, final @Named("ioStrategy") IOService ioService); @Override List<Path> getModelsPaths(final WorkspaceProject workspaceProject); @Override List<Path> getDMNModelsPaths(final WorkspaceProject workspaceProject); @Override List<Path> getPMMLModelsPaths(final WorkspaceProject workspaceProject); @Override String getRelativeURI(final Path dmnModelPath, final Path includedModelPath); }
@Test public void testGetClosestTopLevelDataType() { final DataType dataType0 = makeDataType("name", "Text", false); final DataType dataType1 = makeDataType("name", "Text", false); final DataType dataType2 = makeDataType("name", "Text", false); final DataType dataType3 = makeDataType("city", "tCity", false); final DataType dataType5 = makeDataType("street", "Structure", false, dataType1); final DataType dataType4 = makeDataType("tCity", "Structure", true, dataType0, dataType5); final DataType dataType6 = makeDataType("tPerson", "Structure", true, dataType2, dataType3); doReturn(dataType4).when(handler).parent(dataType0); doReturn(dataType4).when(handler).parent(dataType5); doReturn(dataType5).when(handler).parent(dataType1); doReturn(dataType6).when(handler).parent(dataType2); doReturn(dataType6).when(handler).parent(dataType3); when(dataTypeStore.getTopLevelDataTypes()).thenReturn(asList(dataType4, dataType6)); final DataType closestTopLevelDataTypeForDataType1 = handler.getClosestTopLevelDataType(dataType1).orElseThrow(UnsupportedOperationException::new); final DataType closestTopLevelDataTypeForDataType3 = handler.getClosestTopLevelDataType(dataType3).orElseThrow(UnsupportedOperationException::new); assertEquals(dataType4, closestTopLevelDataTypeForDataType1); assertEquals(dataType6, closestTopLevelDataTypeForDataType3); }
Optional<DataType> getClosestTopLevelDataType(final DataType dataType) { final Optional<DataType> closestTopLevelDataType = getClosestTopLevel(parent(dataType)); if (closestTopLevelDataType.isPresent()) { final DataType topLevel = closestTopLevelDataType.get(); final String type = topLevel.isTopLevel() ? topLevel.getName() : topLevel.getType(); return findTopLevelDataTypeByName(type); } return Optional.empty(); }
DataTypeHandler { Optional<DataType> getClosestTopLevelDataType(final DataType dataType) { final Optional<DataType> closestTopLevelDataType = getClosestTopLevel(parent(dataType)); if (closestTopLevelDataType.isPresent()) { final DataType topLevel = closestTopLevelDataType.get(); final String type = topLevel.isTopLevel() ? topLevel.getName() : topLevel.getType(); return findTopLevelDataTypeByName(type); } return Optional.empty(); } }
DataTypeHandler { Optional<DataType> getClosestTopLevelDataType(final DataType dataType) { final Optional<DataType> closestTopLevelDataType = getClosestTopLevel(parent(dataType)); if (closestTopLevelDataType.isPresent()) { final DataType topLevel = closestTopLevelDataType.get(); final String type = topLevel.isTopLevel() ? topLevel.getName() : topLevel.getType(); return findTopLevelDataTypeByName(type); } return Optional.empty(); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeHandler { Optional<DataType> getClosestTopLevelDataType(final DataType dataType) { final Optional<DataType> closestTopLevelDataType = getClosestTopLevel(parent(dataType)); if (closestTopLevelDataType.isPresent()) { final DataType topLevel = closestTopLevelDataType.get(); final String type = topLevel.isTopLevel() ? topLevel.getName() : topLevel.getType(); return findTopLevelDataTypeByName(type); } return Optional.empty(); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
DataTypeHandler { Optional<DataType> getClosestTopLevelDataType(final DataType dataType) { final Optional<DataType> closestTopLevelDataType = getClosestTopLevel(parent(dataType)); if (closestTopLevelDataType.isPresent()) { final DataType topLevel = closestTopLevelDataType.get(); final String type = topLevel.isTopLevel() ? topLevel.getName() : topLevel.getType(); return findTopLevelDataTypeByName(type); } return Optional.empty(); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
@Test public void testGetSubDataTypesByType() { final String type = "tCity"; final DataType dataType0 = makeDataType("tPerson", "Structure"); final DataType dataType1 = makeDataType("tCity", "Structure"); final DataType dataType2 = makeDataType("city1", "tCity"); final DataType dataType3 = makeDataType("city2", "tCity"); final DataType dataType4 = makeDataType("tCompany", "Structure"); when(dataTypeStore.getTopLevelDataTypes()).thenReturn(asList(dataType0, dataType1, dataType2, dataType3, dataType4)); final List<DataType> expectedDataTypes = asList(dataType2, dataType3); final List<DataType> actualDataTypes = handler.getSubDataTypesByType(type); assertEquals(expectedDataTypes, actualDataTypes); }
List<DataType> getSubDataTypesByType(final String type) { return new DataTypeQuery().where(dataType -> Objects.equals(dataType.getType(), type)).collect(); }
DataTypeHandler { List<DataType> getSubDataTypesByType(final String type) { return new DataTypeQuery().where(dataType -> Objects.equals(dataType.getType(), type)).collect(); } }
DataTypeHandler { List<DataType> getSubDataTypesByType(final String type) { return new DataTypeQuery().where(dataType -> Objects.equals(dataType.getType(), type)).collect(); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeHandler { List<DataType> getSubDataTypesByType(final String type) { return new DataTypeQuery().where(dataType -> Objects.equals(dataType.getType(), type)).collect(); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
DataTypeHandler { List<DataType> getSubDataTypesByType(final String type) { return new DataTypeQuery().where(dataType -> Objects.equals(dataType.getType(), type)).collect(); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
@Test public void testForEachSubDataTypesByType() { final String type = "tCity"; final DataType dataType0 = makeDataType("tPerson", "Structure"); final DataType dataType1 = makeDataType("tCity", "Structure"); final DataType dataType2 = makeDataType("city1", "tCity"); final DataType dataType3 = makeDataType("city2", "tCity"); final DataType dataType4 = makeDataType("tCompany", "Structure"); when(dataTypeStore.getTopLevelDataTypes()).thenReturn(asList(dataType0, dataType1, dataType2, dataType3, dataType4)); final List<DataType> actualDataTypes = new ArrayList<>(); final List<DataType> expectedDataTypes = asList(dataType2, dataType3); final List<DataType> forEachSubDataTypesByType = handler.forEachSubDataTypesByType(type, actualDataTypes::add); assertEquals(expectedDataTypes, actualDataTypes); assertEquals(expectedDataTypes, forEachSubDataTypesByType); }
List<DataType> forEachSubDataTypesByType(final String type, final Consumer<DataType> consumer) { return new DataTypeQuery().where(dataType -> Objects.equals(dataType.getType(), type)).apply(consumer).collect(); }
DataTypeHandler { List<DataType> forEachSubDataTypesByType(final String type, final Consumer<DataType> consumer) { return new DataTypeQuery().where(dataType -> Objects.equals(dataType.getType(), type)).apply(consumer).collect(); } }
DataTypeHandler { List<DataType> forEachSubDataTypesByType(final String type, final Consumer<DataType> consumer) { return new DataTypeQuery().where(dataType -> Objects.equals(dataType.getType(), type)).apply(consumer).collect(); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeHandler { List<DataType> forEachSubDataTypesByType(final String type, final Consumer<DataType> consumer) { return new DataTypeQuery().where(dataType -> Objects.equals(dataType.getType(), type)).apply(consumer).collect(); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
DataTypeHandler { List<DataType> forEachSubDataTypesByType(final String type, final Consumer<DataType> consumer) { return new DataTypeQuery().where(dataType -> Objects.equals(dataType.getType(), type)).apply(consumer).collect(); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
@Test public void testForEachSubDataTypesByTypeOrName() { final String type = "tCompany"; final DataType dataType0 = makeDataType("RedHat", "tCompany"); final DataType dataType1 = makeDataType("tPerson", "Structure"); final DataType dataType2 = makeDataType("tCity", "Structure"); final DataType dataType3 = makeDataType("city1", "tCity"); final DataType dataType4 = makeDataType("city2", "tCity"); final DataType dataType5 = makeDataType("tCompany", "Structure"); when(dataTypeStore.getTopLevelDataTypes()).thenReturn(asList(dataType0, dataType1, dataType2, dataType3, dataType4, dataType5)); final List<DataType> actualDataTypes = new ArrayList<>(); final List<DataType> expectedDataTypes = asList(dataType0, dataType5); final List<DataType> forEachSubDataTypesByType = handler.forEachSubDataTypesByTypeOrName(type, actualDataTypes::add); assertEquals(expectedDataTypes, actualDataTypes); assertEquals(expectedDataTypes, forEachSubDataTypesByType); }
List<DataType> forEachSubDataTypesByTypeOrName(final String typeOrName, final Consumer<DataType> consumer) { return new DataTypeQuery() .where(dataType -> Objects.equals(dataType.getType(), typeOrName) || Objects.equals(dataType.getName(), typeOrName)) .apply(consumer) .collect(); }
DataTypeHandler { List<DataType> forEachSubDataTypesByTypeOrName(final String typeOrName, final Consumer<DataType> consumer) { return new DataTypeQuery() .where(dataType -> Objects.equals(dataType.getType(), typeOrName) || Objects.equals(dataType.getName(), typeOrName)) .apply(consumer) .collect(); } }
DataTypeHandler { List<DataType> forEachSubDataTypesByTypeOrName(final String typeOrName, final Consumer<DataType> consumer) { return new DataTypeQuery() .where(dataType -> Objects.equals(dataType.getType(), typeOrName) || Objects.equals(dataType.getName(), typeOrName)) .apply(consumer) .collect(); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeHandler { List<DataType> forEachSubDataTypesByTypeOrName(final String typeOrName, final Consumer<DataType> consumer) { return new DataTypeQuery() .where(dataType -> Objects.equals(dataType.getType(), typeOrName) || Objects.equals(dataType.getName(), typeOrName)) .apply(consumer) .collect(); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
DataTypeHandler { List<DataType> forEachSubDataTypesByTypeOrName(final String typeOrName, final Consumer<DataType> consumer) { return new DataTypeQuery() .where(dataType -> Objects.equals(dataType.getType(), typeOrName) || Objects.equals(dataType.getName(), typeOrName)) .apply(consumer) .collect(); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
@Test public void testRefreshSubDataTypes() { final DataTypeManager dataTypeManagerWithDataType = mock(DataTypeManager.class); final DataType dataType = makeDataType(); final String type = "type"; doNothing().when(handler).refreshSubDataTypes(any(), anyString()); when(dataTypeManager.withDataType(dataType)).thenReturn(dataTypeManagerWithDataType); when(dataTypeManagerWithDataType.getTypeName()).thenReturn(type); handler.refreshSubDataTypes(dataType); verify(handler).refreshSubDataTypes(dataType, type); }
void refreshSubDataTypes(final DataType dataType) { final String type = dataTypeManager.withDataType(dataType).getTypeName(); refreshSubDataTypes(dataType, type); }
DataTypeHandler { void refreshSubDataTypes(final DataType dataType) { final String type = dataTypeManager.withDataType(dataType).getTypeName(); refreshSubDataTypes(dataType, type); } }
DataTypeHandler { void refreshSubDataTypes(final DataType dataType) { final String type = dataTypeManager.withDataType(dataType).getTypeName(); refreshSubDataTypes(dataType, type); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeHandler { void refreshSubDataTypes(final DataType dataType) { final String type = dataTypeManager.withDataType(dataType).getTypeName(); refreshSubDataTypes(dataType, type); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
DataTypeHandler { void refreshSubDataTypes(final DataType dataType) { final String type = dataTypeManager.withDataType(dataType).getTypeName(); refreshSubDataTypes(dataType, type); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
@Test public void testRefreshSubDataTypesWithNewType() { final DataType dataType = makeDataType(); final String newType = "newType"; when(dataTypeManager.from(any(DataType.class))).thenReturn(dataTypeManager); when(dataTypeManager.withRefreshedSubDataTypes(anyString())).thenReturn(dataTypeManager); handler.refreshSubDataTypes(dataType, newType); final InOrder inOrder = Mockito.inOrder(dataTypeManager); inOrder.verify(dataTypeManager).from(dataType); inOrder.verify(dataTypeManager).withRefreshedSubDataTypes(newType); }
void refreshSubDataTypes(final DataType dataType) { final String type = dataTypeManager.withDataType(dataType).getTypeName(); refreshSubDataTypes(dataType, type); }
DataTypeHandler { void refreshSubDataTypes(final DataType dataType) { final String type = dataTypeManager.withDataType(dataType).getTypeName(); refreshSubDataTypes(dataType, type); } }
DataTypeHandler { void refreshSubDataTypes(final DataType dataType) { final String type = dataTypeManager.withDataType(dataType).getTypeName(); refreshSubDataTypes(dataType, type); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeHandler { void refreshSubDataTypes(final DataType dataType) { final String type = dataTypeManager.withDataType(dataType).getTypeName(); refreshSubDataTypes(dataType, type); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
DataTypeHandler { void refreshSubDataTypes(final DataType dataType) { final String type = dataTypeManager.withDataType(dataType).getTypeName(); refreshSubDataTypes(dataType, type); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
@Test public void testParent() { final DataType dataType = makeDataType(); final DataType expectedParent = makeDataType(); final String parentUUID = "parentUUID"; when(dataType.getParentUUID()).thenReturn(parentUUID); when(dataTypeStore.get(parentUUID)).thenReturn(expectedParent); final DataType actualParent = handler.parent(dataType); assertEquals(expectedParent, actualParent); }
DataType parent(final DataType dataType) { return dataTypeStore.get(dataType.getParentUUID()); }
DataTypeHandler { DataType parent(final DataType dataType) { return dataTypeStore.get(dataType.getParentUUID()); } }
DataTypeHandler { DataType parent(final DataType dataType) { return dataTypeStore.get(dataType.getParentUUID()); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeHandler { DataType parent(final DataType dataType) { return dataTypeStore.get(dataType.getParentUUID()); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
DataTypeHandler { DataType parent(final DataType dataType) { return dataTypeStore.get(dataType.getParentUUID()); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
@Test public void testIsStructureWhenItReturnsTrue() { final DataType dataType = mock(DataType.class); final String structure = "Structure"; when(dataTypeManager.structure()).thenReturn(structure); when(dataType.getType()).thenReturn(structure); assertTrue(handler.isStructure(dataType)); }
boolean isStructure(final DataType dataType) { return Objects.equals(dataType.getType(), dataTypeManager.structure()); }
DataTypeHandler { boolean isStructure(final DataType dataType) { return Objects.equals(dataType.getType(), dataTypeManager.structure()); } }
DataTypeHandler { boolean isStructure(final DataType dataType) { return Objects.equals(dataType.getType(), dataTypeManager.structure()); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeHandler { boolean isStructure(final DataType dataType) { return Objects.equals(dataType.getType(), dataTypeManager.structure()); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
DataTypeHandler { boolean isStructure(final DataType dataType) { return Objects.equals(dataType.getType(), dataTypeManager.structure()); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
@Test public void testIsStructureWhenItReturnsFalse() { final DataType dataType = mock(DataType.class); when(dataTypeManager.structure()).thenReturn("Structure"); when(dataType.getType()).thenReturn("tCity"); assertFalse(handler.isStructure(dataType)); }
boolean isStructure(final DataType dataType) { return Objects.equals(dataType.getType(), dataTypeManager.structure()); }
DataTypeHandler { boolean isStructure(final DataType dataType) { return Objects.equals(dataType.getType(), dataTypeManager.structure()); } }
DataTypeHandler { boolean isStructure(final DataType dataType) { return Objects.equals(dataType.getType(), dataTypeManager.structure()); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeHandler { boolean isStructure(final DataType dataType) { return Objects.equals(dataType.getType(), dataTypeManager.structure()); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
DataTypeHandler { boolean isStructure(final DataType dataType) { return Objects.equals(dataType.getType(), dataTypeManager.structure()); } DataTypeHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void init(final ItemDefinitionRecordEngine recordEngine); }
@Test public void testNotifyPanel() { final Node node1 = mock(Node.class); final Node node2 = mock(Node.class); final Object definition1 = mock(Object.class); final Object definition2 = mock(Object.class); doReturn(asList(node1, node2)).when(notifier).getNodes(); doReturn(definition1).when(notifier).getDefinition(node1); doReturn(definition2).when(notifier).getDefinition(node2); notifier.notifyPanel(); verify(notifier).notifyVariables(node1, definition1); verify(notifier).notifyExpressions(node2, definition2); }
public void notifyPanel() { for (final Node node : getNodes()) { final Object definition = getDefinition(node); notifyVariables(node, definition); notifyExpressions(node, definition); } }
PropertiesPanelNotifier { public void notifyPanel() { for (final Node node : getNodes()) { final Object definition = getDefinition(node); notifyVariables(node, definition); notifyExpressions(node, definition); } } }
PropertiesPanelNotifier { public void notifyPanel() { for (final Node node : getNodes()) { final Object definition = getDefinition(node); notifyVariables(node, definition); notifyExpressions(node, definition); } } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); }
PropertiesPanelNotifier { public void notifyPanel() { for (final Node node : getNodes()) { final Object definition = getDefinition(node); notifyVariables(node, definition); notifyExpressions(node, definition); } } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
PropertiesPanelNotifier { public void notifyPanel() { for (final Node node : getNodes()) { final Object definition = getDefinition(node); notifyVariables(node, definition); notifyExpressions(node, definition); } } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
@Test public void testWbFromDMN() { final String name = "name"; when(ruleAnnotationClause.getName()).thenReturn(name); final RuleAnnotationClause converted = RuleAnnotationClauseConverter.wbFromDMN(ruleAnnotationClause); assertEquals(name, converted.getName().getValue()); }
public static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause) { if (ruleAnnotationClause == null) { return null; } final RuleAnnotationClause rule = new RuleAnnotationClause(); rule.setName(new Name(ruleAnnotationClause.getName())); return rule; }
RuleAnnotationClauseConverter { public static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause) { if (ruleAnnotationClause == null) { return null; } final RuleAnnotationClause rule = new RuleAnnotationClause(); rule.setName(new Name(ruleAnnotationClause.getName())); return rule; } }
RuleAnnotationClauseConverter { public static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause) { if (ruleAnnotationClause == null) { return null; } final RuleAnnotationClause rule = new RuleAnnotationClause(); rule.setName(new Name(ruleAnnotationClause.getName())); return rule; } }
RuleAnnotationClauseConverter { public static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause) { if (ruleAnnotationClause == null) { return null; } final RuleAnnotationClause rule = new RuleAnnotationClause(); rule.setName(new Name(ruleAnnotationClause.getName())); return rule; } static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause); static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb); }
RuleAnnotationClauseConverter { public static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause) { if (ruleAnnotationClause == null) { return null; } final RuleAnnotationClause rule = new RuleAnnotationClause(); rule.setName(new Name(ruleAnnotationClause.getName())); return rule; } static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause); static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb); }
@Test public void testOnCanvasSelectionEvent() { final CanvasSelectionEvent selectionEvent = mock(CanvasSelectionEvent.class); final String uuid1 = "uuid1"; final String uuid2 = "uuid2"; final List<String> t = asList(uuid1, uuid2); when(selectionEvent.getIdentifiers()).thenReturn(t); notifier.onCanvasSelectionEvent(selectionEvent); verify(notifier).setSelectedElementUUID(uuid1); }
void onCanvasSelectionEvent(final @Observes CanvasSelectionEvent event) { final Collection<String> identifiers = event.getIdentifiers(); if (identifiers.size() > 0) { setSelectedElementUUID(identifiers.iterator().next()); } }
PropertiesPanelNotifier { void onCanvasSelectionEvent(final @Observes CanvasSelectionEvent event) { final Collection<String> identifiers = event.getIdentifiers(); if (identifiers.size() > 0) { setSelectedElementUUID(identifiers.iterator().next()); } } }
PropertiesPanelNotifier { void onCanvasSelectionEvent(final @Observes CanvasSelectionEvent event) { final Collection<String> identifiers = event.getIdentifiers(); if (identifiers.size() > 0) { setSelectedElementUUID(identifiers.iterator().next()); } } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); }
PropertiesPanelNotifier { void onCanvasSelectionEvent(final @Observes CanvasSelectionEvent event) { final Collection<String> identifiers = event.getIdentifiers(); if (identifiers.size() > 0) { setSelectedElementUUID(identifiers.iterator().next()); } } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
PropertiesPanelNotifier { void onCanvasSelectionEvent(final @Observes CanvasSelectionEvent event) { final Collection<String> identifiers = event.getIdentifiers(); if (identifiers.size() > 0) { setSelectedElementUUID(identifiers.iterator().next()); } } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
@Test public void testOnDomainObjectSelectionEvent() { final DomainObjectSelectionEvent selectionEvent = mock(DomainObjectSelectionEvent.class); final DomainObject domainObject = mock(DomainObject.class); final String uuid = "uuid"; when(selectionEvent.getDomainObject()).thenReturn(domainObject); when(domainObject.getDomainObjectUUID()).thenReturn(uuid); notifier.onDomainObjectSelectionEvent(selectionEvent); verify(notifier).setSelectedElementUUID(uuid); }
void onDomainObjectSelectionEvent(final @Observes DomainObjectSelectionEvent event) { setSelectedElementUUID(event.getDomainObject().getDomainObjectUUID()); }
PropertiesPanelNotifier { void onDomainObjectSelectionEvent(final @Observes DomainObjectSelectionEvent event) { setSelectedElementUUID(event.getDomainObject().getDomainObjectUUID()); } }
PropertiesPanelNotifier { void onDomainObjectSelectionEvent(final @Observes DomainObjectSelectionEvent event) { setSelectedElementUUID(event.getDomainObject().getDomainObjectUUID()); } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); }
PropertiesPanelNotifier { void onDomainObjectSelectionEvent(final @Observes DomainObjectSelectionEvent event) { setSelectedElementUUID(event.getDomainObject().getDomainObjectUUID()); } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
PropertiesPanelNotifier { void onDomainObjectSelectionEvent(final @Observes DomainObjectSelectionEvent event) { setSelectedElementUUID(event.getDomainObject().getDomainObjectUUID()); } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
@Test public void testNotifyExpressions() { final Node node = mock(Node.class); final HasExpression hasExpression = mock(HasExpression.class); final Expression expression = mock(Expression.class); final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class); final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class); when(expression.getHasTypeRefs()).thenReturn(asList(hasTypeRef1, hasTypeRef2)); when(hasExpression.getExpression()).thenReturn(expression); doNothing().when(notifier).notifyOutdatedElement(any(), any()); notifier.notifyExpressions(node, hasExpression); verify(notifier).notifyOutdatedElement(node, hasTypeRef1); verify(notifier).notifyOutdatedElement(node, hasTypeRef2); }
void notifyExpressions(final Node node, final Object definition) { if (definition instanceof HasExpression) { final HasExpression hasExpression = asHasExpression(definition); final List<HasTypeRef> hasTypeRefs = getNotNullHasTypeRefs(hasExpression.getExpression()); for (final HasTypeRef hasTypeRef : hasTypeRefs) { notifyOutdatedElement(node, hasTypeRef); } } }
PropertiesPanelNotifier { void notifyExpressions(final Node node, final Object definition) { if (definition instanceof HasExpression) { final HasExpression hasExpression = asHasExpression(definition); final List<HasTypeRef> hasTypeRefs = getNotNullHasTypeRefs(hasExpression.getExpression()); for (final HasTypeRef hasTypeRef : hasTypeRefs) { notifyOutdatedElement(node, hasTypeRef); } } } }
PropertiesPanelNotifier { void notifyExpressions(final Node node, final Object definition) { if (definition instanceof HasExpression) { final HasExpression hasExpression = asHasExpression(definition); final List<HasTypeRef> hasTypeRefs = getNotNullHasTypeRefs(hasExpression.getExpression()); for (final HasTypeRef hasTypeRef : hasTypeRefs) { notifyOutdatedElement(node, hasTypeRef); } } } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); }
PropertiesPanelNotifier { void notifyExpressions(final Node node, final Object definition) { if (definition instanceof HasExpression) { final HasExpression hasExpression = asHasExpression(definition); final List<HasTypeRef> hasTypeRefs = getNotNullHasTypeRefs(hasExpression.getExpression()); for (final HasTypeRef hasTypeRef : hasTypeRefs) { notifyOutdatedElement(node, hasTypeRef); } } } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
PropertiesPanelNotifier { void notifyExpressions(final Node node, final Object definition) { if (definition instanceof HasExpression) { final HasExpression hasExpression = asHasExpression(definition); final List<HasTypeRef> hasTypeRefs = getNotNullHasTypeRefs(hasExpression.getExpression()); for (final HasTypeRef hasTypeRef : hasTypeRefs) { notifyOutdatedElement(node, hasTypeRef); } } } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
@Test public void testNotifyVariables() { final Node node = mock(Node.class); final HasVariable hasVariable = mock(HasVariable.class); final IsInformationItem informationItem = mock(IsInformationItem.class); when(hasVariable.getVariable()).thenReturn(informationItem); doNothing().when(notifier).notifyOutdatedElement(any(), any()); notifier.notifyVariables(node, hasVariable); verify(notifier).notifyOutdatedElement(node, informationItem); }
void notifyVariables(final Node node, final Object definition) { if (definition instanceof HasVariable) { notifyOutdatedElement(node, asHasVariable(definition).getVariable()); } }
PropertiesPanelNotifier { void notifyVariables(final Node node, final Object definition) { if (definition instanceof HasVariable) { notifyOutdatedElement(node, asHasVariable(definition).getVariable()); } } }
PropertiesPanelNotifier { void notifyVariables(final Node node, final Object definition) { if (definition instanceof HasVariable) { notifyOutdatedElement(node, asHasVariable(definition).getVariable()); } } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); }
PropertiesPanelNotifier { void notifyVariables(final Node node, final Object definition) { if (definition instanceof HasVariable) { notifyOutdatedElement(node, asHasVariable(definition).getVariable()); } } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
PropertiesPanelNotifier { void notifyVariables(final Node node, final Object definition) { if (definition instanceof HasVariable) { notifyOutdatedElement(node, asHasVariable(definition).getVariable()); } } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
@Test public void testGetDefinition() { final Node node = mock(Node.class); final ViewImpl content = mock(ViewImpl.class); final Object expected = mock(Object.class); when(content.getDefinition()).thenReturn(expected); when(node.getContent()).thenReturn(content); final Object actual = notifier.getDefinition(node); assertEquals(expected, actual); }
Object getDefinition(final Node node) { final ViewImpl content = (ViewImpl) node.getContent(); return content.getDefinition(); }
PropertiesPanelNotifier { Object getDefinition(final Node node) { final ViewImpl content = (ViewImpl) node.getContent(); return content.getDefinition(); } }
PropertiesPanelNotifier { Object getDefinition(final Node node) { final ViewImpl content = (ViewImpl) node.getContent(); return content.getDefinition(); } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); }
PropertiesPanelNotifier { Object getDefinition(final Node node) { final ViewImpl content = (ViewImpl) node.getContent(); return content.getDefinition(); } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
PropertiesPanelNotifier { Object getDefinition(final Node node) { final ViewImpl content = (ViewImpl) node.getContent(); return content.getDefinition(); } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
@Test public void testGetNodes() { final Graph graph = mock(Graph.class); final Node node1 = mock(Node.class); final Node node2 = mock(Node.class); final Iterable<Node> expectedNodes = asList(node1, node2); when(graph.nodes()).thenReturn(expectedNodes); doReturn(Optional.of(graph)).when(notifier).getGraph(); final List<Node> actualNodes = notifier.getNodes(); assertEquals(expectedNodes, actualNodes); }
List<Node> getNodes() { final List<Node> nodes = new ArrayList<>(); getGraph().ifPresent(graph -> { graph.nodes().forEach(nodes::add); }); return nodes; }
PropertiesPanelNotifier { List<Node> getNodes() { final List<Node> nodes = new ArrayList<>(); getGraph().ifPresent(graph -> { graph.nodes().forEach(nodes::add); }); return nodes; } }
PropertiesPanelNotifier { List<Node> getNodes() { final List<Node> nodes = new ArrayList<>(); getGraph().ifPresent(graph -> { graph.nodes().forEach(nodes::add); }); return nodes; } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); }
PropertiesPanelNotifier { List<Node> getNodes() { final List<Node> nodes = new ArrayList<>(); getGraph().ifPresent(graph -> { graph.nodes().forEach(nodes::add); }); return nodes; } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
PropertiesPanelNotifier { List<Node> getNodes() { final List<Node> nodes = new ArrayList<>(); getGraph().ifPresent(graph -> { graph.nodes().forEach(nodes::add); }); return nodes; } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
@Test public void testGetGraph() { final ClientSession clientSession = mock(ClientSession.class); final CanvasHandler canvasHandler = mock(CanvasHandler.class); final Diagram diagram = mock(Diagram.class); final Optional<Graph> expected = Optional.of(mock(Graph.class)); when(diagram.getGraph()).thenReturn(expected.get()); when(canvasHandler.getDiagram()).thenReturn(diagram); when(clientSession.getCanvasHandler()).thenReturn(canvasHandler); when(sessionManager.getCurrentSession()).thenReturn(clientSession); final Optional<Graph<?, Node>> actual = notifier.getGraph(); assertEquals(expected, actual); }
Optional<Graph<?, Node>> getGraph() { final Optional<CanvasHandler> canvasHandler = getCurrentSession().map(ClientSession::getCanvasHandler); final Optional<Diagram> diagram = canvasHandler.map(CanvasHandler::getDiagram); return diagram.map(Diagram::getGraph); }
PropertiesPanelNotifier { Optional<Graph<?, Node>> getGraph() { final Optional<CanvasHandler> canvasHandler = getCurrentSession().map(ClientSession::getCanvasHandler); final Optional<Diagram> diagram = canvasHandler.map(CanvasHandler::getDiagram); return diagram.map(Diagram::getGraph); } }
PropertiesPanelNotifier { Optional<Graph<?, Node>> getGraph() { final Optional<CanvasHandler> canvasHandler = getCurrentSession().map(ClientSession::getCanvasHandler); final Optional<Diagram> diagram = canvasHandler.map(CanvasHandler::getDiagram); return diagram.map(Diagram::getGraph); } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); }
PropertiesPanelNotifier { Optional<Graph<?, Node>> getGraph() { final Optional<CanvasHandler> canvasHandler = getCurrentSession().map(ClientSession::getCanvasHandler); final Optional<Diagram> diagram = canvasHandler.map(CanvasHandler::getDiagram); return diagram.map(Diagram::getGraph); } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
PropertiesPanelNotifier { Optional<Graph<?, Node>> getGraph() { final Optional<CanvasHandler> canvasHandler = getCurrentSession().map(ClientSession::getCanvasHandler); final Optional<Diagram> diagram = canvasHandler.map(CanvasHandler::getDiagram); return diagram.map(Diagram::getGraph); } @Inject PropertiesPanelNotifier(final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent, final SessionManager sessionManager); PropertiesPanelNotifier withOldLocalPart(final String oldLocalPart); PropertiesPanelNotifier withNewQName(final QName newQName); void notifyPanel(); }
@Test public void testUpdateWhenDataTypeIsDefault() { final DataType dataType = mock(DataType.class); when(dataType.getType()).thenReturn(BuiltInType.STRING.getName()); handler.update(dataType); verify(dataTypeManager, never()).from(any(DataType.class)); verify(dataTypeManager, never()).withRefreshedSubDataTypes(anyString()); }
public void update(final DataType dataType) { final String type = getTypeName(dataType); if (!isBuiltInType(type)) { dataTypeManager .from(dataType) .withRefreshedSubDataTypes(type); } }
DataTypeUpdateHandler extends DataTypeHandler { public void update(final DataType dataType) { final String type = getTypeName(dataType); if (!isBuiltInType(type)) { dataTypeManager .from(dataType) .withRefreshedSubDataTypes(type); } } }
DataTypeUpdateHandler extends DataTypeHandler { public void update(final DataType dataType) { final String type = getTypeName(dataType); if (!isBuiltInType(type)) { dataTypeManager .from(dataType) .withRefreshedSubDataTypes(type); } } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeUpdateHandler extends DataTypeHandler { public void update(final DataType dataType) { final String type = getTypeName(dataType); if (!isBuiltInType(type)) { dataTypeManager .from(dataType) .withRefreshedSubDataTypes(type); } } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void update(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName); }
DataTypeUpdateHandler extends DataTypeHandler { public void update(final DataType dataType) { final String type = getTypeName(dataType); if (!isBuiltInType(type)) { dataTypeManager .from(dataType) .withRefreshedSubDataTypes(type); } } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void update(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName); }
@Test public void testUpdateWhenDataTypeIsNotDefault() { final DataType dataType = mock(DataType.class); final String name = "city"; final String type = "tCity"; when(dataType.getName()).thenReturn(name); when(dataType.getType()).thenReturn(type); when(dataTypeManager.from(any(DataType.class))).thenReturn(dataTypeManager); when(dataTypeManager.withRefreshedSubDataTypes(anyString())).thenReturn(dataTypeManager); handler.update(dataType); final InOrder inOrder = Mockito.inOrder(dataTypeManager); inOrder.verify(dataTypeManager).from(dataType); inOrder.verify(dataTypeManager).withRefreshedSubDataTypes(type); }
public void update(final DataType dataType) { final String type = getTypeName(dataType); if (!isBuiltInType(type)) { dataTypeManager .from(dataType) .withRefreshedSubDataTypes(type); } }
DataTypeUpdateHandler extends DataTypeHandler { public void update(final DataType dataType) { final String type = getTypeName(dataType); if (!isBuiltInType(type)) { dataTypeManager .from(dataType) .withRefreshedSubDataTypes(type); } } }
DataTypeUpdateHandler extends DataTypeHandler { public void update(final DataType dataType) { final String type = getTypeName(dataType); if (!isBuiltInType(type)) { dataTypeManager .from(dataType) .withRefreshedSubDataTypes(type); } } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeUpdateHandler extends DataTypeHandler { public void update(final DataType dataType) { final String type = getTypeName(dataType); if (!isBuiltInType(type)) { dataTypeManager .from(dataType) .withRefreshedSubDataTypes(type); } } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void update(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName); }
DataTypeUpdateHandler extends DataTypeHandler { public void update(final DataType dataType) { final String type = getTypeName(dataType); if (!isBuiltInType(type)) { dataTypeManager .from(dataType) .withRefreshedSubDataTypes(type); } } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void update(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName); }
@Test public void testRefreshDependentDataTypes() { final DataType dataType = mock(DataType.class); final String oldItemDefinitionName = "oldItemDefinitionName"; final DataType dataType0 = mock(DataType.class); final DataType dataType1 = mock(DataType.class); final DataType dataType2 = mock(DataType.class); final DataType dataType3 = mock(DataType.class); doReturn(asList(dataType0, dataType1)).when(handler).handleTopLevelDataTypeUpdate(dataType, oldItemDefinitionName); doReturn(asList(dataType2, dataType3)).when(handler).handleNestedDataTypeFieldUpdate(dataType); final List<DataType> expectedDataTypes = asList(dataType0, dataType1, dataType2, dataType3); final List<DataType> actualDataTypes = handler.refreshDependentDataTypes(dataType, oldItemDefinitionName); assertEquals(expectedDataTypes, actualDataTypes); }
public List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.addAll(handleTopLevelDataTypeUpdate(dataType, oldItemDefinitionName)); affectedDataTypes.addAll(handleNestedDataTypeFieldUpdate(dataType)); return affectedDataTypes; }
DataTypeUpdateHandler extends DataTypeHandler { public List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.addAll(handleTopLevelDataTypeUpdate(dataType, oldItemDefinitionName)); affectedDataTypes.addAll(handleNestedDataTypeFieldUpdate(dataType)); return affectedDataTypes; } }
DataTypeUpdateHandler extends DataTypeHandler { public List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.addAll(handleTopLevelDataTypeUpdate(dataType, oldItemDefinitionName)); affectedDataTypes.addAll(handleNestedDataTypeFieldUpdate(dataType)); return affectedDataTypes; } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeUpdateHandler extends DataTypeHandler { public List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.addAll(handleTopLevelDataTypeUpdate(dataType, oldItemDefinitionName)); affectedDataTypes.addAll(handleNestedDataTypeFieldUpdate(dataType)); return affectedDataTypes; } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void update(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName); }
DataTypeUpdateHandler extends DataTypeHandler { public List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.addAll(handleTopLevelDataTypeUpdate(dataType, oldItemDefinitionName)); affectedDataTypes.addAll(handleNestedDataTypeFieldUpdate(dataType)); return affectedDataTypes; } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void update(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName); }
@Test public void testWbFromDMNWhenIsNull() { final RuleAnnotationClause converted = RuleAnnotationClauseConverter.wbFromDMN(null); assertNull(converted); }
public static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause) { if (ruleAnnotationClause == null) { return null; } final RuleAnnotationClause rule = new RuleAnnotationClause(); rule.setName(new Name(ruleAnnotationClause.getName())); return rule; }
RuleAnnotationClauseConverter { public static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause) { if (ruleAnnotationClause == null) { return null; } final RuleAnnotationClause rule = new RuleAnnotationClause(); rule.setName(new Name(ruleAnnotationClause.getName())); return rule; } }
RuleAnnotationClauseConverter { public static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause) { if (ruleAnnotationClause == null) { return null; } final RuleAnnotationClause rule = new RuleAnnotationClause(); rule.setName(new Name(ruleAnnotationClause.getName())); return rule; } }
RuleAnnotationClauseConverter { public static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause) { if (ruleAnnotationClause == null) { return null; } final RuleAnnotationClause rule = new RuleAnnotationClause(); rule.setName(new Name(ruleAnnotationClause.getName())); return rule; } static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause); static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb); }
RuleAnnotationClauseConverter { public static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause) { if (ruleAnnotationClause == null) { return null; } final RuleAnnotationClause rule = new RuleAnnotationClause(); rule.setName(new Name(ruleAnnotationClause.getName())); return rule; } static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause); static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb); }
@Test public void testHandleTopLevelDataTypeUpdate() { final DataType dataType = mock(DataType.class); final DataType dataType0 = mock(DataType.class); final DataType dataType1 = mock(DataType.class); final List<DataType> expectedDataTypes = asList(dataType0, dataType1); final String oldItemDefinitionName = "oldItemDefinitionName"; doReturn(expectedDataTypes).when(handler).updateAllChildrenWithTheNewTypeName(dataType, oldItemDefinitionName); final List<DataType> actualDataTypes = handler.handleTopLevelDataTypeUpdate(dataType, oldItemDefinitionName); assertEquals(expectedDataTypes, actualDataTypes); }
List<DataType> handleTopLevelDataTypeUpdate(final DataType dataType, final String oldItemDefinitionName) { return updateAllChildrenWithTheNewTypeName(dataType, oldItemDefinitionName); }
DataTypeUpdateHandler extends DataTypeHandler { List<DataType> handleTopLevelDataTypeUpdate(final DataType dataType, final String oldItemDefinitionName) { return updateAllChildrenWithTheNewTypeName(dataType, oldItemDefinitionName); } }
DataTypeUpdateHandler extends DataTypeHandler { List<DataType> handleTopLevelDataTypeUpdate(final DataType dataType, final String oldItemDefinitionName) { return updateAllChildrenWithTheNewTypeName(dataType, oldItemDefinitionName); } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeUpdateHandler extends DataTypeHandler { List<DataType> handleTopLevelDataTypeUpdate(final DataType dataType, final String oldItemDefinitionName) { return updateAllChildrenWithTheNewTypeName(dataType, oldItemDefinitionName); } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void update(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName); }
DataTypeUpdateHandler extends DataTypeHandler { List<DataType> handleTopLevelDataTypeUpdate(final DataType dataType, final String oldItemDefinitionName) { return updateAllChildrenWithTheNewTypeName(dataType, oldItemDefinitionName); } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void update(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName); }
@Test public void testHandleNestedDataTypeFieldUpdateWhenDataTypeIsNotStructure() { final DataType dataType = mock(DataType.class); final DataType topLevelDataType = mock(DataType.class); final DataType dataType0 = mock(DataType.class); final DataType dataType1 = mock(DataType.class); final DataType dataType2 = mock(DataType.class); final String name = "name"; final String type = "type"; when(dataType0.getType()).thenReturn(name); when(dataType1.getType()).thenReturn(type); when(dataType2.getName()).thenReturn(type); when(topLevelDataType.getName()).thenReturn(name); when(topLevelDataType.getType()).thenReturn(type); when(dataTypeStore.getTopLevelDataTypes()).thenReturn(asList(dataType0, dataType1, dataType2)); doReturn(Optional.of(topLevelDataType)).when(handler).getClosestTopLevelDataType(dataType); doReturn(false).when(handler).isStructure(dataType); doNothing().when(handler).refreshSubDataTypes(any(), anyString()); final List<DataType> expectedDataTypes = asList(dataType1, dataType2, topLevelDataType); final List<DataType> actualDataTypes = handler.handleNestedDataTypeFieldUpdate(dataType); verify(handler).refreshSubDataTypes(topLevelDataType, name); verify(handler).refreshSubDataTypes(dataType1, type); verify(handler).refreshSubDataTypes(dataType2, type); assertEquals(expectedDataTypes, actualDataTypes); }
List<DataType> handleNestedDataTypeFieldUpdate(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); getClosestTopLevelDataType(dataType) .ifPresent(topLevelUpdate -> { refreshSubDataTypes(topLevelUpdate, topLevelUpdate.getName()); if (!isStructure(topLevelUpdate)) { forEachSubDataTypesByTypeOrName(topLevelUpdate.getType(), subDataType -> { refreshSubDataTypes(subDataType, topLevelUpdate.getType()); affectedDataTypes.add(subDataType); }); } else { affectedDataTypes.addAll(handleTopLevelDataTypeUpdate(topLevelUpdate, topLevelUpdate.getName())); } affectedDataTypes.add(topLevelUpdate); }); return affectedDataTypes; }
DataTypeUpdateHandler extends DataTypeHandler { List<DataType> handleNestedDataTypeFieldUpdate(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); getClosestTopLevelDataType(dataType) .ifPresent(topLevelUpdate -> { refreshSubDataTypes(topLevelUpdate, topLevelUpdate.getName()); if (!isStructure(topLevelUpdate)) { forEachSubDataTypesByTypeOrName(topLevelUpdate.getType(), subDataType -> { refreshSubDataTypes(subDataType, topLevelUpdate.getType()); affectedDataTypes.add(subDataType); }); } else { affectedDataTypes.addAll(handleTopLevelDataTypeUpdate(topLevelUpdate, topLevelUpdate.getName())); } affectedDataTypes.add(topLevelUpdate); }); return affectedDataTypes; } }
DataTypeUpdateHandler extends DataTypeHandler { List<DataType> handleNestedDataTypeFieldUpdate(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); getClosestTopLevelDataType(dataType) .ifPresent(topLevelUpdate -> { refreshSubDataTypes(topLevelUpdate, topLevelUpdate.getName()); if (!isStructure(topLevelUpdate)) { forEachSubDataTypesByTypeOrName(topLevelUpdate.getType(), subDataType -> { refreshSubDataTypes(subDataType, topLevelUpdate.getType()); affectedDataTypes.add(subDataType); }); } else { affectedDataTypes.addAll(handleTopLevelDataTypeUpdate(topLevelUpdate, topLevelUpdate.getName())); } affectedDataTypes.add(topLevelUpdate); }); return affectedDataTypes; } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeUpdateHandler extends DataTypeHandler { List<DataType> handleNestedDataTypeFieldUpdate(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); getClosestTopLevelDataType(dataType) .ifPresent(topLevelUpdate -> { refreshSubDataTypes(topLevelUpdate, topLevelUpdate.getName()); if (!isStructure(topLevelUpdate)) { forEachSubDataTypesByTypeOrName(topLevelUpdate.getType(), subDataType -> { refreshSubDataTypes(subDataType, topLevelUpdate.getType()); affectedDataTypes.add(subDataType); }); } else { affectedDataTypes.addAll(handleTopLevelDataTypeUpdate(topLevelUpdate, topLevelUpdate.getName())); } affectedDataTypes.add(topLevelUpdate); }); return affectedDataTypes; } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void update(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName); }
DataTypeUpdateHandler extends DataTypeHandler { List<DataType> handleNestedDataTypeFieldUpdate(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); getClosestTopLevelDataType(dataType) .ifPresent(topLevelUpdate -> { refreshSubDataTypes(topLevelUpdate, topLevelUpdate.getName()); if (!isStructure(topLevelUpdate)) { forEachSubDataTypesByTypeOrName(topLevelUpdate.getType(), subDataType -> { refreshSubDataTypes(subDataType, topLevelUpdate.getType()); affectedDataTypes.add(subDataType); }); } else { affectedDataTypes.addAll(handleTopLevelDataTypeUpdate(topLevelUpdate, topLevelUpdate.getName())); } affectedDataTypes.add(topLevelUpdate); }); return affectedDataTypes; } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void update(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName); }
@Test public void testRefreshSubDataType() { final DataType dataType = mock(DataType.class); final ItemDefinition itemDefinition = mock(ItemDefinition.class); final String newType = "newType"; final String type = "type"; final String uuid = "uuid"; when(dataType.getType()).thenReturn(type); when(dataType.getUUID()).thenReturn(uuid); when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition); when(dataTypeManager.from(dataType)).thenReturn(dataTypeManager); when(dataTypeManager.withType(newType)).thenReturn(dataTypeManager); handler.refreshSubDataType(dataType, newType); final InOrder inOrder = Mockito.inOrder(dataTypeManager, dataTypeManager, recordEngine, handler); inOrder.verify(dataTypeManager).from(dataType); inOrder.verify(dataTypeManager).withType(newType); inOrder.verify(recordEngine).doUpdate(dataType, itemDefinition); inOrder.verify(handler).refreshSubDataTypes(dataType, type); }
void refreshSubDataType(final DataType dataType, final String newType) { final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); dataTypeManager.from(dataType).withType(newType); recordEngine.doUpdate(dataType, itemDefinition); refreshSubDataTypes(dataType, dataType.getType()); }
DataTypeUpdateHandler extends DataTypeHandler { void refreshSubDataType(final DataType dataType, final String newType) { final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); dataTypeManager.from(dataType).withType(newType); recordEngine.doUpdate(dataType, itemDefinition); refreshSubDataTypes(dataType, dataType.getType()); } }
DataTypeUpdateHandler extends DataTypeHandler { void refreshSubDataType(final DataType dataType, final String newType) { final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); dataTypeManager.from(dataType).withType(newType); recordEngine.doUpdate(dataType, itemDefinition); refreshSubDataTypes(dataType, dataType.getType()); } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeUpdateHandler extends DataTypeHandler { void refreshSubDataType(final DataType dataType, final String newType) { final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); dataTypeManager.from(dataType).withType(newType); recordEngine.doUpdate(dataType, itemDefinition); refreshSubDataTypes(dataType, dataType.getType()); } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void update(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName); }
DataTypeUpdateHandler extends DataTypeHandler { void refreshSubDataType(final DataType dataType, final String newType) { final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); dataTypeManager.from(dataType).withType(newType); recordEngine.doUpdate(dataType, itemDefinition); refreshSubDataTypes(dataType, dataType.getType()); } @Inject DataTypeUpdateHandler(final ItemDefinitionStore itemDefinitionStore, final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void update(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType, final String oldItemDefinitionName); }
@Test public void testDestroy() { final String uuid = "uuid"; final String parentUUID = "parentUUID"; final String childUUID1 = "childUUID1"; final String childUUID2 = "childUUID2"; final String grandchildUUID1 = "grandchildUUID1"; final String grandchildUUID2 = "grandchildUUID2"; final DataType[] grandchildren = {makeDataType(grandchildUUID1), makeDataType(grandchildUUID2)}; final DataType[] children = {makeDataType(childUUID1), makeDataType(childUUID2, grandchildren)}; final DataType dataType = makeDataType(uuid, children); final DataType parent = makeDataType(parentUUID, dataType); doReturn(parent).when(handler).parent(dataType); handler.destroy(dataType); verify(dataTypeStore).unIndex(uuid); verify(dataTypeStore).unIndex(childUUID1); verify(dataTypeStore).unIndex(childUUID2); verify(dataTypeStore).unIndex(grandchildUUID1); verify(dataTypeStore).unIndex(grandchildUUID2); assertEquals(emptyList(), parent.getSubDataTypes()); }
public void destroy(final DataType dataType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dataType)); dataTypeParent.ifPresent(parent -> { parent.getSubDataTypes().remove(dataType); }); unIndex(dataType); }
DataTypeDestroyHandler extends DataTypeHandler { public void destroy(final DataType dataType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dataType)); dataTypeParent.ifPresent(parent -> { parent.getSubDataTypes().remove(dataType); }); unIndex(dataType); } }
DataTypeDestroyHandler extends DataTypeHandler { public void destroy(final DataType dataType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dataType)); dataTypeParent.ifPresent(parent -> { parent.getSubDataTypes().remove(dataType); }); unIndex(dataType); } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeDestroyHandler extends DataTypeHandler { public void destroy(final DataType dataType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dataType)); dataTypeParent.ifPresent(parent -> { parent.getSubDataTypes().remove(dataType); }); unIndex(dataType); } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void destroy(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType); }
DataTypeDestroyHandler extends DataTypeHandler { public void destroy(final DataType dataType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dataType)); dataTypeParent.ifPresent(parent -> { parent.getSubDataTypes().remove(dataType); }); unIndex(dataType); } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void destroy(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType); }
@Test public void testRefreshDependentDataTypes() { final DataType dataType = mock(DataType.class); final DataType dataType0 = mock(DataType.class); final DataType dataType1 = mock(DataType.class); final DataType dataType2 = mock(DataType.class); final DataType dataType3 = mock(DataType.class); doReturn(asList(dataType0, dataType1)).when(handler).handleTopLevelDataTypes(dataType); doReturn(asList(dataType2, dataType3)).when(handler).handleNestedDataTypes(dataType); final List<DataType> expectedDataTypes = asList(dataType0, dataType1, dataType2, dataType3); final List<DataType> actualDataTypes = handler.refreshDependentDataTypes(dataType); assertEquals(expectedDataTypes, actualDataTypes); }
public List<DataType> refreshDependentDataTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.addAll(handleTopLevelDataTypes(dataType)); affectedDataTypes.addAll(handleNestedDataTypes(dataType)); return affectedDataTypes; }
DataTypeDestroyHandler extends DataTypeHandler { public List<DataType> refreshDependentDataTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.addAll(handleTopLevelDataTypes(dataType)); affectedDataTypes.addAll(handleNestedDataTypes(dataType)); return affectedDataTypes; } }
DataTypeDestroyHandler extends DataTypeHandler { public List<DataType> refreshDependentDataTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.addAll(handleTopLevelDataTypes(dataType)); affectedDataTypes.addAll(handleNestedDataTypes(dataType)); return affectedDataTypes; } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeDestroyHandler extends DataTypeHandler { public List<DataType> refreshDependentDataTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.addAll(handleTopLevelDataTypes(dataType)); affectedDataTypes.addAll(handleNestedDataTypes(dataType)); return affectedDataTypes; } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void destroy(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType); }
DataTypeDestroyHandler extends DataTypeHandler { public List<DataType> refreshDependentDataTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.addAll(handleTopLevelDataTypes(dataType)); affectedDataTypes.addAll(handleNestedDataTypes(dataType)); return affectedDataTypes; } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void destroy(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType); }
@Test public void testHandleTopLevelDataTypesWhenDataTypeIsNotTopLevel() { final DataType dataType = mock(DataType.class); when(dataType.isTopLevel()).thenReturn(false); final List<DataType> expectedDependentDataTypes = emptyList(); final List<DataType> actualDependentDataTypes = handler.handleTopLevelDataTypes(dataType); verify(recordEngine, never()).doDestroy(any()); assertEquals(expectedDependentDataTypes, actualDependentDataTypes); }
List<DataType> handleTopLevelDataTypes(final DataType dataType) { final List<DataType> affected = new ArrayList<>(); if (!dataType.isTopLevel()) { return affected; } final List<DataType> dataTypesByType = getSubDataTypesByType(dataType.getName()); for (final DataType dt : dataTypesByType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dt)); recordEngine.doDestroy(dt); affected.add(dataTypeParent.orElse(dt)); } affected.add(dataType); return affected; }
DataTypeDestroyHandler extends DataTypeHandler { List<DataType> handleTopLevelDataTypes(final DataType dataType) { final List<DataType> affected = new ArrayList<>(); if (!dataType.isTopLevel()) { return affected; } final List<DataType> dataTypesByType = getSubDataTypesByType(dataType.getName()); for (final DataType dt : dataTypesByType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dt)); recordEngine.doDestroy(dt); affected.add(dataTypeParent.orElse(dt)); } affected.add(dataType); return affected; } }
DataTypeDestroyHandler extends DataTypeHandler { List<DataType> handleTopLevelDataTypes(final DataType dataType) { final List<DataType> affected = new ArrayList<>(); if (!dataType.isTopLevel()) { return affected; } final List<DataType> dataTypesByType = getSubDataTypesByType(dataType.getName()); for (final DataType dt : dataTypesByType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dt)); recordEngine.doDestroy(dt); affected.add(dataTypeParent.orElse(dt)); } affected.add(dataType); return affected; } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeDestroyHandler extends DataTypeHandler { List<DataType> handleTopLevelDataTypes(final DataType dataType) { final List<DataType> affected = new ArrayList<>(); if (!dataType.isTopLevel()) { return affected; } final List<DataType> dataTypesByType = getSubDataTypesByType(dataType.getName()); for (final DataType dt : dataTypesByType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dt)); recordEngine.doDestroy(dt); affected.add(dataTypeParent.orElse(dt)); } affected.add(dataType); return affected; } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void destroy(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType); }
DataTypeDestroyHandler extends DataTypeHandler { List<DataType> handleTopLevelDataTypes(final DataType dataType) { final List<DataType> affected = new ArrayList<>(); if (!dataType.isTopLevel()) { return affected; } final List<DataType> dataTypesByType = getSubDataTypesByType(dataType.getName()); for (final DataType dt : dataTypesByType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dt)); recordEngine.doDestroy(dt); affected.add(dataTypeParent.orElse(dt)); } affected.add(dataType); return affected; } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void destroy(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType); }
@Test public void testHandleTopLevelDataTypesWhenDataTypeIsTopLevel() { final DataType dataType = mock(DataType.class); final DataType dataType0 = mock(DataType.class); final DataType dataType1 = mock(DataType.class); final DataType dataType2 = mock(DataType.class); final DataType dataTypeParent0 = mock(DataType.class); final DataType dataTypeParent1 = mock(DataType.class); final String topLevelName = "name"; when(dataType.isTopLevel()).thenReturn(true); when(dataType.getName()).thenReturn(topLevelName); when(dataType0.getType()).thenReturn(topLevelName); when(dataType1.getType()).thenReturn(topLevelName); when(dataType2.getType()).thenReturn(topLevelName); when(dataTypeStore.getTopLevelDataTypes()).thenReturn(asList(dataType0, dataType1, dataType2)); doReturn(dataTypeParent0).when(handler).parent(dataType0); doReturn(dataTypeParent1).when(handler).parent(dataType1); final List<DataType> expectedDependentDataTypes = asList(dataTypeParent0, dataTypeParent1, dataType2, dataType); final List<DataType> actualDependentDataTypes = handler.handleTopLevelDataTypes(dataType); verify(recordEngine).doDestroy(dataType0); verify(recordEngine).doDestroy(dataType1); verify(recordEngine).doDestroy(dataType2); assertEquals(expectedDependentDataTypes, actualDependentDataTypes); }
List<DataType> handleTopLevelDataTypes(final DataType dataType) { final List<DataType> affected = new ArrayList<>(); if (!dataType.isTopLevel()) { return affected; } final List<DataType> dataTypesByType = getSubDataTypesByType(dataType.getName()); for (final DataType dt : dataTypesByType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dt)); recordEngine.doDestroy(dt); affected.add(dataTypeParent.orElse(dt)); } affected.add(dataType); return affected; }
DataTypeDestroyHandler extends DataTypeHandler { List<DataType> handleTopLevelDataTypes(final DataType dataType) { final List<DataType> affected = new ArrayList<>(); if (!dataType.isTopLevel()) { return affected; } final List<DataType> dataTypesByType = getSubDataTypesByType(dataType.getName()); for (final DataType dt : dataTypesByType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dt)); recordEngine.doDestroy(dt); affected.add(dataTypeParent.orElse(dt)); } affected.add(dataType); return affected; } }
DataTypeDestroyHandler extends DataTypeHandler { List<DataType> handleTopLevelDataTypes(final DataType dataType) { final List<DataType> affected = new ArrayList<>(); if (!dataType.isTopLevel()) { return affected; } final List<DataType> dataTypesByType = getSubDataTypesByType(dataType.getName()); for (final DataType dt : dataTypesByType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dt)); recordEngine.doDestroy(dt); affected.add(dataTypeParent.orElse(dt)); } affected.add(dataType); return affected; } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeDestroyHandler extends DataTypeHandler { List<DataType> handleTopLevelDataTypes(final DataType dataType) { final List<DataType> affected = new ArrayList<>(); if (!dataType.isTopLevel()) { return affected; } final List<DataType> dataTypesByType = getSubDataTypesByType(dataType.getName()); for (final DataType dt : dataTypesByType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dt)); recordEngine.doDestroy(dt); affected.add(dataTypeParent.orElse(dt)); } affected.add(dataType); return affected; } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void destroy(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType); }
DataTypeDestroyHandler extends DataTypeHandler { List<DataType> handleTopLevelDataTypes(final DataType dataType) { final List<DataType> affected = new ArrayList<>(); if (!dataType.isTopLevel()) { return affected; } final List<DataType> dataTypesByType = getSubDataTypesByType(dataType.getName()); for (final DataType dt : dataTypesByType) { final Optional<DataType> dataTypeParent = Optional.ofNullable(parent(dt)); recordEngine.doDestroy(dt); affected.add(dataTypeParent.orElse(dt)); } affected.add(dataType); return affected; } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void destroy(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType); }
@Test public void testHandleNestedDataTypes() { final DataType dataType = mock(DataType.class); final DataType dataType0 = mock(DataType.class); final DataType dataType1 = mock(DataType.class); final DataType dataType2 = mock(DataType.class); final DataType dataType3 = mock(DataType.class); final DataType dataTypeParent0 = mock(DataType.class); final DataType dataTypeParent1 = mock(DataType.class); final DataType dataTypeParent2 = mock(DataType.class); final DataType dataTypeParent3 = mock(DataType.class); final DataType topLevelDataType = mock(DataType.class); final String topLevelName = "name"; final String topLevelType = "type"; when(topLevelDataType.getName()).thenReturn(topLevelName); when(topLevelDataType.getType()).thenReturn(topLevelType); when(dataType0.getType()).thenReturn(topLevelName); when(dataType1.getType()).thenReturn(topLevelName); when(dataType2.getType()).thenReturn(topLevelName); when(dataType3.getType()).thenReturn(topLevelType); when(dataType3.isTopLevel()).thenReturn(true); when(dataTypeStore.getTopLevelDataTypes()).thenReturn(asList(dataType0, dataType1, dataType2, dataType3)); doReturn(dataTypeParent0).when(handler).parent(dataType0); doReturn(dataTypeParent1).when(handler).parent(dataType1); doReturn(dataTypeParent2).when(handler).parent(dataType2); doReturn(dataTypeParent3).when(handler).parent(dataType3); doReturn(Optional.of(topLevelDataType)).when(handler).getClosestTopLevelDataType(dataType); doReturn(false).when(handler).isStructure(topLevelDataType); doNothing().when(handler).refreshSubDataTypes(any(), anyString()); doNothing().when(handler).refreshSubDataTypes(any()); final List<DataType> expectedDependentDataTypes = asList(topLevelDataType, dataType3, dataTypeParent0, dataTypeParent1, dataTypeParent2); final List<DataType> actualDependentDataTypes = handler.handleNestedDataTypes(dataType); verify(handler).refreshSubDataTypes(topLevelDataType, topLevelName); verify(handler).refreshSubDataTypes(dataTypeParent0); verify(handler).refreshSubDataTypes(dataType3); verify(handler).refreshSubDataTypes(dataTypeParent1); verify(handler).refreshSubDataTypes(dataTypeParent2); assertEquals(expectedDependentDataTypes, actualDependentDataTypes); }
List<DataType> handleNestedDataTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); getClosestTopLevelDataType(dataType).ifPresent(topLevel -> { final String type = topLevel.getName(); affectedDataTypes.add(topLevel); refreshSubDataTypes(topLevel, type); if (!isStructure(topLevel)) { forEachSubDataTypesByTypeOrName(topLevel.getType(), subDataType -> { affectedDataTypes.add(refreshSubDataType(subDataType)); }); } forEachSubDataTypesByType(type, subDataType -> { affectedDataTypes.add(refreshSubDataType(subDataType)); }); }); return affectedDataTypes; }
DataTypeDestroyHandler extends DataTypeHandler { List<DataType> handleNestedDataTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); getClosestTopLevelDataType(dataType).ifPresent(topLevel -> { final String type = topLevel.getName(); affectedDataTypes.add(topLevel); refreshSubDataTypes(topLevel, type); if (!isStructure(topLevel)) { forEachSubDataTypesByTypeOrName(topLevel.getType(), subDataType -> { affectedDataTypes.add(refreshSubDataType(subDataType)); }); } forEachSubDataTypesByType(type, subDataType -> { affectedDataTypes.add(refreshSubDataType(subDataType)); }); }); return affectedDataTypes; } }
DataTypeDestroyHandler extends DataTypeHandler { List<DataType> handleNestedDataTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); getClosestTopLevelDataType(dataType).ifPresent(topLevel -> { final String type = topLevel.getName(); affectedDataTypes.add(topLevel); refreshSubDataTypes(topLevel, type); if (!isStructure(topLevel)) { forEachSubDataTypesByTypeOrName(topLevel.getType(), subDataType -> { affectedDataTypes.add(refreshSubDataType(subDataType)); }); } forEachSubDataTypesByType(type, subDataType -> { affectedDataTypes.add(refreshSubDataType(subDataType)); }); }); return affectedDataTypes; } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); }
DataTypeDestroyHandler extends DataTypeHandler { List<DataType> handleNestedDataTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); getClosestTopLevelDataType(dataType).ifPresent(topLevel -> { final String type = topLevel.getName(); affectedDataTypes.add(topLevel); refreshSubDataTypes(topLevel, type); if (!isStructure(topLevel)) { forEachSubDataTypesByTypeOrName(topLevel.getType(), subDataType -> { affectedDataTypes.add(refreshSubDataType(subDataType)); }); } forEachSubDataTypesByType(type, subDataType -> { affectedDataTypes.add(refreshSubDataType(subDataType)); }); }); return affectedDataTypes; } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void destroy(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType); }
DataTypeDestroyHandler extends DataTypeHandler { List<DataType> handleNestedDataTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); getClosestTopLevelDataType(dataType).ifPresent(topLevel -> { final String type = topLevel.getName(); affectedDataTypes.add(topLevel); refreshSubDataTypes(topLevel, type); if (!isStructure(topLevel)) { forEachSubDataTypesByTypeOrName(topLevel.getType(), subDataType -> { affectedDataTypes.add(refreshSubDataType(subDataType)); }); } forEachSubDataTypesByType(type, subDataType -> { affectedDataTypes.add(refreshSubDataType(subDataType)); }); }); return affectedDataTypes; } @Inject DataTypeDestroyHandler(final DataTypeStore dataTypeStore, final DataTypeManager dataTypeManager); void destroy(final DataType dataType); List<DataType> refreshDependentDataTypes(final DataType dataType); }
@Test public void testAppendItemDefinition() { when(itemDefinitionUtils.all()).thenReturn(new ArrayList<>()); final ItemDefinition itemDefinition = handler.appendItemDefinition(); assertTrue(itemDefinitionUtils.all().contains(itemDefinition)); }
public ItemDefinition appendItemDefinition() { final ItemDefinition itemDefinition = new ItemDefinition(); itemDefinitions().add(itemDefinition); return itemDefinition; }
ItemDefinitionCreateHandler { public ItemDefinition appendItemDefinition() { final ItemDefinition itemDefinition = new ItemDefinition(); itemDefinitions().add(itemDefinition); return itemDefinition; } }
ItemDefinitionCreateHandler { public ItemDefinition appendItemDefinition() { final ItemDefinition itemDefinition = new ItemDefinition(); itemDefinitions().add(itemDefinition); return itemDefinition; } @Inject ItemDefinitionCreateHandler(final ItemDefinitionUtils itemDefinitionUtils, final ItemDefinitionStore itemDefinitionStore); }
ItemDefinitionCreateHandler { public ItemDefinition appendItemDefinition() { final ItemDefinition itemDefinition = new ItemDefinition(); itemDefinitions().add(itemDefinition); return itemDefinition; } @Inject ItemDefinitionCreateHandler(final ItemDefinitionUtils itemDefinitionUtils, final ItemDefinitionStore itemDefinitionStore); ItemDefinition appendItemDefinition(); ItemDefinition insertNested(final DataType record, final DataType reference); ItemDefinition insertSibling(final DataType record, final DataType reference, final CreationType creationType); }
ItemDefinitionCreateHandler { public ItemDefinition appendItemDefinition() { final ItemDefinition itemDefinition = new ItemDefinition(); itemDefinitions().add(itemDefinition); return itemDefinition; } @Inject ItemDefinitionCreateHandler(final ItemDefinitionUtils itemDefinitionUtils, final ItemDefinitionStore itemDefinitionStore); ItemDefinition appendItemDefinition(); ItemDefinition insertNested(final DataType record, final DataType reference); ItemDefinition insertSibling(final DataType record, final DataType reference, final CreationType creationType); }
@Test public void testLookupAbsoluteParentWhenParentIsNotPresent() { final String referenceUUID = "referenceUUID"; when(itemDefinitionStore.get(referenceUUID)).thenReturn(null); final Optional<ItemDefinition> absoluteParent = handler.lookupAbsoluteParent(referenceUUID); assertFalse(absoluteParent.isPresent()); }
Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); }
ItemDefinitionCreateHandler { Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); } }
ItemDefinitionCreateHandler { Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); } @Inject ItemDefinitionCreateHandler(final ItemDefinitionUtils itemDefinitionUtils, final ItemDefinitionStore itemDefinitionStore); }
ItemDefinitionCreateHandler { Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); } @Inject ItemDefinitionCreateHandler(final ItemDefinitionUtils itemDefinitionUtils, final ItemDefinitionStore itemDefinitionStore); ItemDefinition appendItemDefinition(); ItemDefinition insertNested(final DataType record, final DataType reference); ItemDefinition insertSibling(final DataType record, final DataType reference, final CreationType creationType); }
ItemDefinitionCreateHandler { Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); } @Inject ItemDefinitionCreateHandler(final ItemDefinitionUtils itemDefinitionUtils, final ItemDefinitionStore itemDefinitionStore); ItemDefinition appendItemDefinition(); ItemDefinition insertNested(final DataType record, final DataType reference); ItemDefinition insertSibling(final DataType record, final DataType reference, final CreationType creationType); }
@Test public void testDmnFromWB() { final String dmnName = "name"; final Name name = new Name(dmnName); when(dmnRuleAnnotationClause.getName()).thenReturn(name); final org.kie.dmn.model.api.RuleAnnotationClause converted = RuleAnnotationClauseConverter.dmnFromWB(dmnRuleAnnotationClause); assertEquals(dmnName, converted.getName()); }
public static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb) { if (wb == null) { return null; } final org.kie.dmn.model.api.RuleAnnotationClause rule = new TRuleAnnotationClause(); rule.setName(wb.getName().getValue()); return rule; }
RuleAnnotationClauseConverter { public static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb) { if (wb == null) { return null; } final org.kie.dmn.model.api.RuleAnnotationClause rule = new TRuleAnnotationClause(); rule.setName(wb.getName().getValue()); return rule; } }
RuleAnnotationClauseConverter { public static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb) { if (wb == null) { return null; } final org.kie.dmn.model.api.RuleAnnotationClause rule = new TRuleAnnotationClause(); rule.setName(wb.getName().getValue()); return rule; } }
RuleAnnotationClauseConverter { public static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb) { if (wb == null) { return null; } final org.kie.dmn.model.api.RuleAnnotationClause rule = new TRuleAnnotationClause(); rule.setName(wb.getName().getValue()); return rule; } static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause); static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb); }
RuleAnnotationClauseConverter { public static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb) { if (wb == null) { return null; } final org.kie.dmn.model.api.RuleAnnotationClause rule = new TRuleAnnotationClause(); rule.setName(wb.getName().getValue()); return rule; } static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause); static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb); }
@Test public void testLookupAbsoluteParentWhenParentIsStructure() { final String referenceUUID = "referenceUUID"; final ItemDefinition parent = mock(ItemDefinition.class); when(parent.getTypeRef()).thenReturn(null); when(itemDefinitionStore.get(referenceUUID)).thenReturn(parent); final Optional<ItemDefinition> actualParent = handler.lookupAbsoluteParent(referenceUUID); final Optional<ItemDefinition> expectedParent = Optional.of(parent); assertEquals(expectedParent, actualParent); }
Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); }
ItemDefinitionCreateHandler { Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); } }
ItemDefinitionCreateHandler { Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); } @Inject ItemDefinitionCreateHandler(final ItemDefinitionUtils itemDefinitionUtils, final ItemDefinitionStore itemDefinitionStore); }
ItemDefinitionCreateHandler { Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); } @Inject ItemDefinitionCreateHandler(final ItemDefinitionUtils itemDefinitionUtils, final ItemDefinitionStore itemDefinitionStore); ItemDefinition appendItemDefinition(); ItemDefinition insertNested(final DataType record, final DataType reference); ItemDefinition insertSibling(final DataType record, final DataType reference, final CreationType creationType); }
ItemDefinitionCreateHandler { Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); } @Inject ItemDefinitionCreateHandler(final ItemDefinitionUtils itemDefinitionUtils, final ItemDefinitionStore itemDefinitionStore); ItemDefinition appendItemDefinition(); ItemDefinition insertNested(final DataType record, final DataType reference); ItemDefinition insertSibling(final DataType record, final DataType reference, final CreationType creationType); }
@Test public void testLookupAbsoluteParentWhenParentIsNotStructure() { final String type = "type"; final String referenceUUID = "referenceUUID"; final ItemDefinition parent = mock(ItemDefinition.class); final Optional<ItemDefinition> expectedParent = Optional.of(mock(ItemDefinition.class)); final QName qName = mock(QName.class); when(qName.getLocalPart()).thenReturn(type); when(parent.getTypeRef()).thenReturn(qName); when(itemDefinitionStore.get(referenceUUID)).thenReturn(parent); when(itemDefinitionUtils.findByName(type)).thenReturn(expectedParent); final Optional<ItemDefinition> actualParent = handler.lookupAbsoluteParent(referenceUUID); assertEquals(expectedParent, actualParent); }
Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); }
ItemDefinitionCreateHandler { Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); } }
ItemDefinitionCreateHandler { Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); } @Inject ItemDefinitionCreateHandler(final ItemDefinitionUtils itemDefinitionUtils, final ItemDefinitionStore itemDefinitionStore); }
ItemDefinitionCreateHandler { Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); } @Inject ItemDefinitionCreateHandler(final ItemDefinitionUtils itemDefinitionUtils, final ItemDefinitionStore itemDefinitionStore); ItemDefinition appendItemDefinition(); ItemDefinition insertNested(final DataType record, final DataType reference); ItemDefinition insertSibling(final DataType record, final DataType reference, final CreationType creationType); }
ItemDefinitionCreateHandler { Optional<ItemDefinition> lookupAbsoluteParent(final String parentUUID) { final Optional<ItemDefinition> optionalParent = Optional.ofNullable(getIndexedItemDefinition(parentUUID)); if (optionalParent.isPresent()) { final ItemDefinition parent = optionalParent.get(); final boolean isStructure = parent.getTypeRef() == null; if (isStructure) { return Optional.of(parent); } else { return findItemDefinitionByName(parent.getTypeRef().getLocalPart()); } } return Optional.empty(); } @Inject ItemDefinitionCreateHandler(final ItemDefinitionUtils itemDefinitionUtils, final ItemDefinitionStore itemDefinitionStore); ItemDefinition appendItemDefinition(); ItemDefinition insertNested(final DataType record, final DataType reference); ItemDefinition insertSibling(final DataType record, final DataType reference, final CreationType creationType); }
@Test public void testGetWhenItReturnsNull() { assertNull(store.get("456")); }
public DataType get(final String uuid) { return dataTypes.get(uuid); }
DataTypeStore { public DataType get(final String uuid) { return dataTypes.get(uuid); } }
DataTypeStore { public DataType get(final String uuid) { return dataTypes.get(uuid); } }
DataTypeStore { public DataType get(final String uuid) { return dataTypes.get(uuid); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
DataTypeStore { public DataType get(final String uuid) { return dataTypes.get(uuid); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
@Test public void testGetWhenItDoesNotReturnNull() { assertNotNull(store.get(uuid)); assertEquals(dataType, store.get(uuid)); }
public DataType get(final String uuid) { return dataTypes.get(uuid); }
DataTypeStore { public DataType get(final String uuid) { return dataTypes.get(uuid); } }
DataTypeStore { public DataType get(final String uuid) { return dataTypes.get(uuid); } }
DataTypeStore { public DataType get(final String uuid) { return dataTypes.get(uuid); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
DataTypeStore { public DataType get(final String uuid) { return dataTypes.get(uuid); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
@Test public void testIndex() { assertEquals(1, store.size()); final DataType secondDataType = mock(DataType.class); final String secondUUID = "789"; store.index(secondUUID, secondDataType); assertEquals(2, store.size()); assertEquals(dataType, store.get(uuid)); assertEquals(secondDataType, store.get(secondUUID)); }
public void index(final String uuid, final DataType dataType) { dataTypes.put(uuid, dataType); }
DataTypeStore { public void index(final String uuid, final DataType dataType) { dataTypes.put(uuid, dataType); } }
DataTypeStore { public void index(final String uuid, final DataType dataType) { dataTypes.put(uuid, dataType); } }
DataTypeStore { public void index(final String uuid, final DataType dataType) { dataTypes.put(uuid, dataType); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
DataTypeStore { public void index(final String uuid, final DataType dataType) { dataTypes.put(uuid, dataType); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
@Test public void testClear() { store.clear(); assertEquals(0, store.size()); }
public void clear() { dataTypes.clear(); }
DataTypeStore { public void clear() { dataTypes.clear(); } }
DataTypeStore { public void clear() { dataTypes.clear(); } }
DataTypeStore { public void clear() { dataTypes.clear(); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
DataTypeStore { public void clear() { dataTypes.clear(); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
@Test public void testGetTopLevelDataTypes() { final String secondUUID = "789"; final String thirdUUID = "012"; final DataType secondDataType = mock(DataType.class); final DataType thirdDataType = mock(DataType.class); when(secondDataType.isTopLevel()).thenReturn(true); store.index(secondUUID, secondDataType); store.index(thirdUUID, thirdDataType); final List<DataType> topLevelDataTypes = store.getTopLevelDataTypes(); assertEquals(topLevelDataTypes, singletonList(secondDataType)); }
public List<DataType> getTopLevelDataTypes() { return all() .stream() .filter(DataType::isTopLevel) .collect(Collectors.toList()); }
DataTypeStore { public List<DataType> getTopLevelDataTypes() { return all() .stream() .filter(DataType::isTopLevel) .collect(Collectors.toList()); } }
DataTypeStore { public List<DataType> getTopLevelDataTypes() { return all() .stream() .filter(DataType::isTopLevel) .collect(Collectors.toList()); } }
DataTypeStore { public List<DataType> getTopLevelDataTypes() { return all() .stream() .filter(DataType::isTopLevel) .collect(Collectors.toList()); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
DataTypeStore { public List<DataType> getTopLevelDataTypes() { return all() .stream() .filter(DataType::isTopLevel) .collect(Collectors.toList()); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
@Test public void testUnIndex() { final DataType dataType0 = mock(DataType.class); final DataType dataType1 = mock(DataType.class); final DataType dataType2 = mock(DataType.class); final DataType dataType3 = mock(DataType.class); final DataType dataType4 = mock(DataType.class); final DataType dataType5 = mock(DataType.class); when(dataType0.getUUID()).thenReturn("012"); when(dataType1.getUUID()).thenReturn("345"); when(dataType2.getUUID()).thenReturn("678"); when(dataType3.getUUID()).thenReturn("901"); when(dataType4.getUUID()).thenReturn("234"); when(dataType5.getUUID()).thenReturn("567"); when(dataType0.getParentUUID()).thenReturn(TOP_LEVEL_PARENT_UUID); when(dataType1.getParentUUID()).thenReturn("012"); when(dataType2.getParentUUID()).thenReturn("012"); when(dataType3.getParentUUID()).thenReturn("678"); when(dataType4.getParentUUID()).thenReturn("678"); when(dataType5.getParentUUID()).thenReturn(TOP_LEVEL_PARENT_UUID); store.index(dataType0.getUUID(), dataType0); store.index(dataType1.getUUID(), dataType1); store.index(dataType2.getUUID(), dataType2); store.index(dataType3.getUUID(), dataType3); store.index(dataType4.getUUID(), dataType4); store.index(dataType5.getUUID(), dataType5); store.unIndex("012"); assertNull(store.get("012")); assertNull(store.get("345")); assertNull(store.get("678")); assertNull(store.get("901")); assertNull(store.get("234")); assertNotNull(store.get("567")); }
public void unIndex(final String uuid) { dataTypes.remove(uuid); subDataTypesUUID(uuid).forEach(this::unIndex); }
DataTypeStore { public void unIndex(final String uuid) { dataTypes.remove(uuid); subDataTypesUUID(uuid).forEach(this::unIndex); } }
DataTypeStore { public void unIndex(final String uuid) { dataTypes.remove(uuid); subDataTypesUUID(uuid).forEach(this::unIndex); } }
DataTypeStore { public void unIndex(final String uuid) { dataTypes.remove(uuid); subDataTypesUUID(uuid).forEach(this::unIndex); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
DataTypeStore { public void unIndex(final String uuid) { dataTypes.remove(uuid); subDataTypesUUID(uuid).forEach(this::unIndex); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
@Test public void testAll() { final DataType dataType0 = mock(DataType.class); final DataType dataType1 = mock(DataType.class); store.index("0", dataType0); store.index("1", dataType1); final List<DataType> all = store.all(); assertEquals(3, all.size()); assertTrue(all.contains(dataType)); assertTrue(all.contains(dataType0)); assertTrue(all.contains(dataType1)); }
public List<DataType> all() { return new ArrayList<>(dataTypes.values()); }
DataTypeStore { public List<DataType> all() { return new ArrayList<>(dataTypes.values()); } }
DataTypeStore { public List<DataType> all() { return new ArrayList<>(dataTypes.values()); } }
DataTypeStore { public List<DataType> all() { return new ArrayList<>(dataTypes.values()); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
DataTypeStore { public List<DataType> all() { return new ArrayList<>(dataTypes.values()); } DataType get(final String uuid); void index(final String uuid, final DataType dataType); void clear(); int size(); List<DataType> getTopLevelDataTypes(); List<DataType> all(); void unIndex(final String uuid); }
@Test public void testCreate() { final DataTypeRecordEngine engine = makeRecordEngine(); final DataType record = spy(new DataType(engine)); final DataType reference = mock(DataType.class); final List<DataType> expectedDataTypes = asList(mock(DataType.class), mock(DataType.class)); final CreationType creationType = mock(CreationType.class); doReturn(expectedDataTypes).when(engine).create(record, reference, creationType); final List<DataType> actualDataTypes = record.create(reference, creationType); assertEquals(expectedDataTypes, actualDataTypes); }
public List<DataType> create(final DataType reference, final CreationType creationType) { return getDataTypeRecordEngine().create(getRecord(), reference, creationType); }
DataTypeActiveRecord extends ActiveRecord<DataType> { public List<DataType> create(final DataType reference, final CreationType creationType) { return getDataTypeRecordEngine().create(getRecord(), reference, creationType); } }
DataTypeActiveRecord extends ActiveRecord<DataType> { public List<DataType> create(final DataType reference, final CreationType creationType) { return getDataTypeRecordEngine().create(getRecord(), reference, creationType); } DataTypeActiveRecord(final RecordEngine<DataType> recordEngine); }
DataTypeActiveRecord extends ActiveRecord<DataType> { public List<DataType> create(final DataType reference, final CreationType creationType) { return getDataTypeRecordEngine().create(getRecord(), reference, creationType); } DataTypeActiveRecord(final RecordEngine<DataType> recordEngine); List<DataType> create(final DataType reference, final CreationType creationType); List<DataType> destroyWithoutDependentTypes(); }
DataTypeActiveRecord extends ActiveRecord<DataType> { public List<DataType> create(final DataType reference, final CreationType creationType) { return getDataTypeRecordEngine().create(getRecord(), reference, creationType); } DataTypeActiveRecord(final RecordEngine<DataType> recordEngine); List<DataType> create(final DataType reference, final CreationType creationType); List<DataType> destroyWithoutDependentTypes(); }
@Test public void testDmnFromWBWhenIsNull() { final org.kie.dmn.model.api.RuleAnnotationClause converted = RuleAnnotationClauseConverter.dmnFromWB(null); assertNull(converted); }
public static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb) { if (wb == null) { return null; } final org.kie.dmn.model.api.RuleAnnotationClause rule = new TRuleAnnotationClause(); rule.setName(wb.getName().getValue()); return rule; }
RuleAnnotationClauseConverter { public static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb) { if (wb == null) { return null; } final org.kie.dmn.model.api.RuleAnnotationClause rule = new TRuleAnnotationClause(); rule.setName(wb.getName().getValue()); return rule; } }
RuleAnnotationClauseConverter { public static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb) { if (wb == null) { return null; } final org.kie.dmn.model.api.RuleAnnotationClause rule = new TRuleAnnotationClause(); rule.setName(wb.getName().getValue()); return rule; } }
RuleAnnotationClauseConverter { public static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb) { if (wb == null) { return null; } final org.kie.dmn.model.api.RuleAnnotationClause rule = new TRuleAnnotationClause(); rule.setName(wb.getName().getValue()); return rule; } static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause); static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb); }
RuleAnnotationClauseConverter { public static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb) { if (wb == null) { return null; } final org.kie.dmn.model.api.RuleAnnotationClause rule = new TRuleAnnotationClause(); rule.setName(wb.getName().getValue()); return rule; } static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause); static org.kie.dmn.model.api.RuleAnnotationClause dmnFromWB(final RuleAnnotationClause wb); }
@Test public void testDestroyWithoutDependentTypes() { final DataTypeRecordEngine engine = makeRecordEngine(); final DataType record = spy(new DataType(engine)); final List<DataType> expectedDataTypes = singletonList(mock(DataType.class)); doReturn(expectedDataTypes).when(engine).destroyWithoutDependentTypes(record); final List<DataType> actualDataTypes = record.destroyWithoutDependentTypes(); assertEquals(expectedDataTypes, actualDataTypes); }
public List<DataType> destroyWithoutDependentTypes() { return getDataTypeRecordEngine().destroyWithoutDependentTypes(getRecord()); }
DataTypeActiveRecord extends ActiveRecord<DataType> { public List<DataType> destroyWithoutDependentTypes() { return getDataTypeRecordEngine().destroyWithoutDependentTypes(getRecord()); } }
DataTypeActiveRecord extends ActiveRecord<DataType> { public List<DataType> destroyWithoutDependentTypes() { return getDataTypeRecordEngine().destroyWithoutDependentTypes(getRecord()); } DataTypeActiveRecord(final RecordEngine<DataType> recordEngine); }
DataTypeActiveRecord extends ActiveRecord<DataType> { public List<DataType> destroyWithoutDependentTypes() { return getDataTypeRecordEngine().destroyWithoutDependentTypes(getRecord()); } DataTypeActiveRecord(final RecordEngine<DataType> recordEngine); List<DataType> create(final DataType reference, final CreationType creationType); List<DataType> destroyWithoutDependentTypes(); }
DataTypeActiveRecord extends ActiveRecord<DataType> { public List<DataType> destroyWithoutDependentTypes() { return getDataTypeRecordEngine().destroyWithoutDependentTypes(getRecord()); } DataTypeActiveRecord(final RecordEngine<DataType> recordEngine); List<DataType> create(final DataType reference, final CreationType creationType); List<DataType> destroyWithoutDependentTypes(); }
@Test public void testInit() { recordEngine.init(); verify(dataTypeDestroyHandler).init(recordEngine); verify(dataTypeUpdateHandler).init(recordEngine); }
@PostConstruct public void init() { dataTypeCreateHandler.init(this); dataTypeDestroyHandler.init(this); dataTypeUpdateHandler.init(this); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @PostConstruct public void init() { dataTypeCreateHandler.init(this); dataTypeDestroyHandler.init(this); dataTypeUpdateHandler.init(this); } }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @PostConstruct public void init() { dataTypeCreateHandler.init(this); dataTypeDestroyHandler.init(this); dataTypeUpdateHandler.init(this); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @PostConstruct public void init() { dataTypeCreateHandler.init(this); dataTypeDestroyHandler.init(this); dataTypeUpdateHandler.init(this); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @PostConstruct public void init() { dataTypeCreateHandler.init(this); dataTypeDestroyHandler.init(this); dataTypeUpdateHandler.init(this); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
@Test public void testUpdate() { final String uuid = "uuid"; final String nameValue = "nameValue"; final DataType dataType = mock(DataType.class); final ItemDefinition itemDefinition = mock(ItemDefinition.class); final Name name = mock(Name.class); final List<DataType> expectedDependentDataTypes = asList(mock(DataType.class), mock(DataType.class)); when(dataType.isValid()).thenReturn(true); when(dataType.getUUID()).thenReturn(uuid); when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition); when(itemDefinition.getName()).thenReturn(name); when(name.getValue()).thenReturn(nameValue); when(dataTypeUpdateHandler.refreshDependentDataTypes(dataType, nameValue)).thenReturn(expectedDependentDataTypes); final List<DataType> actualDependentDataTypes = recordEngine.update(dataType); verify(recordEngine).doUpdate(dataType, itemDefinition); assertEquals(expectedDependentDataTypes, actualDependentDataTypes); }
@Override public List<DataType> update(final DataType dataType) { if (!dataType.isValid()) { throw new UnsupportedOperationException("An invalid Data Type cannot be updated."); } final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); final String itemDefinitionBeforeUpdate = itemDefinition.getName().getValue(); doUpdate(dataType, itemDefinition); return refreshDependentDataTypesFromUpdateOperation(dataType, itemDefinitionBeforeUpdate); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> update(final DataType dataType) { if (!dataType.isValid()) { throw new UnsupportedOperationException("An invalid Data Type cannot be updated."); } final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); final String itemDefinitionBeforeUpdate = itemDefinition.getName().getValue(); doUpdate(dataType, itemDefinition); return refreshDependentDataTypesFromUpdateOperation(dataType, itemDefinitionBeforeUpdate); } }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> update(final DataType dataType) { if (!dataType.isValid()) { throw new UnsupportedOperationException("An invalid Data Type cannot be updated."); } final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); final String itemDefinitionBeforeUpdate = itemDefinition.getName().getValue(); doUpdate(dataType, itemDefinition); return refreshDependentDataTypesFromUpdateOperation(dataType, itemDefinitionBeforeUpdate); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> update(final DataType dataType) { if (!dataType.isValid()) { throw new UnsupportedOperationException("An invalid Data Type cannot be updated."); } final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); final String itemDefinitionBeforeUpdate = itemDefinition.getName().getValue(); doUpdate(dataType, itemDefinition); return refreshDependentDataTypesFromUpdateOperation(dataType, itemDefinitionBeforeUpdate); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> update(final DataType dataType) { if (!dataType.isValid()) { throw new UnsupportedOperationException("An invalid Data Type cannot be updated."); } final ItemDefinition itemDefinition = itemDefinitionStore.get(dataType.getUUID()); final String itemDefinitionBeforeUpdate = itemDefinition.getName().getValue(); doUpdate(dataType, itemDefinition); return refreshDependentDataTypesFromUpdateOperation(dataType, itemDefinitionBeforeUpdate); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
@Test public void testDoUpdate() { final DataType dataType = mock(DataType.class); final ItemDefinition itemDefinition = mock(ItemDefinition.class); recordEngine.doUpdate(dataType, itemDefinition); verify(dataTypeUpdateHandler).update(dataType); verify(itemDefinitionUpdateHandler).update(dataType, itemDefinition); }
public void doUpdate(final DataType dataType, final ItemDefinition itemDefinition) { dataTypeUpdateHandler.update(dataType); itemDefinitionUpdateHandler.update(dataType, itemDefinition); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { public void doUpdate(final DataType dataType, final ItemDefinition itemDefinition) { dataTypeUpdateHandler.update(dataType); itemDefinitionUpdateHandler.update(dataType, itemDefinition); } }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { public void doUpdate(final DataType dataType, final ItemDefinition itemDefinition) { dataTypeUpdateHandler.update(dataType); itemDefinitionUpdateHandler.update(dataType, itemDefinition); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { public void doUpdate(final DataType dataType, final ItemDefinition itemDefinition) { dataTypeUpdateHandler.update(dataType); itemDefinitionUpdateHandler.update(dataType, itemDefinition); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { public void doUpdate(final DataType dataType, final ItemDefinition itemDefinition) { dataTypeUpdateHandler.update(dataType); itemDefinitionUpdateHandler.update(dataType, itemDefinition); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
@Test public void testDestroy() { final DataType dataType = mock(DataType.class); final List<DataType> expectedDependentDataTypes = asList(mock(DataType.class), mock(DataType.class)); when(dataTypeDestroyHandler.refreshDependentDataTypes(dataType)).thenReturn(expectedDependentDataTypes); final List<DataType> actualDependentDataTypes = recordEngine.destroy(dataType); verify(recordEngine).doDestroy(dataType); assertEquals(expectedDependentDataTypes, actualDependentDataTypes); }
@Override public List<DataType> destroy(final DataType dataType) { doDestroy(dataType); return refreshDependentDataTypesFromDestroyOperation(dataType); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> destroy(final DataType dataType) { doDestroy(dataType); return refreshDependentDataTypesFromDestroyOperation(dataType); } }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> destroy(final DataType dataType) { doDestroy(dataType); return refreshDependentDataTypesFromDestroyOperation(dataType); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> destroy(final DataType dataType) { doDestroy(dataType); return refreshDependentDataTypesFromDestroyOperation(dataType); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> destroy(final DataType dataType) { doDestroy(dataType); return refreshDependentDataTypesFromDestroyOperation(dataType); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
@Test public void testDestroyWithoutDependentTypes() { final DataType dataType = mock(DataType.class); final List<DataType> dependentDataTypes = asList(mock(DataType.class), mock(DataType.class)); when(dataTypeDestroyHandler.refreshDependentDataTypes(dataType)).thenReturn(dependentDataTypes); final List<DataType> actualDependentDataTypes = recordEngine.destroyWithoutDependentTypes(dataType); final List<DataType> expectedDependentDataTypes = singletonList(dataType); verify(dataTypeDestroyHandler).destroy(dataType); verify(itemDefinitionDestroyHandler).destroy(dataType, false); assertEquals(expectedDependentDataTypes, actualDependentDataTypes); }
@Override public List<DataType> destroyWithoutDependentTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.add(dataType); doDestroy(dataType, false); return affectedDataTypes; }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> destroyWithoutDependentTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.add(dataType); doDestroy(dataType, false); return affectedDataTypes; } }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> destroyWithoutDependentTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.add(dataType); doDestroy(dataType, false); return affectedDataTypes; } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> destroyWithoutDependentTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.add(dataType); doDestroy(dataType, false); return affectedDataTypes; } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> destroyWithoutDependentTypes(final DataType dataType) { final List<DataType> affectedDataTypes = new ArrayList<>(); affectedDataTypes.add(dataType); doDestroy(dataType, false); return affectedDataTypes; } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
@Test public void testCreate() { final DataType dataType = mock(DataType.class); final List<DataType> expectedAffectedDataTypes = asList(mock(DataType.class), mock(DataType.class)); final ItemDefinition itemDefinition = mock(ItemDefinition.class); when(itemDefinitionCreateHandler.appendItemDefinition()).thenReturn(itemDefinition); when(dataTypeCreateHandler.append(dataType, itemDefinition)).thenReturn(expectedAffectedDataTypes); final List<DataType> actualAffectedDataTypes = recordEngine.create(dataType); assertEquals(expectedAffectedDataTypes, actualAffectedDataTypes); }
@Override public List<DataType> create(final DataType dataType) { return dataTypeCreateHandler.append(dataType, itemDefinitionCreateHandler.appendItemDefinition()); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> create(final DataType dataType) { return dataTypeCreateHandler.append(dataType, itemDefinitionCreateHandler.appendItemDefinition()); } }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> create(final DataType dataType) { return dataTypeCreateHandler.append(dataType, itemDefinitionCreateHandler.appendItemDefinition()); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> create(final DataType dataType) { return dataTypeCreateHandler.append(dataType, itemDefinitionCreateHandler.appendItemDefinition()); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public List<DataType> create(final DataType dataType) { return dataTypeCreateHandler.append(dataType, itemDefinitionCreateHandler.appendItemDefinition()); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
@Test public void testIsValidWhenItIsTrue() { final DataType dataType = mock(DataType.class); doReturn(true).when(dataTypeNameValidator).isValid(dataType); assertTrue(recordEngine.isValid(dataType)); }
@Override public boolean isValid(final DataType dataType) { return dataTypeNameValidator.isValid(dataType); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public boolean isValid(final DataType dataType) { return dataTypeNameValidator.isValid(dataType); } }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public boolean isValid(final DataType dataType) { return dataTypeNameValidator.isValid(dataType); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public boolean isValid(final DataType dataType) { return dataTypeNameValidator.isValid(dataType); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public boolean isValid(final DataType dataType) { return dataTypeNameValidator.isValid(dataType); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
@Test public void testIsValidWhenItIsFalse() { final DataType dataType = mock(DataType.class); doReturn(false).when(dataTypeNameValidator).isValid(dataType); assertFalse(recordEngine.isValid(dataType)); }
@Override public boolean isValid(final DataType dataType) { return dataTypeNameValidator.isValid(dataType); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public boolean isValid(final DataType dataType) { return dataTypeNameValidator.isValid(dataType); } }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public boolean isValid(final DataType dataType) { return dataTypeNameValidator.isValid(dataType); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public boolean isValid(final DataType dataType) { return dataTypeNameValidator.isValid(dataType); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { @Override public boolean isValid(final DataType dataType) { return dataTypeNameValidator.isValid(dataType); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
@Test public void testDoDestroy() { final DataType dataType = mock(DataType.class); recordEngine.doDestroy(dataType); verify(dataTypeDestroyHandler).destroy(dataType); verify(itemDefinitionDestroyHandler).destroy(dataType, true); }
public void doDestroy(final DataType dataType) { doDestroy(dataType, true); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { public void doDestroy(final DataType dataType) { doDestroy(dataType, true); } }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { public void doDestroy(final DataType dataType) { doDestroy(dataType, true); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { public void doDestroy(final DataType dataType) { doDestroy(dataType, true); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
ItemDefinitionRecordEngine implements DataTypeRecordEngine { public void doDestroy(final DataType dataType) { doDestroy(dataType, true); } @Inject ItemDefinitionRecordEngine(final ItemDefinitionStore itemDefinitionStore, final ItemDefinitionDestroyHandler itemDefinitionDestroyHandler, final ItemDefinitionUpdateHandler itemDefinitionUpdateHandler, final ItemDefinitionCreateHandler itemDefinitionCreateHandler, final DataTypeDestroyHandler dataTypeDestroyHandler, final DataTypeUpdateHandler dataTypeUpdateHandler, final DataTypeCreateHandler dataTypeCreateHandler, final DataTypeNameValidator dataTypeNameValidator); @PostConstruct void init(); @Override List<DataType> update(final DataType dataType); @Override List<DataType> destroy(final DataType dataType); @Override List<DataType> destroyWithoutDependentTypes(final DataType dataType); @Override List<DataType> create(final DataType dataType); @Override List<DataType> create(final DataType record, final DataType reference, final CreationType creationType); @Override boolean isValid(final DataType dataType); void doUpdate(final DataType dataType, final ItemDefinition itemDefinition); void doDestroy(final DataType dataType); }
@Test public void testAssignAttributes() { final ExternalLink externalLink = mock(ExternalLink.class); final HierarchicalStreamReader reader = mock(HierarchicalStreamReader.class); when(reader.getAttribute(NAME)).thenReturn(TEST_NAME); when(reader.getAttribute(URL)).thenReturn(TEST_URL); converter.assignAttributes(reader, externalLink); verify(externalLink).setName(TEST_NAME); verify(externalLink).setUrl(TEST_URL); }
@Override protected void assignAttributes(final HierarchicalStreamReader reader, final Object parent) { superAssignAttributes(reader, parent); final ExternalLink externalLink = (ExternalLink) parent; externalLink.setName(reader.getAttribute(NAME)); externalLink.setUrl(reader.getAttribute(URL)); }
ExternalLinksConverter extends DMNModelInstrumentedBaseConverter { @Override protected void assignAttributes(final HierarchicalStreamReader reader, final Object parent) { superAssignAttributes(reader, parent); final ExternalLink externalLink = (ExternalLink) parent; externalLink.setName(reader.getAttribute(NAME)); externalLink.setUrl(reader.getAttribute(URL)); } }
ExternalLinksConverter extends DMNModelInstrumentedBaseConverter { @Override protected void assignAttributes(final HierarchicalStreamReader reader, final Object parent) { superAssignAttributes(reader, parent); final ExternalLink externalLink = (ExternalLink) parent; externalLink.setName(reader.getAttribute(NAME)); externalLink.setUrl(reader.getAttribute(URL)); } ExternalLinksConverter(final XStream xstream); }
ExternalLinksConverter extends DMNModelInstrumentedBaseConverter { @Override protected void assignAttributes(final HierarchicalStreamReader reader, final Object parent) { superAssignAttributes(reader, parent); final ExternalLink externalLink = (ExternalLink) parent; externalLink.setName(reader.getAttribute(NAME)); externalLink.setUrl(reader.getAttribute(URL)); } ExternalLinksConverter(final XStream xstream); @Override boolean canConvert(final Class aClass); }
ExternalLinksConverter extends DMNModelInstrumentedBaseConverter { @Override protected void assignAttributes(final HierarchicalStreamReader reader, final Object parent) { superAssignAttributes(reader, parent); final ExternalLink externalLink = (ExternalLink) parent; externalLink.setName(reader.getAttribute(NAME)); externalLink.setUrl(reader.getAttribute(URL)); } ExternalLinksConverter(final XStream xstream); @Override boolean canConvert(final Class aClass); }
@Test public void testInit() { verify(dataTypeEditor).addValueChangeHandler(valueChangeHandlerCaptor.capture()); valueChangeHandlerCaptor.getValue().onValueChange(valueChangeEvent); assertEquals(view.getCurrentTypeRef(), typeRef); verify(view).setKeyDownListeners(); }
@Override public void init(final Presenter presenter) { this.presenter = presenter; typeRefEditor.addValueChangeHandler(e -> currentTypeRef = e.getValue()); setKeyDownListeners(); }
ValueAndDataTypePopoverViewImpl extends AbstractPopoverViewImpl implements ValueAndDataTypePopoverView { @Override public void init(final Presenter presenter) { this.presenter = presenter; typeRefEditor.addValueChangeHandler(e -> currentTypeRef = e.getValue()); setKeyDownListeners(); } }
ValueAndDataTypePopoverViewImpl extends AbstractPopoverViewImpl implements ValueAndDataTypePopoverView { @Override public void init(final Presenter presenter) { this.presenter = presenter; typeRefEditor.addValueChangeHandler(e -> currentTypeRef = e.getValue()); setKeyDownListeners(); } ValueAndDataTypePopoverViewImpl(); @Inject ValueAndDataTypePopoverViewImpl(final Input valueEditor, final DataTypePickerWidget typeRefEditor, final Div popoverElement, final Div popoverContentElement, final Span valueLabel, final Span dataTypeLabel, final JQueryProducer.JQuery<Popover> jQueryPopover, final TranslationService translationService); }
ValueAndDataTypePopoverViewImpl extends AbstractPopoverViewImpl implements ValueAndDataTypePopoverView { @Override public void init(final Presenter presenter) { this.presenter = presenter; typeRefEditor.addValueChangeHandler(e -> currentTypeRef = e.getValue()); setKeyDownListeners(); } ValueAndDataTypePopoverViewImpl(); @Inject ValueAndDataTypePopoverViewImpl(final Input valueEditor, final DataTypePickerWidget typeRefEditor, final Div popoverElement, final Div popoverContentElement, final Span valueLabel, final Span dataTypeLabel, final JQueryProducer.JQuery<Popover> jQueryPopover, final TranslationService translationService); @Override void init(final Presenter presenter); String getCurrentValue(); QName getCurrentTypeRef(); @Override void setDMNModel(final DMNModelInstrumentedBase dmnModel); @Override void initValue(final String value); @Override void initSelectedTypeRef(final QName typeRef); @Override void show(final Optional<String> popoverTitle); @Override void hide(); void hide(final boolean applyChanges); @Override void reset(); @SuppressWarnings("unused") @EventHandler("valueEditor") void onValueEditorKeyDown(final KeyDownEvent event); }
ValueAndDataTypePopoverViewImpl extends AbstractPopoverViewImpl implements ValueAndDataTypePopoverView { @Override public void init(final Presenter presenter) { this.presenter = presenter; typeRefEditor.addValueChangeHandler(e -> currentTypeRef = e.getValue()); setKeyDownListeners(); } ValueAndDataTypePopoverViewImpl(); @Inject ValueAndDataTypePopoverViewImpl(final Input valueEditor, final DataTypePickerWidget typeRefEditor, final Div popoverElement, final Div popoverContentElement, final Span valueLabel, final Span dataTypeLabel, final JQueryProducer.JQuery<Popover> jQueryPopover, final TranslationService translationService); @Override void init(final Presenter presenter); String getCurrentValue(); QName getCurrentTypeRef(); @Override void setDMNModel(final DMNModelInstrumentedBase dmnModel); @Override void initValue(final String value); @Override void initSelectedTypeRef(final QName typeRef); @Override void show(final Optional<String> popoverTitle); @Override void hide(); void hide(final boolean applyChanges); @Override void reset(); @SuppressWarnings("unused") @EventHandler("valueEditor") void onValueEditorKeyDown(final KeyDownEvent event); }