@Override public Map<String, Object> getProvisioningFlags(Collection<String> tags) { if (tags.size() > 0) { LOG.warn("Location {}, ignoring provisioning tags {}", this, tags); } return MutableMap.<String, Object>of(); }
protected <K, V> Map<K, V> copyRetainingKeys(Map<K, V> orig, Set<? extends K> keysToKeep) { Map<K, V> result = MutableMap.of(); for (Map.Entry<K, V> entry : orig.entrySet()) { if (keysToKeep.contains(entry.getKey())) { result.put(entry.getKey(), entry.getValue()); } } return result; }
/** * Installs a URL onto a remote machine. * * @see #install(Map, SshMachineLocation, String, String, int) */ public static int install(SshMachineLocation machine, String urlToInstall, String target) { return install(MutableMap.<String, Object>of(), machine, urlToInstall, target, NUM_RETRIES_FOR_COPYING); }
@Test public void testSetFromFlagUsingOverridenName() { MyLocation loc = newLocation(MutableMap.of("altStr2", "myval")); assertEquals(loc.str2, "myval"); }
@Test public void testSetFromFlagOverridingDefault() { MyLocation loc = newLocation(MutableMap.of("str3", "overridden str3")); assertEquals(loc.str3, "overridden str3"); }
private <T> void assertEqualsEventually(final T actual, final T expected) { Asserts.succeedsEventually(MutableMap.of("timeout", TIMEOUT_MS), new Runnable() { @Override public void run() { assertEquals(actual, expected, "actual="+actual); }}); }
public BasicExternalConfigSupplierRegistry(ManagementContext mgmt) { addProvider(DEMO_SAMPLE_PROVIDER, new InPlaceExternalConfigSupplier(mgmt, DEMO_SAMPLE_PROVIDER, MutableMap.of(DEMO_SAMPLE_PROVIDER_PASSWORD_KEY, DEMO_SAMPLE_PROVIDER_PASSWORD_VALUE))); updateFromBrooklynProperties(mgmt); }
@Test public void testSetFromFlagCastsPrimitives() { MyPolicy policy = newPolicy(MutableMap.of("double1", 1f)); assertEquals(policy.double1, 1d); }
private void assertRecordsEventually(final RecordingMembershipTrackingPolicy policy, final List<Record>... validExpecteds) { Asserts.succeedsEventually(MutableMap.of("timeout", TIMEOUT_MS), new Runnable() { @Override public void run() { for (List<Record> validExpected : validExpecteds) { if (policy.records.equals(validExpected)) return; } fail("actual="+policy.records+"; valid: "+Arrays.toString(validExpecteds)); }}); }
@Override @Test(groups = {"Integration"}) public void testExecReturningNonZeroExitCode() throws Exception { int exitcode = tool.execCommands(MutableMap.<String,Object>of(), ImmutableList.of("exit 123")); assertEquals(exitcode, 123); }
@Test public void testFieldSetFromFlag() { ConcreteLocation loc = new ConcreteLocation(MutableMap.of("myfield", "myval")); assertEquals(loc.myfield, "myval"); }
@Test public void testLegacyConstructionUsesCustomDisplayName() throws Exception { app = new TestApplicationImpl(MutableMap.of("displayName", "appname")); MyEntity entity = new MyEntityImpl(MutableMap.of("displayName", "entityname"), app); MyEntity entity2 = new MyEntityImpl(MutableMap.of("name", "entityname2"), app); assertEquals(app.getDisplayName(), "appname"); assertEquals(entity.getDisplayName(), "entityname"); assertEquals(entity2.getDisplayName(), "entityname2"); } }
@Test public void testEffectorWithoutBodyFails() throws Exception { Entity doubler = app.createAndManageChild(EntitySpec.create(TestEntity.class)); boolean failed = false; try { doubler.invoke(DOUBLE_BODYLESS, MutableMap.of("numberToDouble", 3)); } catch (Exception e) { failed = true; } if (!failed) Assert.fail("doubling should have failed because it had no body"); }
/** the composed effector should allow us to inspect its children */ @Test public void testComposedEffectorBasic() throws Exception { Entity txp1 = app.createAndManageChild(EntitySpec.create(Entity.class, Txp1Entity.class)); Task<Integer> e = txp1.invoke(TWO_X_PLUS_ONE_BASIC, MutableMap.of("numberToStartWith", 3)); Assert.assertTrue(e instanceof DynamicSequentialTask); Assert.assertEquals(e.get(), (Integer)7); Assert.assertEquals( Iterables.size( ((HasTaskChildren)e).getChildren() ), 2); }
@Test public void testFailsFastOnInvalidCoercion() { try { newLocation(MutableMap.of("int1", "thisisnotanint")); Asserts.shouldHaveFailedPreviously(); } catch (Exception e) { if (Exceptions.getFirstThrowableOfType(e, IllegalArgumentException.class) == null) { throw e; } } }
@Test public void testSyntaxOneTaggedCorrectly() throws Exception { Task<Integer> t = app.invoke(DOUBLE_1, MutableMap.of("numberToDouble", 3)); t.get(); checkTags(t, app, DOUBLE_1, false); }
@Override public void onEvent(SensorEvent<Object> event) { final Effector<?> eff = getEffectorNamed(getConfig(EFFECTOR)).get(); if (isBusySensorEnabled()) { final Object currentSensorValue = entity.sensors().get(sensor); setMoreUpdatesComing(event.getTimestamp(), event.getValue(), currentSensorValue); } invoke(eff, MutableMap.<String, Object>of()); }
@Test public void testSummingEnricherWhenNoSensorValuesYetDefaultsToNull() { entity.enrichers().add(Enrichers.builder() .aggregating(intSensor) .publishing(target) .computingSum() .fromHardcodedProducers(ImmutableList.of(entity)) .build()); EntityAsserts.assertAttributeEqualsContinually(MutableMap.of("timeout", 50), entity, target, null); }
@Test public void testSummingEnricherWithNoValues() { entity.enrichers().add(Enrichers.builder() .aggregating(intSensor) .publishing(target) .computingSum() .fromHardcodedProducers(ImmutableList.of(entity)) .build()); EntityAsserts.assertAttributeEqualsContinually(MutableMap.of("timeout", 50), entity, target, null); }
@Test public void testHttpEffectorWithJsonPath() throws Exception { new HttpCommandEffector(ConfigBag.newInstance() .configure(HttpCommandEffector.EFFECTOR_NAME, "Httpbin") .configure(HttpCommandEffector.EFFECTOR_URI, serverUrl + "/get?id=myId") .configure(HttpCommandEffector.EFFECTOR_HTTP_VERB, "GET") .configure(HttpCommandEffector.JSON_PATH, "$.args.id") ).apply(entity); String val = entity.invoke(EFFECTOR_HTTPBIN, MutableMap.<String,String>of()).get(); Assert.assertEquals(val, "myId"); }