@Test public void testUnresolvedCatalogItemParameters() { // Insert template which is not instantiatable during catalog addition due to // missing dependencies, but the spec can be created (the // dependencies are already parsed). addCatalogItems( "brooklyn.catalog:", " version: " + TEST_VERSION, " items:", " - id: " + SYMBOLIC_NAME, " itemType: template", " item:", " services:", " - type: basic-app", " - id: basic-app", " itemType: entity", " item:", " type: " + ConfigAppForTest.class.getName()); EntitySpec<? extends Application> spec = createAppSpec("services:", "- type: " + ver(SYMBOLIC_NAME)); List<SpecParameter<?>> params = spec.getParameters(); assertEquals( params.size(), 4, "Wrong number of params: " + params); // sample + defaultDisplayName + destroy_on_stop + start.latch assertEquals( ImmutableSet.copyOf(params), ImmutableSet.copyOf(BasicSpecParameter.fromClass(mgmt(), ConfigAppForTest.class))); }
@Test public void testAppServiceParameters() throws Exception { EntitySpec<? extends Application> spec = createAppSpec( "services:", "- type: " + BasicApplication.class.getName(), " brooklyn.parameters:", " - simple"); List<SpecParameter<?>> inputs = spec.getParameters(); assertEquals(inputs.size(), 4); SpecParameter<?> firstInput = inputs.get(0); assertEquals(firstInput.getLabel(), "simple"); }
@Test public void testAppSpecInheritsCatalogRootParameters() { addCatalogItems( "brooklyn.catalog:", " id: " + SYMBOLIC_NAME, " version: " + TEST_VERSION, " itemType: entity", " item:", " type: " + BasicApplication.class.getName(), " brooklyn.parameters:", " - simple"); EntitySpec<? extends Application> spec = createAppSpec("services:", "- type: " + ver(SYMBOLIC_NAME)); List<SpecParameter<?>> params = spec.getParameters(); assertEquals(params.size(), 4); assertTrue(Iterables.tryFind(params, nameEqualTo("simple")).isPresent()); assertTrue(Iterables.tryFind(params, labelEqualTo("simple")).isPresent()); }
@Test public void testChildEntitiyHasParameters() { addCatalogItems( "brooklyn.catalog:", " id: " + SYMBOLIC_NAME, " version: " + TEST_VERSION, " itemType: entity", " item:", " type: " + ConfigEntityForTest.class.getName(), " brooklyn.children:", " - type: " + ConfigEntityForTest.class.getName(), " brooklyn.parameters:", " - simple"); CatalogItem<?, ?> item = catalog.getCatalogItem(SYMBOLIC_NAME, TEST_VERSION); @SuppressWarnings({"rawtypes", "unchecked"}) EntitySpec<?> parentSpec = (EntitySpec<?>) catalog.createSpec((CatalogItem) item); EntitySpec<?> spec = parentSpec.getChildren().get(0); List<SpecParameter<?>> params = spec.getParameters(); assertEquals(params.size(), 3); assertTrue(Iterables.tryFind(params, nameEqualTo("simple")).isPresent()); assertTrue(Iterables.tryFind(params, labelEqualTo("simple")).isPresent()); }