use of org.guvnor.structure.organizationalunit.OrganizationalUnit in project kie-wb-common by kiegroup.
the class ProjectScreenServiceImplTest method testCopy.
@Test
public void testCopy() throws Exception {
final WorkspaceProject project = mock(WorkspaceProject.class);
final OrganizationalUnit ou = mock(OrganizationalUnit.class);
final Path projectRoot = mock(Path.class);
doReturn(ou).when(project).getOrganizationalUnit();
doReturn(projectRoot).when(project).getRootPath();
final Repository newRepository = mock(Repository.class);
final Path newRepositoryRoot = PathFactory.newPath("root", "file:///root");
doReturn(Optional.of(new Branch("master", newRepositoryRoot))).when(newRepository).getDefaultBranch();
doReturn(newRepository).when(repositoryCopier).copy(ou, "newName", projectRoot);
final ArgumentCaptor<POM> pomArgumentCaptor = ArgumentCaptor.forClass(POM.class);
final POM pom = new POM();
doReturn(pom).when(pomService).load(any(Path.class));
final Metadata metadata = mock(Metadata.class);
doReturn(metadata).when(metadataService).getMetadata(any(Path.class));
service.copy(project, "newName");
verify(pomService).save(any(Path.class), pomArgumentCaptor.capture(), eq(metadata), eq("Renaming the project."), eq(true));
final POM updatedPom = pomArgumentCaptor.getValue();
assertEquals("newName", updatedPom.getName());
assertEquals("newName", updatedPom.getGav().getArtifactId());
}
use of org.guvnor.structure.organizationalunit.OrganizationalUnit in project kie-wb-common by kiegroup.
the class NewWorkspaceProjectHandlerTest method testGetCommandWithActiveRepository.
@Test
public void testGetCommandWithActiveRepository() {
final LibraryOrganizationalUnitPreferences libraryOrganizationalUnitPreferences = mock(LibraryOrganizationalUnitPreferences.class);
when(libraryOrganizationalUnitPreferences.getName()).thenReturn("myOU");
when(libraryPreferences.getOrganizationalUnitPreferences()).thenReturn(libraryOrganizationalUnitPreferences);
when(context.getActiveWorkspaceProject()).thenReturn(Optional.of(new WorkspaceProject(mock(OrganizationalUnit.class), repository, mock(Branch.class), mock(Module.class))));
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
when(organizationalUnit.getDefaultGroupId()).thenReturn("defaultGroupId");
when(organizationalUnitService.getOrganizationalUnit("myOU")).thenReturn(organizationalUnit);
doAnswer(new Answer() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
when(context.getActiveOrganizationalUnit()).thenReturn(Optional.of(organizationalUnit));
return null;
}
}).when(projectContextChangeEvent).fire(any(WorkspaceProjectContextChangeEvent.class));
final Command command = handler.getCommand(newResourcePresenter);
assertNotNull(command);
command.execute();
ArgumentCaptor<POM> pomArgumentCaptor = ArgumentCaptor.forClass(POM.class);
verify(wizard, times(1)).initialise(pomArgumentCaptor.capture());
verify(wizard, times(1)).start(any(org.uberfire.client.callbacks.Callback.class), anyBoolean());
assertEquals("defaultGroupId", pomArgumentCaptor.getValue().getGav().getGroupId());
assertEquals("kjar", pomArgumentCaptor.getValue().getPackaging());
}
use of org.guvnor.structure.organizationalunit.OrganizationalUnit in project kie-wb-common by kiegroup.
the class NewWorkspaceProjectWizardTest method testInitialize.
@Test
public void testInitialize() throws Exception {
OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
when(organizationalUnit.getDefaultGroupId()).thenReturn("mygroup");
when(moduleContext.getActiveOrganizationalUnit()).thenReturn(Optional.of(organizationalUnit));
wizard.initialise();
ArgumentCaptor<POM> pomArgumentCaptor = ArgumentCaptor.forClass(POM.class);
verify(pomWizardPage).setPom(pomArgumentCaptor.capture());
assertEquals("mygroup", pomArgumentCaptor.getValue().getGav().getGroupId());
}
use of org.guvnor.structure.organizationalunit.OrganizationalUnit in project kie-wb-common by kiegroup.
the class ExamplesServiceImplRepositoryNamesTest method setup.
@Before
public void setup() {
service = spy(new ExamplesServiceImpl(ioService, configurationFactory, repositoryFactory, moduleService, repositoryService, repositoryCopier, ouService, projectService, metadataService, spaces, newProjectEvent, projectScreenService));
when(ouService.getOrganizationalUnits()).thenReturn(new HashSet<OrganizationalUnit>() {
{
add(new OrganizationalUnitImpl("ou1Name", "ou1Owner", "ou1GroupId"));
}
});
when(moduleService.resolveModule(any(Path.class))).thenAnswer(new Answer<KieModule>() {
@Override
public KieModule answer(final InvocationOnMock invocationOnMock) throws Throwable {
final Path path = (Path) invocationOnMock.getArguments()[0];
final KieModule module = new KieModule(path, path, path, path, path, path, mock(POM.class));
return module;
}
});
when(sessionInfo.getId()).thenReturn("sessionId");
when(sessionInfo.getIdentity()).thenReturn(user);
when(user.getIdentifier()).thenReturn("user");
when(configurationFactory.newConfigGroup(any(ConfigType.class), anyString(), anyString())).thenReturn(mock(ConfigGroup.class));
final ExampleProject exProject1 = mock(ExampleProject.class);
exampleProjects = new ArrayList<ExampleProject>() {
{
add(exProject1);
}
};
final OrganizationalUnit ou = mock(OrganizationalUnit.class);
doReturn("ou").when(ou).getName();
final GitRepository repository1 = mock(GitRepository.class);
final Path repositoryRoot = mock(Path.class);
final Path module1Root = mock(Path.class);
when(exampleOrganizationalUnit.getName()).thenReturn("ou");
when(exProject1.getName()).thenReturn("module1");
when(exProject1.getRoot()).thenReturn(module1Root);
when(repository1.getBranch("dev_branch")).thenReturn(Optional.of(new Branch("dev_branch", repositoryRoot)));
final Optional<Branch> master = Optional.of(new Branch("master", PathFactory.newPath("testFile", "file:///")));
when(repository1.getDefaultBranch()).thenReturn(master);
when(repositoryRoot.toURI()).thenReturn("default:///");
when(module1Root.toURI()).thenReturn("default:///module1");
when(ouService.getOrganizationalUnit(eq("ou"))).thenReturn(ou);
doReturn("module1").when(repository1).getAlias();
doReturn(repository1).when(repositoryCopier).copy(eq(ou), anyString(), eq(module1Root));
final WorkspaceProject project = spy(new WorkspaceProject());
doReturn(repository1.getAlias()).when(project).getName();
doReturn(mock(Module.class)).when(project).getMainModule();
doReturn(mock(OrganizationalUnit.class)).when(project).getOrganizationalUnit();
doReturn(project).when(projectService).resolveProject(repository1);
doReturn(project).when(projectService).resolveProject(any(Path.class));
final ProjectScreenModel model = new ProjectScreenModel();
model.setPOM(new POM());
doReturn(model).when(projectScreenService).load(any());
}
use of org.guvnor.structure.organizationalunit.OrganizationalUnit in project kie-wb-common by kiegroup.
the class ExamplesServiceImplTest method setup.
@Before
public void setup() {
service = spy(new ExamplesServiceImpl(ioService, configurationFactory, repositoryFactory, moduleService, repositoryService, repositoryCopier, ouService, projectService, metadataService, spaces, newProjectEvent, projectScreenService));
when(ouService.getOrganizationalUnits()).thenReturn(new HashSet<OrganizationalUnit>() {
{
add(new OrganizationalUnitImpl("ou1Name", "ou1Owner", "ou1GroupId"));
add(new OrganizationalUnitImpl("ou2Name", "ou2Owner", "ou2GroupId"));
}
});
when(moduleService.resolveModule(any(Path.class))).thenAnswer(new Answer<KieModule>() {
@Override
public KieModule answer(final InvocationOnMock invocationOnMock) throws Throwable {
final Path path = (Path) invocationOnMock.getArguments()[0];
final KieModule module = new KieModule(path, path, path, path, path, path, mock(POM.class));
return module;
}
});
when(sessionInfo.getId()).thenReturn("sessionId");
when(sessionInfo.getIdentity()).thenReturn(user);
when(user.getIdentifier()).thenReturn("user");
when(configurationFactory.newConfigGroup(any(ConfigType.class), anyString(), anyString(), anyString())).thenReturn(mock(ConfigGroup.class));
}
Aggregations