### Question:
DataTypeManager { Optional<DataType> findTopLevelDataTypeWithName(final String typeName) { return dataTypeStore.getTopLevelDataTypes().stream() .filter(data -> Objects.equals(data.getName(), typeName)) .findFirst(); } @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 testFindTopLevelDataTypeWithName() { final DataType dt1 = mock(DataType.class); final String dt1Name = "The Name"; when(dt1.getName()).thenReturn(dt1Name); final DataType dt2 = mock(DataType.class); final String dt2Name = "The Other Name"; when(dt2.getName()).thenReturn(dt2Name); final List<DataType> store = Arrays.asList(dt1, dt2); when(dataTypeStore.getTopLevelDataTypes()).thenReturn(store); Optional<DataType> foundDt = manager.findTopLevelDataTypeWithName(dt1Name); assertTrue(foundDt.isPresent()); assertEquals(dt1, foundDt.get()); foundDt = manager.findTopLevelDataTypeWithName(dt2Name); assertTrue(foundDt.isPresent()); assertEquals(dt2, foundDt.get()); Optional<DataType> notFoundDt = manager.findTopLevelDataTypeWithName("not present"); assertFalse(notFoundDt.isPresent()); }