CaseProjectServiceImpl implements CaseProjectService { public void configurePackage(@Observes NewPackageEvent pkg) { if (isCaseProject(Paths.convert(pkg.getPackage().getModuleRootPath()))) { String resourcesPathStr = Paths.convert(pkg.getPackage().getPackageMainResourcesPath()).toUri().toString(); String separator = Paths.convert(pkg.getPackage().getModuleRootPath()).getFileSystem().getSeparator(); Path resourcesPath = ioService.get(URI.create(resourcesPathStr + separator + WORK_DEFINITION_FILE)); addWorkDefinitions(resourcesPath); } } CaseProjectServiceImpl(); @Inject  CaseProjectServiceImpl(DDEditorService ddEditorService,
                                  @Named("ioStrategy") IOService ioService); @Override void configureNewCaseProject(WorkspaceProject project); void addWorkDefinitionsFileToProjectResources(KieModule kieModule, WorkspaceProject project, String separator); void configurePackage(@Observes NewPackageEvent pkg);  }
@Test public void testConfigureNewPackage() { Path packagePath = Mockito.mock(Path.class); when(packagePath.toUri()).thenReturn(URI.create("default: DirectoryStream directoryStream = Mockito.mock(DirectoryStream.class); when(ioService.newDirectoryStream(any(), any())).thenReturn((DirectoryStream<Path>) directoryStream); when(directoryStream.iterator()).thenReturn(Arrays.asList(packagePath).iterator()); org.guvnor.common.services.project.model.Package pkg = Mockito.mock(org.guvnor.common.services.project.model.Package.class); when(pkg.getModuleRootPath()).thenReturn(projectPath); when(pkg.getPackageMainResourcesPath()).thenReturn(projectPath); NewPackageEvent event = new NewPackageEvent(pkg); caseProjectService.configurePackage(event); verify(ioService, times(1)).write(any(), any(byte[].class)); }