@Test public void testAppServiceParameters() throws Exception { EntitySpec<? extends Application> spec = createAppSpec( "services:", "- type: " + BasicApplication.class.getName(), " brooklyn.parameters:", " - simple"); final int NUM_CONFIG_KEYS_FROM_TEST_BLUEPRINT = 1; List<SpecParameter<?>> params = spec.getParameters(); assertEquals(params.size(), NUM_APP_DEFAULT_CONFIG_KEYS + NUM_CONFIG_KEYS_FROM_TEST_BLUEPRINT, "params="+params); SpecParameter<?> firstInput = params.get(0); assertEquals(firstInput.getLabel(), "simple"); }
@Test public void testAppRootParameters() throws Exception { EntitySpec<? extends Application> spec = createAppSpec( "brooklyn.parameters:", "- simple", "services:", "- type: " + BasicApplication.class.getName()); final int NUM_CONFIG_KEYS_FROM_TEST_BLUEPRINT = 1; List<SpecParameter<?>> params = spec.getParameters(); assertEquals(params.size(), NUM_APP_DEFAULT_CONFIG_KEYS + NUM_CONFIG_KEYS_FROM_TEST_BLUEPRINT, "params="+params); SpecParameter<?> firstInput = params.get(0); assertEquals(firstInput.getLabel(), "simple"); }
@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"); EntitySpec<?> parentSpec = (EntitySpec<?>) peekSpec(); EntitySpec<?> spec = parentSpec.getChildren().get(0); List<SpecParameter<?>> params = spec.getParameters(); assertEquals(params.size(), NUM_ENTITY_DEFAULT_CONFIG_KEYS + 2, "params="+params); assertTrue(Iterables.tryFind(params, nameEqualTo("simple")).isPresent()); assertTrue(Iterables.tryFind(params, labelEqualTo("simple")).isPresent()); }
@Test public void testAppSpecInheritsCatalogRootParametersWithServices() { addCatalogItems( "brooklyn.catalog:", " id: " + SYMBOLIC_NAME, " version: " + TEST_VERSION, " itemType: entity", " item:", " brooklyn.parameters:", " - simple", " services:", " - type: " + BasicApplication.class.getName()); final int NUM_CONFIG_KEYS_FROM_TEST_BLUEPRINT = 1; EntitySpec<? extends Application> spec = createAppSpec( "services:", "- type: " + ver(SYMBOLIC_NAME)); List<SpecParameter<?>> params = spec.getParameters(); assertEquals(params.size(), NUM_APP_DEFAULT_CONFIG_KEYS + NUM_CONFIG_KEYS_FROM_TEST_BLUEPRINT, "params="+params); assertTrue(Iterables.tryFind(params, nameEqualTo("simple")).isPresent()); assertTrue(Iterables.tryFind(params, labelEqualTo("simple")).isPresent()); }
@Test public void testAppSpecInheritsCatalogParameters() { addCatalogItems( "brooklyn.catalog:", " version: " + TEST_VERSION, " id: " + SYMBOLIC_NAME, " itemType: entity", " item:", " type: " + BasicApplication.class.getName(), " brooklyn.parameters:", " - simple"); final int NUM_CONFIG_KEYS_FROM_TEST_BLUEPRINT = 1; EntitySpec<? extends Application> spec = createAppSpec( "services:", "- type: " + ver(SYMBOLIC_NAME)); List<SpecParameter<?>> params = spec.getParameters(); assertEquals(params.size(), NUM_APP_DEFAULT_CONFIG_KEYS + NUM_CONFIG_KEYS_FROM_TEST_BLUEPRINT, "params="+params); assertTrue(Iterables.tryFind(params, nameEqualTo("simple")).isPresent()); assertTrue(Iterables.tryFind(params, labelEqualTo("simple")).isPresent()); }
@Test public void testAppSpecInheritsCatalogRootParameters() { addCatalogItems( "brooklyn.catalog:", " id: " + SYMBOLIC_NAME, " version: " + TEST_VERSION, " itemType: entity", " item:", " type: " + BasicApplication.class.getName(), " brooklyn.parameters:", " - simple"); final int NUM_CONFIG_KEYS_FROM_TEST_BLUEPRINT = 1; EntitySpec<? extends Application> spec = createAppSpec( "services:", "- type: " + ver(SYMBOLIC_NAME)); List<SpecParameter<?>> params = spec.getParameters(); assertEquals(params.size(), NUM_APP_DEFAULT_CONFIG_KEYS + NUM_CONFIG_KEYS_FROM_TEST_BLUEPRINT, "params="+params); assertTrue(Iterables.tryFind(params, nameEqualTo("simple")).isPresent()); assertTrue(Iterables.tryFind(params, labelEqualTo("simple")).isPresent()); }
@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(), NUM_APP_DEFAULT_CONFIG_KEYS + ConfigAppForTest.NUM_CONFIG_KEYS_DEFINED_HERE, "params="+params); assertEquals(ImmutableSet.copyOf(params), ImmutableSet.copyOf(BasicSpecParameter.fromClass(mgmt(), ConfigAppForTest.class))); }
wrappedChild.locations(wrapperParent.getLocations()); if (!wrapperParent.getParameters().isEmpty()) { wrappedChild.parametersAdd(wrapperParent.getParameters());
for (SpecParameter<?> input: spec.getParameters()) config.add(EntityTransformer.entityConfigSummary(input, paramPriorityCnt)); for (Sensor<?> x: type.getSensors())
for (SpecParameter<?> input: spec.getParameters()) config.add(EntityTransformer.entityConfigSummary(input, paramPriorityCnt)); for (Sensor<?> x: type.getSensors())
private void addSpecParameters(EntitySpec<?> spec, EntityDynamicType edType) { // if coming from a catalog item, parsed by CAMP, then the spec list of parameters is canonical, // the parent item has had its config keys set as parameters here with those non-inheritable // via type definition removed, so wipe those on the EDT to make sure non-inheritable ones are removed; // OTOH if item is blank, it was set as a java type, not inheriting it, // and the config keys on the dynamic type are the correct ones to use, and usually there is nothing in spec.parameters, // except what is being added programmatically. // (this logic could get confused if catalog item ID referred to some runtime-inherited context, // but those semantics should no longer be used -- https://issues.apache.org/jira/browse/BROOKLYN-445) if (Strings.isNonBlank(spec.getCatalogItemId())) { edType.clearConfigKeys(); } for (SpecParameter<?> param : spec.getParameters()) { edType.addConfigKey(param.getConfigKey()); if (param.getSensor()!=null) edType.addSensor(param.getSensor()); } }
" pinned: false"); EntitySpec<?> item = mgmt().getTypeRegistry().createSpec(mgmt().getTypeRegistry().get(itemId), null, EntitySpec.class); List<SpecParameter<?>> inputs = item.getParameters(); assertEquals(inputs.size(), NUM_APP_DEFAULT_CONFIG_KEYS + 3, "inputs="+inputs); SpecParameter<?> firstInput = inputs.get(0);