Commit e57fd7da authored by Romain Bioteau's avatar Romain Bioteau
Browse files

Fix Unit tests

parent 8873fa45
......@@ -22,6 +22,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import org.bonitasoft.studio.common.extension.ExtensionContextInjectionFactory;
import org.bonitasoft.studio.common.repository.core.BonitaHomeHandler;
import org.bonitasoft.studio.common.repository.core.ProjectClasspathFactory;
import org.bonitasoft.studio.common.repository.core.ProjectManifestFactory;
import org.bonitasoft.studio.common.repository.jdt.JDTTypeHierarchyManager;
......@@ -50,6 +51,8 @@ public class RepositoryTest {
private IProgressMonitor monitor;
@Mock
private ProjectClasspathFactory bonitaBPMProjectClasspath;
@Mock
private BonitaHomeHandler bonitaHomeHandler;
@Test
public void should_open_trigger_project_manifest_factory() throws Exception {
......@@ -80,7 +83,7 @@ public class RepositoryTest {
@Test
public void should_refresh_project_when_deleting_an_open_repository() throws Exception {
final Repository repository = spy(newRepository());
final Repository repository = newRepository();
doReturn(true).when(repository).isBuildEnable();
doReturn(true).when(project).isOpen();
......@@ -90,8 +93,10 @@ public class RepositoryTest {
}
private Repository newRepository() {
return new Repository(workspace, project, extensionContextInjectionFactory, jdtTypeHierarchyManager, projectManifestFactory,
bonitaBPMProjectClasspath, true);
final Repository repo = spy(new Repository(workspace, project, extensionContextInjectionFactory, jdtTypeHierarchyManager, projectManifestFactory,
bonitaBPMProjectClasspath, true));
doReturn(bonitaHomeHandler).when(repo).getBonitaHomeHandler();
return repo;
}
}
......@@ -24,6 +24,7 @@ import org.bonitasoft.studio.common.ProjectUtil;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.platform.tools.PlatformUtil;
import org.bonitasoft.studio.common.repository.CommonRepositoryPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
......@@ -35,7 +36,7 @@ public class BonitaHomeHandler {
public static final String BONITA_HOME = "bonita_home";
private final IProject project;
public BonitaHomeHandler(IProject project) {
public BonitaHomeHandler(final IProject project) {
this.project = project;
}
......@@ -85,11 +86,11 @@ public class BonitaHomeHandler {
return Paths.get(getRoot(), "engine-server", "work", "platform").toFile();
}
public String getRoot(){
public String getRoot() {
return project.getFile(BONITA_HOME).getLocation().toFile().getAbsolutePath();
}
public void initBonitaHome(IProgressMonitor monitor) throws CoreException {
public void initBonitaHome(final IProgressMonitor monitor) throws CoreException {
final File bonitaHome = new File(getRoot());
if (!bonitaHome.exists()) {
final URL url = ProjectUtil.getConsoleLibsBundle().getResource("tomcat/bonita");
......@@ -144,4 +145,8 @@ public class BonitaHomeHandler {
+ File.separator + "work"
+ File.separator + "i18n");
}
public IFile getCustomPermissionMappingFile() {
return project.getFile(BONITA_HOME + "/client/tenants/1/conf/custom-permissions-mapping.properties");
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment