### Question:
DataTypeManager { DataType createSubDataType(final ItemDefinition itemDefinition) { return anotherManager() .newDataType(getDataType().isReadOnly()) .withUUID() .withParentUUID(getDataTypeUUID().orElseThrow(() -> new UnsupportedOperationException("A parent data type must have an UUID."))) .withItemDefinition(itemDefinition) .withItemDefinitionName() .withItemDefinitionType() .withItemDefinitionConstraint() .withItemDefinitionCollection() .withTypeStack(getSubDataTypeStack()) .withItemDefinitionSubDataTypes() .withIndexedItemDefinition() .get(); } @Inject  DataTypeManager(final TranslationService translationService,
                           final ItemDefinitionRecordEngine recordEngine,
                           final ItemDefinitionStore itemDefinitionStore,
                           final DataTypeStore dataTypeStore,
                           final ItemDefinitionUtils itemDefinitionUtils,
                           final ManagedInstance<DataTypeManager> dataTypeManagers,
                           final DataTypeNameValidator dataTypeNameValidator,
                           final DataTypeManagerStackStore typeStack); DataTypeManager fromNew(); DataTypeManager from(final ItemDefinition itemDefinition); DataTypeManager from(final BuiltInType builtInType); DataTypeManager from(final DataType dataType); DataTypeManager withParentUUID(final String parentUUID); DataTypeManager withName(final String name); DataTypeManager withType(final String type); DataTypeManager withConstraint(final String constraint); DataTypeManager withConstraintType(final String constraintType); DataTypeManager asList(final boolean isCollection); DataTypeManager withNoConstraint(); DataTypeManager withDataType(final DataType dataType); DataTypeManager withItemDefinition(final ItemDefinition itemDefinition); DataTypeManager withRefreshedSubDataTypes(final String newType); DataTypeManager withSubDataTypes(final List<DataType> dataTypes); DataTypeManager withNoName(); DataTypeManager withUniqueName(); DataTypeManager withUniqueName(final String name); DataTypeManager withItemDefinitionSubDataTypes(); DataTypeManager withIndexedItemDefinition(); DataType get(); List<DataType> makeExternalDataTypes(final String typeName); String structure(); String getTypeName(); DataTypeManager asStructure(); Optional<DataType> getTopLevelDataTypeWithName(final String typeName);  }### Answer:
@Test public void testCreateSubDataType() { final DataType expectedDataType = mock(DataType.class); final ItemDefinition itemDefinition = mock(ItemDefinition.class); final List<String> subDataTypeStack = singletonList("type"); final String expectedParentUUID = "expectedParentUUID"; doReturn(expectedDataType).when(manager).getDataType(); doReturn(manager).when(manager).anotherManager(); doReturn(manager).when(manager).newDataType(anyBoolean()); doReturn(manager).when(manager).withUUID(); doReturn(manager).when(manager).withParentUUID(anyString()); doReturn(manager).when(manager).withItemDefinition(any()); doReturn(manager).when(manager).withItemDefinition(any()); doReturn(manager).when(manager).withItemDefinitionName(); doReturn(manager).when(manager).withItemDefinitionType(); doReturn(manager).when(manager).withItemDefinitionConstraint(); doReturn(manager).when(manager).withItemDefinitionCollection(); doReturn(manager).when(manager).withTypeStack(any()); doReturn(manager).when(manager).withItemDefinitionSubDataTypes(); doReturn(manager).when(manager).withIndexedItemDefinition(); doReturn(subDataTypeStack).when(manager).getSubDataTypeStack(); doReturn(expectedDataType).when(manager).get(); when(expectedDataType.isReadOnly()).thenReturn(false); when(expectedDataType.getUUID()).thenReturn(expectedParentUUID); final DataType actualDataType = manager.createSubDataType(itemDefinition); final InOrder inOrder = Mockito.inOrder(manager); inOrder.verify(manager).newDataType(false); inOrder.verify(manager).withUUID(); inOrder.verify(manager).withParentUUID(expectedParentUUID); inOrder.verify(manager).withItemDefinition(itemDefinition); inOrder.verify(manager).withItemDefinitionName(); inOrder.verify(manager).withItemDefinitionType(); inOrder.verify(manager).withTypeStack(subDataTypeStack); inOrder.verify(manager).withItemDefinitionSubDataTypes(); inOrder.verify(manager).withIndexedItemDefinition(); assertEquals(expectedDataType, actualDataType); }