Search in sources :

Example 1 with KPropertyImpl

use of org.kie.workbench.common.services.refactoring.KPropertyImpl in project kie-wb-common by kiegroup.

the class GitKeepFileIndexerTest method testTheUsualBuild.

@Test
public void testTheUsualBuild() throws Exception {
    final KieModule kieModule = mock(KieModule.class);
    doReturn(kieModule).when(moduleService).resolveModule(any(Path.class));
    doReturn("Module Name").when(kieModule).getModuleName();
    doReturn(getPathMock("default://main@myRepository/Test")).when(kieModule).getRootPath();
    final Package aPackage = mock(Package.class);
    doReturn("pkgName").when(aPackage).getPackageName();
    doReturn(aPackage).when(moduleService).resolvePackage(any(Path.class));
    final IndexBuilder indexBuilder = indexer.fillIndexBuilder(mainPath);
    final Set<KProperty<?>> properties = indexBuilder.build();
    assertEquals(3, properties.size());
    assertTrue(properties.contains(new KPropertyImpl<>(ModuleRootPathIndexTerm.TERM, "default://main@myRepository/Test")));
    assertTrue(properties.contains(new KPropertyImpl<>(ModuleNameIndexTerm.TERM, "Module Name")));
    assertTrue(properties.contains(new KPropertyImpl<>(PackageNameIndexTerm.TERM, "pkgName")));
}
Also used : Path(org.uberfire.backend.vfs.Path) KPropertyImpl(org.kie.workbench.common.services.refactoring.KPropertyImpl) KProperty(org.uberfire.ext.metadata.model.KProperty) Package(org.guvnor.common.services.project.model.Package) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Example 2 with KPropertyImpl

use of org.kie.workbench.common.services.refactoring.KPropertyImpl in project kie-wb-common by kiegroup.

the class LibraryIndexer method fillIndexBuilder.

@Override
protected IndexBuilder fillIndexBuilder(final Path path) throws Exception {
    // responsible for basic index info: file name, project root path
    final String fileName = Paths.convert(path).getFileName();
    final String repoRoot = getRootBackendPath(path);
    final IndexBuilder builder = () -> {
        final Set<KProperty<?>> indexElements = new HashSet<>();
        indexElements.add(new KPropertyImpl<>(LibraryFileNameIndexTerm.TERM, fileName));
        indexElements.add(new KPropertyImpl<>(FieldFactory.FILE_NAME_FIELD_SORTED, fileName.toLowerCase(), false, true));
        indexElements.add(new KPropertyImpl<>(LibraryRepositoryRootIndexTerm.TERM, repoRoot));
        return indexElements;
    };
    return builder;
}
Also used : KPropertyImpl(org.kie.workbench.common.services.refactoring.KPropertyImpl) HashSet(java.util.HashSet) Set(java.util.Set) IndexBuilder(org.kie.workbench.common.services.refactoring.backend.server.indexing.IndexBuilder)

Aggregations

KPropertyImpl (org.kie.workbench.common.services.refactoring.KPropertyImpl)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Package (org.guvnor.common.services.project.model.Package)1 Test (org.junit.Test)1 IndexBuilder (org.kie.workbench.common.services.refactoring.backend.server.indexing.IndexBuilder)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1 Path (org.uberfire.backend.vfs.Path)1 KProperty (org.uberfire.ext.metadata.model.KProperty)1