DtoConverter { public ProjectTemplateDescription fromDto(ProjectTemplateDescriptor dto) { final String category = dto.getCategory(); final ImportSourceDescriptor importSource = dto.getSource(); final BuildersDescriptor builders = dto.getBuilders(); final RunnersDescriptor runners = dto.getRunners(); return new ProjectTemplateDescription( category == null ? org.eclipse.che.api.project.shared.Constants.DEFAULT_TEMPLATE_CATEGORY : category, importSource == null ? null : importSource.getType(), dto.getDisplayName(), dto.getDescription(), importSource == null ? null : importSource.getLocation(), importSource == null ? null : importSource.getParameters(), builders == null ? null : fromDto(builders), runners == null ? null : fromDto(runners)); }  ProjectTemplateDescription fromDto(ProjectTemplateDescriptor dto); ProjectTemplateDescriptor toDto(ProjectTemplateDescription templateDescription); ProjectConfig fromDto2(ProjectUpdate dto, ProjectTypeRegistry typeRegistry); ProjectConfig toProjectConfig(ProjectModule dto, ProjectTypeRegistry typeRegistry); Builders fromDto(BuildersDescriptor dto); Runners fromDto(RunnersDescriptor dto); ProjectTypeDefinition toTypeDescriptor2(ProjectType projectType); ProjectTemplateDescriptor toTemplateDescriptor(ProjectTemplateDescription projectTemplate, String projectType); ProjectImporterDescriptor toImporterDescriptor(ProjectImporter importer); ItemReference toItemReferenceDto(FileEntry file, UriBuilder uriBuilder); ItemReference toItemReferenceDto(FolderEntry folder, UriBuilder uriBuilder); ProjectDescriptor toDescriptorDto2(Project project,
                                                     UriBuilder serviceUriBuilder,
                                                     UriBuilder baseUriBuilder,
                                                     ProjectTypeRegistry ptRegistry,
                                                     String wsId); BuildersDescriptor toDto(Builders builders); RunnersDescriptor toDto(Runners runners); ProjectReference toReferenceDto2(Project project,
                                                   UriBuilder uriBuilder,
                                                   UriBuilder baseUriBuilder);  }
@Test public void buildersFromDtoBuildersDescriptor() { String optionsKey = NameGenerator.generate("optionsKey",5); String optionsValue = NameGenerator.generate("optionsValue",5); String optionsKey1 = NameGenerator.generate("optionsKey",5); String optionsValue1 = NameGenerator.generate("optionsValue",5); String optionsKey2 = NameGenerator.generate("optionsKey",5); String optionsValue2 = NameGenerator.generate("optionsValue",5); Map<String, String> options = new HashMap<>(3); options.put(optionsKey,optionsValue); options.put(optionsKey1,optionsValue1); options.put(optionsKey2,optionsValue2); String target1 = NameGenerator.generate("target",5); String target2 = NameGenerator.generate("target",5); List<String> targets = new ArrayList<>(2); targets.add(target1); targets.add(target2); BuilderConfiguration builderConfiguration = mock(BuilderConfiguration.class); when(builderConfiguration.getOptions()).thenReturn(options); when(builderConfiguration.getTargets()).thenReturn(targets); Map<String, BuilderConfiguration> configurationMap = new HashMap<>(); String confName = NameGenerator.generate("conf",5); configurationMap.put(confName, builderConfiguration); String defaultBuilder = NameGenerator.generate("builder",5); BuildersDescriptor buildersDescriptor = mock(BuildersDescriptor.class); when(buildersDescriptor.getConfigs()).thenReturn(configurationMap); when(buildersDescriptor.getDefault()).thenReturn(defaultBuilder); Builders builders = new DtoConverter().fromDto(buildersDescriptor); Assert.assertNotNull(builders); Assert.assertEquals(defaultBuilder, builders.getDefault()); Builders.Config config = builders.getConfig(confName); Assert.assertNotNull(config); Assert.assertNotNull(config.getTargets()); Assert.assertEquals(2, config.getTargets().size()); Assert.assertTrue(config.getTargets().contains(target1)); Assert.assertTrue(config.getTargets().contains(target2)); Assert.assertNotNull(config.getOptions()); Assert.assertEquals(3, config.getOptions().size()); Assert.assertTrue(config.getOptions().containsKey(optionsKey)); Assert.assertTrue(config.getOptions().containsKey(optionsKey1)); Assert.assertTrue(config.getOptions().containsKey(optionsKey2)); Assert.assertTrue(config.getOptions().containsValue(optionsValue)); Assert.assertTrue(config.getOptions().containsValue(optionsValue1)); Assert.assertTrue(config.getOptions().containsValue(optionsValue2)); }