use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class BaseViewPresenterTest method testAutomaticModuleBuildEnabled.
@Test
public void testAutomaticModuleBuildEnabled() {
final OrganizationalUnit ou = mock(OrganizationalUnit.class);
final Repository repository = mock(Repository.class);
final Module module = mock(Module.class);
ApplicationPreferences.setUp(new HashMap<String, String>());
when(activeContextItems.setupActiveModule(content)).thenReturn(true);
final WorkspaceProject project = mock(WorkspaceProject.class);
when(activeContextItems.getActiveProject()).thenReturn(project);
when(project.getOrganizationalUnit()).thenReturn(ou);
when(project.getRepository()).thenReturn(repository);
when(project.getBranch()).thenReturn(new Branch("master", mock(Path.class)));
when(activeContextItems.getActiveModule()).thenReturn(module);
presenter.doContentCallback(content);
verify(buildServiceActual, times(1)).build(module);
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class BaseViewPresenterTest method testAutomaticModuleBuildDisabledSystemProperty.
@Test
public void testAutomaticModuleBuildDisabledSystemProperty() {
final OrganizationalUnit ou = mock(OrganizationalUnit.class);
final Repository repository = mock(Repository.class);
final Module module = mock(Module.class);
String spBuildDisableModuleExplorer = null;
try {
spBuildDisableModuleExplorer = System.getProperty(ExplorerService.BUILD_PROJECT_PROPERTY_NAME);
System.setProperty(ExplorerService.BUILD_PROJECT_PROPERTY_NAME, "true");
final ExplorerPreferencesLoader preferencesLoader = new ExplorerPreferencesLoader();
ApplicationPreferences.setUp(preferencesLoader.load());
when(activeContextItems.setupActiveModule(content)).thenReturn(true);
final WorkspaceProject project = mock(WorkspaceProject.class);
when(activeContextItems.getActiveProject()).thenReturn(project);
when(project.getOrganizationalUnit()).thenReturn(ou);
when(project.getRepository()).thenReturn(repository);
when(project.getBranch()).thenReturn(new Branch("master", mock(Path.class)));
when(activeContextItems.getActiveModule()).thenReturn(module);
presenter.doContentCallback(content);
verify(buildServiceActual, never()).build(any(Module.class));
} finally {
if (spBuildDisableModuleExplorer != null) {
System.setProperty(ExplorerService.BUILD_PROJECT_PROPERTY_NAME, spBuildDisableModuleExplorer);
}
}
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method importProjectWithoutCredentialsTest.
@Test
public void importProjectWithoutCredentialsTest() {
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
final Repository repo = mock(Repository.class);
final WorkspaceProject project = mock(WorkspaceProject.class);
final String repositoryURL = "file:///some/path/to/fake-repo.git";
final String username = null;
final String password = null;
final ArgumentCaptor<RepositoryEnvironmentConfigurations> configCaptor = ArgumentCaptor.forClass(RepositoryEnvironmentConfigurations.class);
when(repositoryService.createRepository(any(), any(), any(), configCaptor.capture())).thenReturn(repo);
when(projectService.resolveProject(any(Repository.class))).thenReturn(project);
final WorkspaceProject observedProject = libraryService.importProject(organizationalUnit, repositoryURL, username, password);
verify(repositoryService).createRepository(same(organizationalUnit), eq(GitRepository.SCHEME.toString()), eq("fake-repo"), any());
RepositoryEnvironmentConfigurations observedConfig = configCaptor.getValue();
assertEquals(username, observedConfig.getUserName());
assertEquals(password, observedConfig.getPassword());
assertEquals(repositoryURL, observedConfig.getOrigin());
verify(projectService).resolveProject(same(repo));
assertSame(project, observedProject);
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method importProjectFromExampleTest.
@Test
public void importProjectFromExampleTest() {
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
final ExampleProject exampleProject = mock(ExampleProject.class);
final WorkspaceProject project = mock(WorkspaceProject.class);
final Module module = mock(Module.class);
doReturn(module).when(project).getMainModule();
final WorkspaceProjectContextChangeEvent projectContextChangeEvent = mock(WorkspaceProjectContextChangeEvent.class);
doReturn(project).when(projectContextChangeEvent).getWorkspaceProject();
doReturn(projectContextChangeEvent).when(examplesService).setupExamples(any(ExampleOrganizationalUnit.class), anyList());
final WorkspaceProject importedProject = libraryService.importProject(organizationalUnit, exampleProject);
assertEquals(module, importedProject.getMainModule());
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method unexistentProjectDosNotHaveAssetsTest.
@Test
public void unexistentProjectDosNotHaveAssetsTest() {
final Path path = mockPath("file://the_project");
final Package package1 = mock(Package.class);
final WorkspaceProject project1 = mock(WorkspaceProject.class);
when(project1.getRootPath()).thenReturn(path);
final Module module = mock(Module.class);
when(project1.getMainModule()).thenReturn(module);
doReturn(false).when(ioService).exists(any());
doReturn(package1).when(moduleService).resolveDefaultPackage(module);
doReturn(true).when(explorerServiceHelper).hasAssets(package1);
assertFalse(libraryService.hasAssets(project1));
}
Aggregations