@Test public void testUpdateProperties() { final DataType dataType = spy(makeDataType()); final String uuid = "uuid"; final String expectedName = "name"; final String expectedType = "type"; final String expectedConstraint = "constraint"; final boolean expectedList = true; final ItemDefinition itemDefinition = mock(ItemDefinition.class); when(dataType.getUUID()).thenReturn(uuid); when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition); when(view.getName()).thenReturn(expectedName); when(dataTypeSelectComponent.getValue()).thenReturn(expectedType); when(dataTypeConstraintComponent.getValue()).thenReturn(expectedConstraint); when(dataTypeListComponent.getValue()).thenReturn(expectedList); when(dataTypeManager.get()).thenReturn(dataType); final DataType updatedDataType = listItem.updateProperties(dataType); assertEquals(expectedName, updatedDataType.getName()); assertEquals(expectedType, updatedDataType.getType()); assertEquals(expectedConstraint, updatedDataType.getConstraint()); assertEquals(expectedList, updatedDataType.isList()); }
DataType updateProperties(final DataType dataType) { return dataTypeManager .from(dataType) .withName(NameUtils.normaliseName(getName())) .withType(getType()) .withConstraint(getConstraint()) .withConstraintType(getConstraintType()) .asList(isList()) .get(); }
DataTypeListItem { DataType updateProperties(final DataType dataType) { return dataTypeManager .from(dataType) .withName(NameUtils.normaliseName(getName())) .withType(getType()) .withConstraint(getConstraint()) .withConstraintType(getConstraintType()) .asList(isList()) .get(); } }
DataTypeListItem { DataType updateProperties(final DataType dataType) { return dataTypeManager .from(dataType) .withName(NameUtils.normaliseName(getName())) .withType(getType()) .withConstraint(getConstraint()) .withConstraintType(getConstraintType()) .asList(isList()) .get(); } @Inject  DataTypeListItem(final View view,
                            final DataTypeSelect dataTypeSelectComponent,
                            final DataTypeConstraint dataTypeConstraintComponent,
                            final SmallSwitchComponent dataTypeListComponent,
                            final DataTypeManager dataTypeManager,
                            final DataTypeConfirmation confirmation,
                            final DataTypeNameFormatValidator nameFormatValidator,
                            final Event<DataTypeEditModeToggleEvent> editModeToggleEvent,
                            final Event<DataTypeChangedEvent> dataTypeChangedEvent); }
DataTypeListItem { DataType updateProperties(final DataType dataType) { return dataTypeManager .from(dataType) .withName(NameUtils.normaliseName(getName())) .withType(getType()) .withConstraint(getConstraint()) .withConstraintType(getConstraintType()) .asList(isList()) .get(); } @Inject  DataTypeListItem(final View view,
                            final DataTypeSelect dataTypeSelectComponent,
                            final DataTypeConstraint dataTypeConstraintComponent,
                            final SmallSwitchComponent dataTypeListComponent,
                            final DataTypeManager dataTypeManager,
                            final DataTypeConfirmation confirmation,
                            final DataTypeNameFormatValidator nameFormatValidator,
                            final Event<DataTypeEditModeToggleEvent> editModeToggleEvent,
                            final Event<DataTypeChangedEvent> dataTypeChangedEvent); void init(final DataTypeList dataTypeList); DataType getDataType(); boolean isReadOnly(); int getLevel(); boolean isCollapsed(); void expand(); void collapse(); void enableEditMode(); void disableEditMode(); void saveAndCloseEditMode(); void remove(); Command removeItem(); Command destroy(); void destroyWithDependentTypes(); void destroyWithoutDependentTypes(); String getType(); void insertFieldAbove(); String insertFieldAbove(final DataType dataType); void insertFieldBelow(); String insertFieldBelow(final DataType dataType); void insertNestedField(); void insertNestedField(final DataType newDataType); HTMLElement getDragAndDropElement(); void highlightLevel(final DataType dataType); }
DataTypeListItem { DataType updateProperties(final DataType dataType) { return dataTypeManager .from(dataType) .withName(NameUtils.normaliseName(getName())) .withType(getType()) .withConstraint(getConstraint()) .withConstraintType(getConstraintType()) .asList(isList()) .get(); } @Inject  DataTypeListItem(final View view,
                            final DataTypeSelect dataTypeSelectComponent,
                            final DataTypeConstraint dataTypeConstraintComponent,
                            final SmallSwitchComponent dataTypeListComponent,
                            final DataTypeManager dataTypeManager,
                            final DataTypeConfirmation confirmation,
                            final DataTypeNameFormatValidator nameFormatValidator,
                            final Event<DataTypeEditModeToggleEvent> editModeToggleEvent,
                            final Event<DataTypeChangedEvent> dataTypeChangedEvent); void init(final DataTypeList dataTypeList); DataType getDataType(); boolean isReadOnly(); int getLevel(); boolean isCollapsed(); void expand(); void collapse(); void enableEditMode(); void disableEditMode(); void saveAndCloseEditMode(); void remove(); Command removeItem(); Command destroy(); void destroyWithDependentTypes(); void destroyWithoutDependentTypes(); String getType(); void insertFieldAbove(); String insertFieldAbove(final DataType dataType); void insertFieldBelow(); String insertFieldBelow(final DataType dataType); void insertNestedField(); void insertNestedField(final DataType newDataType); HTMLElement getDragAndDropElement(); void highlightLevel(final DataType dataType);  }