@Test public void testNotEqual() { checkTF(IfFunctions.ifNotEquals(false).value("T").defaultValue("F").build(), "T"); }
@Test public void testIfNotEqual() { IfFunctionsTest.checkTF(Functionals.ifNotEquals(false).value("T").defaultValue("F").build(), "T"); }
@Test public void testIfNoBuilder() { IfFunctionsTest.checkTF(Functionals.ifEquals(false).value("F").ifEquals(true).value("T").defaultValue("?"), "?"); }
.computing(Functionals.ifNotEquals(true).value("Management URL not reachable") ) .build());
.computing(Functionals.ifNotEquals(true).value("URL not reachable")) .build());
.computing(Functionals.ifNotEquals(true).value("URL where Brooklyn listens is not answering correctly") ) .build());
.uniqueTag("not-up-unless-url-answers") .from(NGINX_URL_ANSWERS_NICELY) .computing(Functionals.ifNotEquals(true).value("URL where nginx listens is not answering correctly (with expected header)") ) .build()); connectServiceUpIsRunning();
.computing(Functionals.ifNotEquals(true).value("Crate server reports it is not ok.")) .build());
@Override protected Entity createNode(Location loc, Map<?, ?> flags) { MySqlNode node = (MySqlNode) super.createNode(loc, flags); if (!MySqlClusterUtils.IS_MASTER.apply(node)) { ServiceNotUpLogic.updateNotUpIndicator(node, MySqlSlave.SLAVE_HEALTHY, "Replication not started"); addFeed(FunctionFeed.builder() .entity(node) .period(Duration.FIVE_SECONDS) .poll(FunctionPollConfig.forSensor(MySqlSlave.SLAVE_HEALTHY) .callable(new SlaveStateCallable(node)) .checkSuccess(StringPredicates.isNonBlank()) .onSuccess(new SlaveStateParser(node)) .setOnFailure(false) .description("Polls SHOW SLAVE STATUS")) .build()); node.enrichers().add(Enrichers.builder().updatingMap(Attributes.SERVICE_NOT_UP_INDICATORS) .from(MySqlSlave.SLAVE_HEALTHY) .computing(Functionals.ifNotEquals(true).value("Slave replication status is not healthy") ) .build()); } return node; }
@Test public void testIf() { IfFunctionsTest.checkTF(Functionals.ifEquals(false).value("F").ifEquals(true).value("T").defaultValue("?").build(), "?"); }
@Test public void testIsImmutableAndSupportsReplace() { IfFunctionBuilder<Boolean, String> f = IfFunctions.ifEquals(false).value("F").ifEquals(true).value("T").defaultValue("?"); IfFunctionBuilder<Boolean, String> f2 = f.ifEquals(false).value("false").defaultValue("X"); IfFunctionBuilder<Boolean, String> f3 = f2.ifEquals(false).value("F"); checkTF(f, "?"); checkTF(f3, "X"); Assert.assertEquals(f2.apply(false), "false"); }
@Test public void testUpdatingMap1() { entity.enrichers().add(Enrichers.builder() .updatingMap(MAP1) .from(LONG1) .computing(Functionals.ifEquals(-1L).value("-1 is not allowed")) .build()); doUpdatingMapChecks(MAP1); }
@Test public void testCommonUsage() { checkTF(IfFunctions.ifEquals(false).value("F").ifEquals(true).value("T").defaultValue("?").build(), "?"); }
@Test public void testNoDefault() { checkTF(IfFunctions.ifEquals(false).value("F").ifEquals(true).value("T").build(), null); }
@Test public void testNoBuilder() { checkTF(IfFunctions.ifEquals(false).value("F").ifEquals(true).value("T").defaultValue("?"), "?"); }
@Test public void testWithCast() { Function<Boolean, String> f = IfFunctions.ifEquals(false).value("F").ifEquals(true).value("T").defaultValue("?").build(); checkTF(f, "?"); }
@Test public void testSupportsReplace() { checkTF(IfFunctions.ifEquals(false).value("false").ifEquals(false).value("F").ifEquals(true).value("T").defaultValue("?").build(), "?"); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testUpdatingMap2() { entity.enrichers().add(Enrichers.builder() .updatingMap((AttributeSensor)MAP2) .from(LONG1) .computing(Functionals.ifEquals(-1L).value("-1 is not allowed")) .build()); doUpdatingMapChecks(MAP2); }