use of org.eclipse.che.api.project.shared.dto.ProjectImporterDescriptor in project che by eclipse.
the class SubversionProjectImporterPresenterTest method testGo.
/**
* Test for {@link SubversionProjectImporterPresenter#go(AcceptsOneWidget)}.
*
* @throws Exception if anything goes wrong
*/
@Test
public void testGo() throws Exception {
final String importerDescription = "Some description.";
final AcceptsOneWidget container = mock(AcceptsOneWidget.class);
final ProjectImporterDescriptor projectImporter = mock(ProjectImporterDescriptor.class);
when(projectImporter.getDescription()).thenReturn(importerDescription);
presenter.go(container);
verify(container).setWidget(eq(view));
verify(view).setProjectName(anyString());
verify(view).setProjectDescription(anyString());
verify(view).setProjectUrl(anyString());
verify(view).setInputsEnableState(eq(true));
}
use of org.eclipse.che.api.project.shared.dto.ProjectImporterDescriptor in project che by eclipse.
the class MainPagePresenter method loadImporters.
private void loadImporters() {
final Map<String, Set<ProjectImporterDescriptor>> importersByCategory = new LinkedHashMap<>();
final Unmarshallable<ProjectImporterData> unmarshaller = dtoUnmarshallerFactory.newUnmarshaller(ProjectImporterData.class);
AsyncRequestCallback<ProjectImporterData> callback = new AsyncRequestCallback<ProjectImporterData>(unmarshaller) {
@Override
protected void onSuccess(ProjectImporterData data) {
List<ProjectImporterDescriptor> result = data.getImporters();
String defaultImporterId = data.getConfiguration().get(DEFAULT_PROJECT_IMPORTER);
Iterator<ProjectImporterDescriptor> itr = result.iterator();
while (itr.hasNext()) {
ProjectImporterDescriptor importer = itr.next();
if (importer.getId().equals(defaultImporterId)) {
Set<ProjectImporterDescriptor> importersSet = new LinkedHashSet<>();
importersSet.add(importer);
importersByCategory.put(importer.getCategory(), importersSet);
itr.remove();
}
}
ProjectImporterDescriptor defaultImporter = null;
for (ProjectImporterDescriptor importer : result) {
if (importer.isInternal() || importer.getCategory() == null || importWizardRegistry.getWizardRegistrar(importer.getId()) == null) {
continue;
}
if (importersByCategory.containsKey(importer.getCategory())) {
importersByCategory.get(importer.getCategory()).add(importer);
} else {
Set<ProjectImporterDescriptor> importersSet = new LinkedHashSet<>();
importersSet.add(importer);
importersByCategory.put(importer.getCategory(), importersSet);
}
if (importer.getId().equals(defaultImporterId)) {
defaultImporter = importer;
}
}
setImporters(defaultImporter);
}
private void setImporters(final ProjectImporterDescriptor defaultImporter) {
new Timer() {
@Override
public void run() {
view.setImporters(importersByCategory);
view.selectImporter(defaultImporter != null ? defaultImporter : importersByCategory.get(importersByCategory.keySet().iterator().next()).iterator().next());
}
}.schedule(300);
}
@Override
protected void onFailure(Throwable exception) {
notificationManager.notify(locale.failedToImportProject(), FAIL, FLOAT_MODE);
}
};
projectImportersService.getProjectImporters(appContext.getDevMachine(), callback);
}
use of org.eclipse.che.api.project.shared.dto.ProjectImporterDescriptor in project che by eclipse.
the class GithubImporterPagePresenterTest method testGo.
@Test
public void testGo() throws Exception {
String importerDescription = "description";
AcceptsOneWidget container = mock(AcceptsOneWidget.class);
ProjectImporterDescriptor projectImporter = mock(ProjectImporterDescriptor.class);
//when(wizardContext.getData(ImportProjectWizard.PROJECT_IMPORTER)).thenReturn(projectImporter);
when(projectImporter.getDescription()).thenReturn(importerDescription);
presenter.go(container);
verify(view).setInputsEnableState(eq(true));
verify(container).setWidget(eq(view));
verify(view).focusInUrlInput();
}
Aggregations