예제 #1
0
  public Builder(
      final Project project,
      final IOService ioService,
      final KieProjectService projectService,
      final ProjectImportsService importsService,
      final List<BuildValidationHelper> buildValidationHelpers,
      final PackageNameWhiteList packageNameWhiteList,
      final LRUProjectDependenciesClassLoaderCache dependenciesClassLoaderCache,
      final LRUPomModelCache pomModelCache) {
    this.project = project;
    this.ioService = ioService;
    this.projectService = projectService;
    this.importsService = importsService;
    this.buildValidationHelpers = buildValidationHelpers;
    this.packageNameWhiteList = packageNameWhiteList;
    this.projectGAV = project.getPom().getGav();
    this.projectRoot = Paths.convert(project.getRootPath());
    this.projectPrefix = projectRoot.toUri().toString();
    this.kieServices = KieServices.Factory.get();
    this.kieFileSystem = kieServices.newKieFileSystem();
    this.dependenciesClassLoaderCache = dependenciesClassLoaderCache;
    this.pomModelCache = pomModelCache;

    DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream =
        Files.newDirectoryStream(projectRoot);
    visitPaths(directoryStream);
  }
  @Test
  public void testNewProjectCreation() throws URISyntaxException {
    final URI fs = new URI("git://test");
    try {
      FileSystems.getFileSystem(fs);
    } catch (FileSystemNotFoundException e) {
      FileSystems.newFileSystem(fs, new HashMap<String, Object>());
    }

    final Repository repository = mock(Repository.class);
    final String name = "p0";
    final POM pom = new POM();
    final String baseURL = "/";

    final Path repositoryRootPath = mock(Path.class);
    when(repository.getRoot()).thenReturn(repositoryRootPath);
    when(repositoryRootPath.toURI()).thenReturn("git://test");

    pom.getGav().setGroupId("org.kie.workbench.services");
    pom.getGav().setArtifactId("kie-wb-common-services-test");
    pom.getGav().setVersion("1.0.0-SNAPSHOT");

    when(pomService.load(any(Path.class))).thenReturn(pom);

    final AbstractProjectService projectServiceSpy = spy(projectService);

    final Project project = projectServiceSpy.newProject(repository, name, pom, baseURL);

    verify(projectServiceSpy, times(1))
        .simpleProjectInstance(any(org.uberfire.java.nio.file.Path.class));

    assertEquals(pom, project.getPom());
  }