@Test public void testLoadTemplatesWhenDefaultNotPresent() { final ArchetypePreferences preferences = mock(ArchetypePreferences.class); final Map<String, Boolean> archetypeSelectionMap = new HashMap<>(); archetypeSelectionMap.put("template1", true); archetypeSelectionMap.put("template2", true); archetypeSelectionMap.put("template3", false); doReturn(archetypeSelectionMap).when(preferences).getArchetypeSelectionMap(); doReturn("template3").when(preferences).getDefaultSelection(); final List<String> templates = Arrays.asList("template1", "template2"); presenter.finishLoadTemplates(preferences); verify(view).setTemplates(templates, 0); }
void finishLoadTemplates(final ArchetypePreferences preferences) { final List<String> templates = preferences.getArchetypeSelectionMap() .entrySet() .stream() .filter(Map.Entry::getValue) .map(Map.Entry::getKey) .sorted() .collect(Collectors.toList()); final boolean templatesAvailable = !templates.isEmpty(); if (templatesAvailable) { final String defaultSelection = preferences.getDefaultSelection(); final int selectedTemplateIdx = IntStream.range(0, templates.size()) .filter(i -> templates.get(i).equals(defaultSelection)) .findFirst() .orElse(0); view.setTemplates(templates, selectedTemplateIdx); } else { view.setTemplates(Collections.singletonList( translationService.getTranslation(LibraryConstants.NoTemplatesAvailable)), 0); } view.enableBasedOnTemplatesCheckbox(templatesAvailable); view.show(); }
AddProjectPopUpPresenter { void finishLoadTemplates(final ArchetypePreferences preferences) { final List<String> templates = preferences.getArchetypeSelectionMap() .entrySet() .stream() .filter(Map.Entry::getValue) .map(Map.Entry::getKey) .sorted() .collect(Collectors.toList()); final boolean templatesAvailable = !templates.isEmpty(); if (templatesAvailable) { final String defaultSelection = preferences.getDefaultSelection(); final int selectedTemplateIdx = IntStream.range(0, templates.size()) .filter(i -> templates.get(i).equals(defaultSelection)) .findFirst() .orElse(0); view.setTemplates(templates, selectedTemplateIdx); } else { view.setTemplates(Collections.singletonList( translationService.getTranslation(LibraryConstants.NoTemplatesAvailable)), 0); } view.enableBasedOnTemplatesCheckbox(templatesAvailable); view.show(); } }
AddProjectPopUpPresenter { void finishLoadTemplates(final ArchetypePreferences preferences) { final List<String> templates = preferences.getArchetypeSelectionMap() .entrySet() .stream() .filter(Map.Entry::getValue) .map(Map.Entry::getKey) .sorted() .collect(Collectors.toList()); final boolean templatesAvailable = !templates.isEmpty(); if (templatesAvailable) { final String defaultSelection = preferences.getDefaultSelection(); final int selectedTemplateIdx = IntStream.range(0, templates.size()) .filter(i -> templates.get(i).equals(defaultSelection)) .findFirst() .orElse(0); view.setTemplates(templates, selectedTemplateIdx); } else { view.setTemplates(Collections.singletonList( translationService.getTranslation(LibraryConstants.NoTemplatesAvailable)), 0); } view.enableBasedOnTemplatesCheckbox(templatesAvailable); view.show(); } @Inject  AddProjectPopUpPresenter(final Caller<LibraryService> libraryService,
                                    final BusyIndicatorView busyIndicatorView,
                                    final Event<NotificationEvent> notificationEvent,
                                    final LibraryPlaces libraryPlaces,
                                    final WorkspaceProjectContext projectContext,
                                    final View view,
                                    final SessionInfo sessionInfo,
                                    final Event<NewProjectEvent> newProjectEvent,
                                    final LibraryPreferences libraryPreferences,
                                    final ConflictingRepositoriesPopup conflictingRepositoriesPopup,
                                    final Caller<ValidationService> validationService,
                                    final ErrorPopup errorPopup,
                                    final TranslationService translationService,
                                    final Caller<WorkspaceProjectService> projectService,
                                    final Logger logger,
                                    final ArchetypePreferences archetypePreferences,
                                    final SpaceScopedResolutionStrategySupplier spaceScopedResolutionStrategySupplier); }
AddProjectPopUpPresenter { void finishLoadTemplates(final ArchetypePreferences preferences) { final List<String> templates = preferences.getArchetypeSelectionMap() .entrySet() .stream() .filter(Map.Entry::getValue) .map(Map.Entry::getKey) .sorted() .collect(Collectors.toList()); final boolean templatesAvailable = !templates.isEmpty(); if (templatesAvailable) { final String defaultSelection = preferences.getDefaultSelection(); final int selectedTemplateIdx = IntStream.range(0, templates.size()) .filter(i -> templates.get(i).equals(defaultSelection)) .findFirst() .orElse(0); view.setTemplates(templates, selectedTemplateIdx); } else { view.setTemplates(Collections.singletonList( translationService.getTranslation(LibraryConstants.NoTemplatesAvailable)), 0); } view.enableBasedOnTemplatesCheckbox(templatesAvailable); view.show(); } @Inject  AddProjectPopUpPresenter(final Caller<LibraryService> libraryService,
                                    final BusyIndicatorView busyIndicatorView,
                                    final Event<NotificationEvent> notificationEvent,
                                    final LibraryPlaces libraryPlaces,
                                    final WorkspaceProjectContext projectContext,
                                    final View view,
                                    final SessionInfo sessionInfo,
                                    final Event<NewProjectEvent> newProjectEvent,
                                    final LibraryPreferences libraryPreferences,
                                    final ConflictingRepositoriesPopup conflictingRepositoriesPopup,
                                    final Caller<ValidationService> validationService,
                                    final ErrorPopup errorPopup,
                                    final TranslationService translationService,
                                    final Caller<WorkspaceProjectService> projectService,
                                    final Logger logger,
                                    final ArchetypePreferences archetypePreferences,
                                    final SpaceScopedResolutionStrategySupplier spaceScopedResolutionStrategySupplier); @PostConstruct void setup(); void setSuccessCallback(ParameterizedCommand<WorkspaceProject> successCallback); void show(); void add(); void onProjectIndexingFinishedEvent(@Observes IndexingFinishedEvent event); ParameterizedCommand<WorkspaceProject> getSuccessCallback(); ParameterizedCommand<WorkspaceProject> getProjectCreationSuccessCallback(); void cancel(); void setDefaultArtifactId(); void restoreAdvancedOptions(); }
AddProjectPopUpPresenter { void finishLoadTemplates(final ArchetypePreferences preferences) { final List<String> templates = preferences.getArchetypeSelectionMap() .entrySet() .stream() .filter(Map.Entry::getValue) .map(Map.Entry::getKey) .sorted() .collect(Collectors.toList()); final boolean templatesAvailable = !templates.isEmpty(); if (templatesAvailable) { final String defaultSelection = preferences.getDefaultSelection(); final int selectedTemplateIdx = IntStream.range(0, templates.size()) .filter(i -> templates.get(i).equals(defaultSelection)) .findFirst() .orElse(0); view.setTemplates(templates, selectedTemplateIdx); } else { view.setTemplates(Collections.singletonList( translationService.getTranslation(LibraryConstants.NoTemplatesAvailable)), 0); } view.enableBasedOnTemplatesCheckbox(templatesAvailable); view.show(); } @Inject  AddProjectPopUpPresenter(final Caller<LibraryService> libraryService,
                                    final BusyIndicatorView busyIndicatorView,
                                    final Event<NotificationEvent> notificationEvent,
                                    final LibraryPlaces libraryPlaces,
                                    final WorkspaceProjectContext projectContext,
                                    final View view,
                                    final SessionInfo sessionInfo,
                                    final Event<NewProjectEvent> newProjectEvent,
                                    final LibraryPreferences libraryPreferences,
                                    final ConflictingRepositoriesPopup conflictingRepositoriesPopup,
                                    final Caller<ValidationService> validationService,
                                    final ErrorPopup errorPopup,
                                    final TranslationService translationService,
                                    final Caller<WorkspaceProjectService> projectService,
                                    final Logger logger,
                                    final ArchetypePreferences archetypePreferences,
                                    final SpaceScopedResolutionStrategySupplier spaceScopedResolutionStrategySupplier); @PostConstruct void setup(); void setSuccessCallback(ParameterizedCommand<WorkspaceProject> successCallback); void show(); void add(); void onProjectIndexingFinishedEvent(@Observes IndexingFinishedEvent event); ParameterizedCommand<WorkspaceProject> getSuccessCallback(); ParameterizedCommand<WorkspaceProject> getProjectCreationSuccessCallback(); void cancel(); void setDefaultArtifactId(); void restoreAdvancedOptions();  }