@Before public void setUp() { projectFactory = SimpleContainer.getServices(getClass().getClassLoader(), ProjectFactory.class).get(); configurator = SimpleContainer.getServices(getClass().getClassLoader(), AddonProjectConfigurator.class) .get(); furnace = SimpleContainer.getFurnace(getClass().getClassLoader()); }
@Override public Result execute(UIExecutionContext context) throws Exception { UIContext uiContext = context.getUIContext(); Project project = (Project) uiContext.getAttributeMap().get(Project.class); String coordinate = archetypeGroupId.getValue() + ":" + archetypeArtifactId.getValue() + ":" + archetypeVersion.getValue(); DependencyQueryBuilder depQuery = DependencyQueryBuilder.create(coordinate); String repository = archetypeRepository.getValue(); if (repository != null) { depQuery.setRepositories(new DependencyRepository("archetype", repository)); } DependencyResolver resolver = SimpleContainer.getServices(getClass().getClassLoader(), DependencyResolver.class).get(); Dependency resolvedArtifact = resolver.resolveArtifact(depQuery); FileResource<?> artifact = resolvedArtifact.getArtifact(); MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class); File fileRoot = project.getRoot().reify(DirectoryResource.class).getUnderlyingResourceObject(); ArchetypeHelper archetypeHelper = new ArchetypeHelper( artifact.getResourceInputStream(), fileRoot, metadataFacet.getProjectGroupName(), metadataFacet.getProjectName(), metadataFacet.getProjectVersion()); JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); archetypeHelper.setPackageName(facet.getBasePackage()); archetypeHelper.execute(); return Results.success(); }
@Test public void testNameLookupReturnsAllMatches() throws Exception { AddonRegistry registry = SimpleContainer.getFurnace(this.getClass().getClassLoader()).getAddonRegistry(); Imported<PublishedService> instance = registry.getServices(PublishedService.class.getName()); Assert.assertTrue(instance.isAmbiguous()); Assert.assertFalse(instance.isUnsatisfied()); Assert.assertNotNull(instance); Iterator<PublishedService> iterator = instance.iterator(); Assert.assertTrue(iterator.hasNext()); Object first = iterator.next(); Assert.assertNotNull(first); Assert.assertTrue(iterator.hasNext()); Assert.assertTrue(iterator.hasNext()); Object second = iterator.next(); Assert.assertNotNull(second); Assert.assertFalse(iterator.hasNext()); boolean typeMatchFound = false; if (first instanceof PublishedService) typeMatchFound = true; if (second instanceof PublishedService) typeMatchFound = true; Assert.assertTrue(typeMatchFound); }
@Before public void setup() throws Exception { AddonRegistry addonRegistry = SimpleContainer.getFurnace(getClass().getClassLoader()).getAddonRegistry(); this.projectFactory = addonRegistry.getServices(ProjectFactory.class).get(); this.testHarness = addonRegistry.getServices(UITestHarness.class).get(); project = projectFactory.createTempProject(); CommandController gitSetupCommandTester = testHarness.createCommandController(GitSetupCommand.class, project.getRoot()); gitSetupCommandTester.initialize(); gitSetupCommandTester.execute(); CommandController gitIgnoreSetupTester = testHarness.createCommandController(GitIgnoreSetupCommand.class, project.getRoot()); gitIgnoreSetupTester.initialize(); gitIgnoreSetupTester.setValueFor("templateRepoDir", getCloneDir()); gitIgnoreSetupTester.execute(); Resource<?> cloneDir = getCloneDir(); boolean templateFound = false; for (Resource<?> resource : cloneDir.listResources()) { if (resource.getName().endsWith(".gitignore")) { templateFound = true; break; } } assertTrue(templateFound); }
@Test(expected = IllegalStateException.class) public void testGetWhenAmbiguousThrowsException() throws Exception { AddonRegistry registry = SimpleContainer.getFurnace(this.getClass().getClassLoader()).getAddonRegistry(); Imported<PublishedService> instance = registry.getServices(PublishedService.class.getName()); Assert.assertTrue(instance.isAmbiguous()); instance.get(); }
@Test public void testTypedLookupReturnsProperType() throws Exception { AddonRegistry registry = SimpleContainer.getFurnace(this.getClass().getClassLoader()).getAddonRegistry(); Imported<PublishedService> instance = registry.getServices(PublishedService.class); Assert.assertNotNull(instance); PublishedService service = instance.get(); Assert.assertNotNull(service); }
@Test public void testMissingTypedLookupReturnsEmptyInstance() throws Exception { AddonRegistry registry = SimpleContainer.getFurnace(this.getClass().getClassLoader()).getAddonRegistry(); Imported<AddonDependencyEntry> instance = registry.getServices(AddonDependencyEntry.class); Assert.assertNotNull(instance); Assert.assertFalse(instance.isAmbiguous()); Assert.assertTrue(instance.isUnsatisfied()); }
@Test public void testAmbiguousSelect() throws Exception { AddonRegistry registry = SimpleContainer.getFurnace(this.getClass().getClassLoader()).getAddonRegistry(); Imported<PublishedService> instance = registry.getServices(PublishedService.class.getName()); Assert.assertTrue(instance.isAmbiguous()); PublishedService service = instance.selectExact(PublishedService.class); Assert.assertNotNull(service); }
@Test public void testMissingNamedLookupReturnsEmptyInstance() throws Exception { AddonRegistry registry = SimpleContainer.getFurnace(this.getClass().getClassLoader()).getAddonRegistry(); Imported<PublishedService> instance = registry.getServices("org.example.blah.NotExistsBadClassThing"); Assert.assertNotNull(instance); Assert.assertFalse(instance.isAmbiguous()); Assert.assertTrue(instance.isUnsatisfied()); }
@Override public boolean install() { DependencyInstaller installer = SimpleContainer.getServices(getClass().getClassLoader(), DependencyInstaller.class).get(); Dependency dependency = installer.installManaged( getFaceted(), DependencyBuilder.create(FURNACE_BOM_DEPENDENCY) .setVersion(FurnaceVersionFacet.VERSION_PROPERTY)); return dependency != null; }
@Test public void testTypedLookupCanBeIterated() throws Exception { AddonRegistry registry = SimpleContainer.getFurnace(this.getClass().getClassLoader()).getAddonRegistry(); Imported<PublishedService> instance = registry.getServices(PublishedService.class); Assert.assertFalse(instance.isAmbiguous()); Assert.assertFalse(instance.isUnsatisfied()); Iterator<PublishedService> iterator = instance.iterator(); Assert.assertTrue(iterator.hasNext()); Assert.assertNotNull(iterator.next()); Assert.assertFalse(iterator.hasNext()); }
@Override public boolean isInstalled() { DependencyInstaller installer = SimpleContainer.getServices(getClass().getClassLoader(), DependencyInstaller.class).get(); return installer.isManaged(origin, FURNACE_BOM_DEPENDENCY); }
@Before public void setUp() { this.resourceFactory = SimpleContainer.getServices(getClass().getClassLoader(), ResourceFactory.class).get(); }
@Before public void setUp() { projectFactory = SimpleContainer.getServices(getClass().getClassLoader(), ProjectFactory.class).get(); buildSystems = SimpleContainer.getServices(getClass().getClassLoader(), ProjectProvider.class); }
/** @return the config */ private Configuration getConfig() { return SimpleContainer.getServices(getClass().getClassLoader(), Configuration.class).get(); }