use of org.uberfire.java.nio.fs.file.SimpleFileSystemProvider in project kie-wb-common by kiegroup.
the class BuilderTest method testBuilderKModuleHasDependency.
@Test
public void testBuilderKModuleHasDependency() throws Exception {
URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample2");
SimpleFileSystemProvider p = new SimpleFileSystemProvider();
org.uberfire.java.nio.file.Path path = p.getPath(url.toURI());
final Module module = moduleService.resolveModule(Paths.convert(path));
final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue);
final BuildResults results = builder.build();
// Debug output
if (!results.getMessages().isEmpty()) {
for (BuildMessage m : results.getMessages()) {
logger.debug(m.getText());
}
}
assertTrue(results.getMessages().isEmpty());
}
use of org.uberfire.java.nio.fs.file.SimpleFileSystemProvider in project kie-wb-common by kiegroup.
the class BuilderTest method testBuilderKModuleHasDependencyMetaData.
@Test
public void testBuilderKModuleHasDependencyMetaData() throws Exception {
URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample2");
SimpleFileSystemProvider p = new SimpleFileSystemProvider();
org.uberfire.java.nio.file.Path path = p.getPath(url.toURI());
final Module module = moduleService.resolveModule(Paths.convert(path));
final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue);
final BuildResults results = builder.build();
// Debug output
if (!results.getMessages().isEmpty()) {
for (BuildMessage m : results.getMessages()) {
logger.debug(m.getText());
}
}
assertTrue(results.getMessages().isEmpty());
final KieModuleMetaData metaData = KieModuleMetaData.Factory.newKieModuleMetaData(builder.getKieModule());
// Check packages
final Set<String> packageNames = new HashSet<>();
final Iterator<String> packageNameIterator = metaData.getPackages().iterator();
while (packageNameIterator.hasNext()) {
packageNames.add(packageNameIterator.next());
}
assertEquals(2, packageNames.size());
assertTrue(packageNames.contains("defaultpkg"));
assertTrue(packageNames.contains("org.kie.workbench.common.services.builder.tests.test1"));
// Check classes
final String packageName = "org.kie.workbench.common.services.builder.tests.test1";
assertEquals(1, metaData.getClasses(packageName).size());
final String className = metaData.getClasses(packageName).iterator().next();
assertEquals("Bean", className);
// Check metadata
final Class clazz = metaData.getClass(packageName, className);
final TypeMetaInfo typeMetaInfo = metaData.getTypeMetaInfo(clazz);
assertNotNull(typeMetaInfo);
assertFalse(typeMetaInfo.isEvent());
}
use of org.uberfire.java.nio.fs.file.SimpleFileSystemProvider in project kie-wb-common by kiegroup.
the class BuilderTest method testKModuleContainsXLS.
@Test
public void testKModuleContainsXLS() throws Exception {
URL url = this.getClass().getResource("/ExampleWithExcel");
SimpleFileSystemProvider p = new SimpleFileSystemProvider();
org.uberfire.java.nio.file.Path path = p.getPath(url.toURI());
final Module module = moduleService.resolveModule(Paths.convert(path));
final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue);
final BuildResults results = builder.build();
// Debug output
if (!results.getMessages().isEmpty()) {
for (BuildMessage m : results.getMessages()) {
logger.debug(m.getText());
}
}
assertTrue(results.getMessages().isEmpty());
}
use of org.uberfire.java.nio.fs.file.SimpleFileSystemProvider in project kie-wb-common by kiegroup.
the class ModuleSaverTest method setUp.
@Before
public void setUp() throws Exception {
fs = new SimpleFileSystemProvider();
super.startWeld();
// Instantiate Paths used in tests for Path conversion
final Bean pathsBean = (Bean) beanManager.getBeans(Paths.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(pathsBean);
paths = (Paths) beanManager.getReference(pathsBean, Paths.class, cc);
// Ensure URLs use the default:// scheme
fs.forceAsDefault();
final Event<NewModuleEvent> newModuleEvent = mock(Event.class);
when(ioService.createDirectory(any(org.uberfire.java.nio.file.Path.class))).thenAnswer(new Answer<Object>() {
@Override
public Object answer(final InvocationOnMock invocation) throws Throwable {
return invocation.getArguments()[0];
}
});
doCallRealMethod().when(resourceResolver).getDefaultWorkspacePath(any());
doCallRealMethod().when(resourceResolver).getLegalId(any());
saver = new ModuleSaver(ioService, pomService, mock(KModuleService.class), newModuleEvent, newPackageEvent, resourceResolver, mock(ProjectImportsService.class), mock(ModuleRepositoriesService.class), mock(PackageNameWhiteListService.class), mock(CommentedOptionFactory.class), new SessionInfo() {
@Override
public String getId() {
return "session";
}
@Override
public User getIdentity() {
return new UserImpl("testuser");
}
});
}
use of org.uberfire.java.nio.fs.file.SimpleFileSystemProvider in project kie-wb-common by kiegroup.
the class KieServiceTest method setUp.
@Before
public void setUp() throws Exception {
fileSystemProvider = new SimpleFileSystemProvider();
// Ensure URLs use the default:// scheme
fileSystemProvider.forceAsDefault();
mainFilePath = fileSystemProvider.getPath(this.getClass().getResource("mymodel.model").toURI());
dotFilePath = fileSystemProvider.getPath(this.getClass().getResource(".mymodel.model").toURI());
orphanDotFilePath = fileSystemProvider.getPath(this.getClass().getResource(".mymodel").toURI());
kieService = spy(new KieService<TestModel>() {
{
IOService mockIOService = mock(IOService.class);
when(mockIOService.exists(mainFilePath)).thenReturn(true);
when(mockIOService.exists(dotFilePath)).thenReturn(false);
this.logger = mock(Logger.class);
this.pathResolver = new PathResolverMock();
this.ioService = mockIOService;
this.moduleService = mock(KieModuleService.class);
this.projectService = mock(WorkspaceProjectService.class);
this.metadataService = KieServiceTest.this.metadataService;
}
@Override
protected TestModel constructContent(Path path, Overview overview) {
if (path.getFileName().toString().equals(mainFilePath.getFileName().toString())) {
return new TestModel(overview);
} else if (path.getFileName().toString().equals(orphanDotFilePath.getFileName().toString())) {
return new TestModel(overview);
} else {
return null;
}
}
});
}
Aggregations