@Test
  public void testDeleteProjectObserverBridge() throws URISyntaxException {
    final URI fs = new URI("git://test");
    try {
      FileSystems.getFileSystem(fs);
    } catch (FileSystemNotFoundException e) {
      FileSystems.newFileSystem(fs, new HashMap<String, Object>());
    }

    final Path path = mock(Path.class);
    final org.uberfire.java.nio.file.Path nioPath = mock(org.uberfire.java.nio.file.Path.class);
    when(path.getFileName()).thenReturn("pom.xml");
    when(path.toURI()).thenReturn("git://test/p0/pom.xml");
    when(nioPath.getParent()).thenReturn(nioPath);
    when(nioPath.resolve(any(String.class))).thenReturn(nioPath);
    when(nioPath.toUri()).thenReturn(URI.create("git://test/p0/pom.xml"));
    when(nioPath.getFileSystem()).thenReturn(FileSystems.getFileSystem(fs));
    when(ioService.get(any(URI.class))).thenReturn(nioPath);

    final SessionInfo sessionInfo = mock(SessionInfo.class);
    final Event<DeleteProjectEvent> deleteProjectEvent = mock(Event.class);
    final AbstractProjectService projectServiceSpy = spy(projectService);

    final DeleteProjectObserverBridge bridge =
        new DeleteProjectObserverBridge(ioService, projectServiceSpy, deleteProjectEvent);

    bridge.onBatchResourceChanges(new ResourceDeletedEvent(path, "message", sessionInfo));

    verify(deleteProjectEvent, times(1)).fire(any(DeleteProjectEvent.class));

    verify(projectServiceSpy, times(0))
        .newProject(any(Repository.class), any(String.class), any(POM.class), any(String.class));
    verify(projectServiceSpy, times(1))
        .simpleProjectInstance(any(org.uberfire.java.nio.file.Path.class));
  }
Пример #2
0
 @WorkbenchPartTitle
 public String getTitle() {
   if (isReadOnly) {
     return "Read Only Fact Models Viewer [" + path.getFileName() + "]";
   }
   return "Fact Models Editor [" + path.getFileName() + "]";
 }
Пример #3
0
 @WorkbenchPartTitle
 public String getTitle() {
   if (isReadOnly) {
     return GlobalsEditorConstants.INSTANCE.globalsEditorReadOnlyTitle0(path.getFileName());
   }
   return GlobalsEditorConstants.INSTANCE.globalsEditorTitle0(path.getFileName());
 }
Пример #4
0
  private Overview loadOverview(final Path path) {
    final Overview overview = new Overview();

    try {
      // Some older versions in our example do not have metadata. This should be impossible in any
      // kie-wb version
      overview.setMetadata(metadataService.getMetadata(path));
    } catch (Exception e) {
      logger.warn(
          "No metadata found for file: "
              + path.getFileName()
              + ", full path ["
              + path.toString()
              + "]");
    }

    // Some resources are not within a Project (e.g. categories.xml) so don't assume we can set the
    // project name
    final KieProject project = projectService.resolveProject(path);
    if (project == null) {
      logger.info(
          "File: "
              + path.getFileName()
              + ", full path ["
              + path.toString()
              + "] was not within a Project. Project Name cannot be set.");
    } else {
      overview.setProjectName(project.getProjectName());
    }

    return overview;
  }
  @Override
  public void create(
      final Package pkg, final String baseFileName, final NewResourcePresenter presenter) {
    busyIndicatorView.showBusyIndicator(DecisionTableXLSEditorConstants.INSTANCE.Uploading());

    final Path path = pkg.getPackageMainResourcesPath();
    final String fileName = buildFileName(baseFileName, fileExtensionSelector.getResourceType());
    // Package Path is already encoded, fileName needs to be encoded
    final Path newPath =
        PathFactory.newPathBasedOn(fileName, path.toURI() + "/" + encode(fileName), path);

    uploadWidget.submit(
        path,
        fileName,
        URLHelper.getServletUrl(),
        new Command() {

          @Override
          public void execute() {
            busyIndicatorView.hideBusyIndicator();
            presenter.complete();
            notifySuccess();
            placeManager.goTo(newPath);
          }
        },
        new Command() {

          @Override
          public void execute() {
            busyIndicatorView.hideBusyIndicator();
          }
        });
  }
  @Override
  public void create(
      final Package pkg, final String baseFileName, final NewResourcePresenter presenter) {
    busyIndicatorView.showBusyIndicator(ScoreCardXLSEditorConstants.INSTANCE.Uploading());

    final Path path = pkg.getPackageMainResourcesPath();
    final String fileName = buildFileName(resourceType, baseFileName);
    final Path newPath =
        PathFactory.newPath(
            path.getFileSystem(), fileName, URL.encode(path.toURI() + "/" + fileName));

    uploadWidget.submit(
        path,
        fileName,
        URLHelper.getServletUrl(),
        new Command() {

          @Override
          public void execute() {
            busyIndicatorView.hideBusyIndicator();
            presenter.complete();
            notifySuccess();
            final PlaceRequest place = new PathPlaceRequest(newPath);
            placeManager.goTo(place);
          }
        },
        new Command() {

          @Override
          public void execute() {
            busyIndicatorView.hideBusyIndicator();
          }
        });
  }
 @Override
 public int hashCode() {
   int result = pom != null ? pom.hashCode() : 0;
   result = 31 * result + (KModule != null ? KModule.hashCode() : 0);
   result = ~~result;
   result = 31 * result + (POMMetaData != null ? POMMetaData.hashCode() : 0);
   result = ~~result;
   result = 31 * result + (KModuleMetaData != null ? KModuleMetaData.hashCode() : 0);
   result = ~~result;
   result = 31 * result + (projectImports != null ? projectImports.hashCode() : 0);
   result = ~~result;
   result = 31 * result + (projectImportsMetaData != null ? projectImportsMetaData.hashCode() : 0);
   result = ~~result;
   result = 31 * result + (projectTagsMetaData != null ? projectTagsMetaData.hashCode() : 0);
   result = ~~result;
   result = 31 * result + (pathToPOM != null ? pathToPOM.hashCode() : 0);
   result = ~~result;
   result = 31 * result + (pathToKModule != null ? pathToKModule.hashCode() : 0);
   result = ~~result;
   result = 31 * result + (pathToImports != null ? pathToImports.hashCode() : 0);
   result = ~~result;
   result = 31 * result + (pathToWhiteList != null ? pathToWhiteList.hashCode() : 0);
   result = ~~result;
   result = 31 * result + (whiteList != null ? whiteList.hashCode() : 0);
   result = ~~result;
   result = 31 * result + (whiteListMetaData != null ? whiteListMetaData.hashCode() : 0);
   result = ~~result;
   return result;
 }
  @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());
  }
  private String getFormDirUri(Path formPath) {
    String fileName = formPath.getFileName();
    try {
      fileName = URIUtil.encodeQuery(fileName);
    } catch (Exception e) {

    }
    return formPath.toURI().substring(0, formPath.toURI().lastIndexOf(fileName) - 1);
  }
Пример #10
0
  public Project simpleProjectInstance(final org.uberfire.java.nio.file.Path nioProjectRootPath) {
    final Path projectRootPath = Paths.convert(nioProjectRootPath);

    return new Project(
        projectRootPath,
        Paths.convert(nioProjectRootPath.resolve(POM_PATH)),
        Paths.convert(nioProjectRootPath.resolve(KMODULE_PATH)),
        Paths.convert(nioProjectRootPath.resolve(PROJECT_IMPORTS_PATH)),
        projectRootPath.getFileName());
  }
  @Test
  public void checkLoad() {
    final Path path = mock(Path.class);
    when(path.toURI())
        .thenReturn(
            "default://project/src/main/resources/mypackage/dtable."
                + dtGraphResourceType.getSuffix());

    when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn("");

    final GuidedDecisionTableEditorGraphModel model = service.load(path);

    verify(ioService, times(1)).readAllString(any(org.uberfire.java.nio.file.Path.class));
    assertNotNull(model);
  }
  @Test
  public void testPackageNameWhiteList() throws URISyntaxException {
    final URI fs = new URI("git://test");
    try {
      FileSystems.getFileSystem(fs);
    } catch (FileSystemNotFoundException e) {
      FileSystems.newFileSystem(fs, new HashMap<String, Object>());
    }

    final Map<String, String> writes = new HashMap<String, String>();

    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");

    when(ioService.write(any(org.uberfire.java.nio.file.Path.class), anyString()))
        .thenAnswer(
            new Answer<Object>() {
              @Override
              public Object answer(final InvocationOnMock invocation) throws Throwable {
                if (invocation.getArguments().length == 2) {
                  final String path =
                      ((org.uberfire.java.nio.file.Path) invocation.getArguments()[0])
                          .toUri()
                          .getPath();
                  final String content = ((String) invocation.getArguments()[1]);
                  writes.put(path, content);
                }
                return invocation.getArguments()[0];
              }
            });

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

    projectService.newProject(repository, name, pom, baseURL);

    assertTrue(writes.containsKey("/p0/package-names-white-list"));
    assertEquals(
        "org.kie.workbench.services.kie_wb_common_services_test.**",
        writes.get("/p0/package-names-white-list"));
  }
  @Test
  public void checkConstructContent() {
    final Path path = mock(Path.class);
    final Overview overview = mock(Overview.class);
    when(path.toURI())
        .thenReturn(
            "default://project/src/main/resources/mypackage/dtable."
                + dtGraphResourceType.getSuffix());

    final GuidedDecisionTableEditorGraphContent content = service.constructContent(path, overview);

    verify(resourceOpenedEvent, times(1)).fire(any(ResourceOpenedEvent.class));

    assertNotNull(content.getModel());
    assertEquals(overview, content.getOverview());
  }
  public Path save(final Path resource, final InputStream content, final String comment) {
    log.info("USER:"******" UPDATING asset [" + resource.getFileName() + "]");

    try {
      final org.kie.commons.java.nio.file.Path nioPath = paths.convert(resource);
      final OutputStream outputStream =
          ioService.newOutputStream(nioPath, makeCommentedOption(comment));
      IOUtils.copy(content, outputStream);
      outputStream.flush();
      outputStream.close();

      // Read Path to ensure attributes have been set
      final Path newPath = paths.convert(nioPath);

      // Signal update to interested parties
      resourceUpdatedEvent.fire(new ResourceUpdatedEvent(newPath, sessionInfo));

      return newPath;

    } catch (Exception e) {
      log.error(e.getMessage(), e);
      throw ExceptionUtilities.handleException(e);

    } finally {
      try {
        content.close();
      } catch (IOException e) {
        throw ExceptionUtilities.handleException(e);
      }
    }
  }
Пример #15
0
  @Override
  public void onRename() {
    final String baseFileName = view.getName();
    final String originalFileName = path.getFileName();
    final String extension =
        (originalFileName.lastIndexOf(".") > 0
            ? originalFileName.substring(originalFileName.lastIndexOf("."))
            : "");
    final String fileName = baseFileName + extension;

    validator.validate(
        fileName,
        new ValidatorWithReasonCallback() {
          @Override
          public void onFailure(final String reason) {
            if (ValidationErrorReason.DUPLICATED_NAME.name().equals(reason)) {
              view.handleDuplicatedFileName();
            } else {
              view.handleInvalidFileName();
            }
          }

          @Override
          public void onSuccess() {
            command.execute(new FileNameAndCommitMessage(baseFileName, view.getCheckInComment()));
          }

          @Override
          public void onFailure() {
            view.handleInvalidFileName();
          }
        });
  }
Пример #16
0
    public void addFile(final Path child) {
      checkCleanupLoading();

      // Util.getHeaderSafeHtml( images.file(), child.getFileName() )
      final TreeItem newFile = parent.addItem(TreeItem.Type.ITEM, child.getFileName());
      newFile.setUserObject(child);
    }
Пример #17
0
  public List<ValidationMessage> validate(
      final Path resourcePath,
      final InputStream resource,
      final DirectoryStream.Filter<org.uberfire.java.nio.file.Path>... supportingFileFilters) {

    final Project project = projectService.resolveProject(resourcePath);
    if (project == null) {
      return Collections.emptyList();
    }

    final KieServices kieServices = KieServices.Factory.get();
    final KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
    final String projectPrefix = project.getRootPath().toURI();

    // Add Java Model files
    final org.uberfire.java.nio.file.Path nioProjectRoot = paths.convert(project.getRootPath());
    final DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream =
        Files.newDirectoryStream(nioProjectRoot);
    visitPaths(projectPrefix, kieFileSystem, directoryStream, supportingFileFilters);

    // Add resource to be validated
    final String destinationPath = resourcePath.toURI().substring(projectPrefix.length() + 1);
    final BufferedInputStream bis = new BufferedInputStream(resource);

    kieFileSystem.write(
        destinationPath, KieServices.Factory.get().getResources().newInputStreamResource(bis));

    // Validate
    final KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem);
    final Results kieResults = kieBuilder.buildAll().getResults();
    final List<ValidationMessage> results = convertMessages(kieResults);

    return results;
  }
Пример #18
0
  public Path save(
      final Path resource,
      final InputStream content,
      final String sessionId,
      final String comment) {
    log.info("USER:"******" UPDATING asset [" + resource.getFileName() + "]");

    try {
      final org.uberfire.java.nio.file.Path nioPath = Paths.convert(resource);
      final OutputStream outputStream =
          ioService.newOutputStream(nioPath, makeCommentedOption(sessionId, comment));
      IOUtils.copy(content, outputStream);
      outputStream.flush();
      outputStream.close();

      return resource;

    } catch (Exception e) {
      throw ExceptionUtilities.handleException(e);

    } finally {
      try {
        content.close();
      } catch (IOException e) {
        throw new org.uberfire.java.nio.IOException(e.getMessage());
      }
    }
  }
Пример #19
0
    public void addDirectory(final Path child) {
      checkCleanupLoading();

      // Util.getHeaderSafeHtml( images.openedFolder(), child.getFileName() )
      final TreeItem newDirectory = parent.addItem(TreeItem.Type.FOLDER, child.getFileName());
      newDirectory.addItem(TreeItem.Type.LOADING, LAZY_LOAD);
      newDirectory.setUserObject(child);
    }
Пример #20
0
  @Override
  public void loadContent(final Path path) {
    final NavigatorItem parent =
        new TreeNavigatorItemImpl(new TreeItem(TreeItem.Type.FOLDER, path.getFileName()));
    tree.addItem(((TreeNavigatorItemImpl) parent).parent);

    loadContent(parent, path);
  }
Пример #21
0
 public void onRestore(@Observes RestoreEvent restore) {
   if (path == null || restore == null || restore.getPath() == null) {
     return;
   }
   if (path.equals(restore.getPath())) {
     loadContent();
     notification.fire(new NotificationEvent(CommonConstants.INSTANCE.ItemRestored()));
   }
 }
  @Override
  public Path createProcess(final Path context, final String fileName) {
    final Path path = paths.convert(paths.convert(context).resolve(fileName), false);

    String location = paths.convert(path).getParent().toString();
    String name = path.getFileName();
    String processId = buildProcessId(location, name);

    String processContent = PROCESS_STUB.replaceAll("\\$\\{processid\\}", processId);

    AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(name);
    builder.location(location).content(processContent).uniqueId(path.toURI());
    Asset<String> processAsset = builder.getAsset();

    repository.createAsset(processAsset);

    return path;
  }
  // Refresh when a batch Resource change has occurred. Simply refresh everything.
  public void onBatchResourceChanges(
      @Observes final ResourceBatchChangesEvent resourceBatchChangesEvent) {
    if (!getView().isVisible()) {
      return;
    }

    boolean projectChange = false;
    for (final Path path : resourceBatchChangesEvent.getBatch().keySet()) {
      if (path.getFileName().equals("pom.xml")) {
        projectChange = true;
        break;
      }
    }

    if (!projectChange) {
      refresh(false);
    }
  }
Пример #24
0
 @Override
 public int hashCode() {
   int result = root.hashCode();
   result = 31 * result + name.hashCode();
   result = ~~result;
   result = 31 * result + (description != null ? description.hashCode() : 0);
   result = ~~result;
   return result;
 }
Пример #25
0
 private void openDataObject(final DataObject dataObject) {
   final Path objectPath = getContext().getDataObjectPath(dataObject.getClassName());
   if (objectPath != null) {
     BusyPopup.showMessage(
         org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants.INSTANCE
             .Loading());
     modelerService
         .call(
             new RemoteCallback<Boolean>() {
               @Override
               public void callback(Boolean exists) {
                 BusyPopup.close();
                 if (Boolean.TRUE.equals(exists)) {
                   placeManager.goTo(new PathPlaceRequest(objectPath));
                 } else {
                   YesNoCancelPopup yesNoCancelPopup =
                       YesNoCancelPopup.newYesNoCancelPopup(
                           CommonConstants.INSTANCE.Warning(),
                           Constants.INSTANCE.objectBrowser_message_file_not_exists_or_renamed(
                               objectPath.toURI()),
                           new Command() {
                             @Override
                             public void execute() {
                               // do nothing.
                             }
                           },
                           CommonConstants.INSTANCE.Close(),
                           ButtonType.WARNING,
                           null,
                           null,
                           null,
                           null,
                           null,
                           null);
                   yesNoCancelPopup.setClosable(false);
                   yesNoCancelPopup.show();
                 }
               }
             },
             new DataModelerErrorCallback(
                 CommonConstants.INSTANCE.ExceptionNoSuchFile0(objectPath.toURI())))
         .exists(objectPath);
   }
 }
Пример #26
0
  private Package makePackage(final Project project, final Path resource) {
    final Path projectRoot = project.getRootPath();
    final org.uberfire.java.nio.file.Path nioProjectRoot = Paths.convert(projectRoot);
    final org.uberfire.java.nio.file.Path nioMainSrcPath = nioProjectRoot.resolve(MAIN_SRC_PATH);
    final org.uberfire.java.nio.file.Path nioTestSrcPath = nioProjectRoot.resolve(TEST_SRC_PATH);
    final org.uberfire.java.nio.file.Path nioMainResourcesPath =
        nioProjectRoot.resolve(MAIN_RESOURCES_PATH);
    final org.uberfire.java.nio.file.Path nioTestResourcesPath =
        nioProjectRoot.resolve(TEST_RESOURCES_PATH);

    org.uberfire.java.nio.file.Path nioResource = Paths.convert(resource);

    if (Files.isRegularFile(nioResource)) {
      nioResource = nioResource.getParent();
    }

    String packageName = null;
    org.uberfire.java.nio.file.Path packagePath = null;
    if (nioResource.startsWith(nioMainSrcPath)) {
      packagePath = nioMainSrcPath.relativize(nioResource);
      packageName = packagePath.toString().replaceAll("/", ".");
    } else if (nioResource.startsWith(nioTestSrcPath)) {
      packagePath = nioTestSrcPath.relativize(nioResource);
      packageName = packagePath.toString().replaceAll("/", ".");
    } else if (nioResource.startsWith(nioMainResourcesPath)) {
      packagePath = nioMainResourcesPath.relativize(nioResource);
      packageName = packagePath.toString().replaceAll("/", ".");
    } else if (nioResource.startsWith(nioTestResourcesPath)) {
      packagePath = nioTestResourcesPath.relativize(nioResource);
      packageName = packagePath.toString().replaceAll("/", ".");
    }

    // Resource was not inside a package
    if (packageName == null) {
      return null;
    }

    final Path mainSrcPath = Paths.convert(nioMainSrcPath.resolve(packagePath));
    final Path testSrcPath = Paths.convert(nioTestSrcPath.resolve(packagePath));
    final Path mainResourcesPath = Paths.convert(nioMainResourcesPath.resolve(packagePath));
    final Path testResourcesPath = Paths.convert(nioTestResourcesPath.resolve(packagePath));

    final String displayName = getPackageDisplayName(packageName);

    final Package pkg =
        new Package(
            project.getRootPath(),
            mainSrcPath,
            testSrcPath,
            mainResourcesPath,
            testResourcesPath,
            packageName,
            displayName,
            getPackageRelativeCaption(displayName, resource.getFileName()));
    return pkg;
  }
  @Override
  public Map<String, String> getEditorParameters(
      final Path path, final String editorID, String hostInfo, PlaceRequest place) {
    List<String> activeNodesList = new ArrayList<String>();
    String activeNodesParam = place.getParameter("activeNodes", null);

    String readOnly = place.getParameter("readOnly", "false");
    String encodedProcessSource = place.getParameter("encodedProcessSource", "");

    if (activeNodesParam != null) {
      activeNodesList = Arrays.asList(activeNodesParam.split(","));
    }

    List<String> completedNodesList = new ArrayList<String>();
    String completedNodesParam = place.getParameter("completedNodes", null);

    if (completedNodesParam != null) {
      completedNodesList = Arrays.asList(completedNodesParam.split(","));
    }

    JSONArray activeNodesArray = new JSONArray(activeNodesList);
    String encodedActiveNodesParam;
    try {
      encodedActiveNodesParam =
          Base64.encodeBase64URLSafeString(activeNodesArray.toString().getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
      encodedActiveNodesParam = "";
    }

    JSONArray completedNodesArray = new JSONArray(completedNodesList);
    String encodedCompletedNodesParam;
    try {
      encodedCompletedNodesParam =
          Base64.encodeBase64URLSafeString(completedNodesArray.toString().getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
      encodedCompletedNodesParam = "";
    }

    Map<String, String> editorParamsMap = new HashMap<String, String>();
    editorParamsMap.put("hostinfo", hostInfo);
    editorParamsMap.put("uuid", path.toURI());
    editorParamsMap.put("profile", "jbpm");
    editorParamsMap.put("pp", "");
    editorParamsMap.put("editorid", editorID);
    editorParamsMap.put("readonly", readOnly);
    editorParamsMap.put("activenodes", encodedActiveNodesParam);
    editorParamsMap.put("completednodes", encodedCompletedNodesParam);
    editorParamsMap.put("processsource", encodedProcessSource);

    return editorParamsMap;
    //        String editorURL = hostInfo + "/editor/?uuid=" + path.toURI() +
    // "&profile=jbpm&pp=&editorid=" + editorID + "&readonly=" + readOnly +
    //                "&activenodes=" + encodedActiveNodesParam + "&completednodes=" +
    // encodedCompletedNodesParam;
    //        return getEditorResponse( editorURL, encodedProcessSource );
  }
Пример #28
0
 @Override
 public int hashCode() {
   int result = environment.hashCode();
   result = 31 * result + (publicURIs.hashCode());
   result = 31 * result + (alias != null ? alias.hashCode() : 0);
   result = 31 * result + (root != null ? root.hashCode() : 0);
   result = 31 * result + (roles != null ? roles.hashCode() : 0);
   result = 31 * result + (branches != null ? branches.hashCode() : 0);
   result = 31 * result + (currentBranch != null ? currentBranch.hashCode() : 0);
   return result;
 }
Пример #29
0
 protected ConfigGroup findProjectConfig(final Path projectRoot) {
   final Collection<ConfigGroup> groups =
       configurationService.getConfiguration(ConfigType.PROJECT);
   if (groups != null) {
     for (ConfigGroup groupConfig : groups) {
       if (groupConfig.getName().equals(projectRoot.toURI())) {
         return groupConfig;
       }
     }
   }
   return null;
 }
  @Test
  public void testListDecisionTablesInPackage() {
    final Path path = mock(Path.class);
    when(path.toURI()).thenReturn("default://project/src/main/resources/dtable1.gdst");

    resolvedPaths.add(makeNioPath("default://project/src/main/resources/dtable1.gdst"));
    resolvedPaths.add(makeNioPath("default://project/src/main/resources/dtable2.gdst"));
    resolvedPaths.add(makeNioPath("default://project/src/main/resources/dtable3.gdst"));
    resolvedPaths.add(makeNioPath("default://project/src/main/resources/pupa.smurf"));

    final List<Path> paths = service.listDecisionTablesInPackage(path);

    assertNotNull(paths);
    assertEquals(3, paths.size());
    final Set<String> fileNames = new HashSet<>();
    fileNames.addAll(
        paths.stream().collect(Collectors.mapping(Path::getFileName, Collectors.toSet())));
    assertTrue(fileNames.contains("dtable1.gdst"));
    assertTrue(fileNames.contains("dtable2.gdst"));
    assertTrue(fileNames.contains("dtable3.gdst"));
  }