Java Code Examples for org.apache.brooklyn.core.internal.BrooklynProperties#getFirst()
The following examples show how to use
org.apache.brooklyn.core.internal.BrooklynProperties#getFirst() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExternalConfigBrooklynPropertiesTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
protected void runExternalisedConfigGetters(BrooklynProperties props, String property, String expectedVal, boolean testSubMap) throws Exception { ExecutionContext exec = mgmt().getServerExecutionContext(); String val1 = props.getConfig(ConfigKeys.newStringConfigKey(property)); assertEquals(val1, expectedVal); DeferredSupplier<?> val2 = (DeferredSupplier<?>) props.getConfigRaw(ConfigKeys.newStringConfigKey(property)).get(); assertEquals(Tasks.resolveValue(val2, String.class, exec), expectedVal); DeferredSupplier<?> val3 = (DeferredSupplier<?>) props.getConfigLocalRaw(ConfigKeys.newStringConfigKey(property)).get(); assertEquals(Tasks.resolveValue(val3, String.class, exec), expectedVal); DeferredSupplier<?> val4 = (DeferredSupplier<?>) props.getAllConfigLocalRaw().get(ConfigKeys.newStringConfigKey(property)); assertEquals(Tasks.resolveValue(val4, String.class, exec), expectedVal); String val5 = props.getFirst(property); assertTrue(val5.startsWith("$brooklyn:external"), "val="+val5); if (testSubMap) { BrooklynProperties submap = props.submap(ConfigPredicates.nameEqualTo(property)); runExternalisedConfigGetters(submap, property, expectedVal, false); } }
Example 2
Source File: BrooklynPropertiesTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testGetFirstUsingFailIfNone() { BrooklynProperties props = BrooklynProperties.Factory.newEmpty().addFromMap(ImmutableMap.of("akey", "aval", "bkey", "bval")); assertEquals(props.getFirst(MutableMap.of("failIfNone", true), "akey"), "aval"); try { props.getFirst(MutableMap.of("failIfNone", true), "notThrere"); fail(); } catch (NoSuchElementException e) { // success } }