### Question:
DataTypeManager { ItemDefinition getItemDefinitionWithItemComponent(final ItemDefinition itemDefinition) { if (itemDefinition.getTypeRef() != null) { final Optional<ItemDefinition> definition = findByName(itemDefinitionType(itemDefinition)); if (definition.isPresent()) { return getItemDefinitionWithItemComponent(definition.get()); } } return itemDefinition; } @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 testGetItemDefinitionWithItemComponent() { final ItemDefinition expectedItemDefinition = mock(ItemDefinition.class); final ItemDefinition tPerson = mock(ItemDefinition.class); final QName tPersonQName = mock(QName.class); final String tPersonValue = "tPersonRaw"; when(tPerson.getTypeRef()).thenReturn(tPersonQName); when(tPersonQName.getLocalPart()).thenReturn(tPersonValue); when(itemDefinitionUtils.findByName(tPersonValue)).thenReturn(Optional.of(expectedItemDefinition)); final ItemDefinition actualItemDefinition = manager.getItemDefinitionWithItemComponent(tPerson); assertEquals(expectedItemDefinition, actualItemDefinition); }