ServiceStateLogic { public static void setExpectedState(Entity entity, Lifecycle state) { setExpectedState(entity, state, entity.getAttribute(SERVICE_STATE_ACTUAL)!=null && entity.getAttribute(SERVICE_STATE_ACTUAL)!=Lifecycle.ON_FIRE); } private  ServiceStateLogic(); static TVal getMapSensorEntry(Entity entity, AttributeSensor<Map<TKey,TVal>> sensor, TKey key); @SuppressWarnings("unchecked") static void clearMapSensorEntry(Entity entity, AttributeSensor<Map<TKey,TVal>> sensor, TKey key); static void updateMapSensorEntry(Entity entity, AttributeSensor<Map<TKey,TVal>> sensor, final TKey key, final TVal v); static void setExpectedState(Entity entity, Lifecycle state); static void setExpectedStateRunningWithErrors(Entity entity); static Lifecycle getExpectedState(Entity entity); static Lifecycle getActualState(Entity entity); static boolean isExpectedState(Entity entity, Lifecycle state); static final EnricherSpec<?> newEnricherForServiceStateFromProblemsAndUp(); static final EnricherSpec<?> newEnricherForServiceState(Class<? extends Enricher> type); static final EnricherSpec<?> newEnricherForServiceUpFromChildren(); static final EnricherSpec<?> newEnricherForServiceUpFromMembers(); static final EnricherSpec<?> newEnricherForServiceUpFromChildrenWithQuorumCheck(QuorumCheck quorumCheck); static final EnricherSpec<?> newEnricherForServiceUp(Boolean fromChildren, Boolean fromMembers); static ComputeServiceIndicatorsFromChildrenAndMembersSpec newEnricherFromChildren(); static ComputeServiceIndicatorsFromChildrenAndMembersSpec newEnricherFromChildrenUp(); static ComputeServiceIndicatorsFromChildrenAndMembersSpec newEnricherFromChildrenState(); static final AttributeSensor<Boolean> SERVICE_UP; static final AttributeSensor<Map<String,Object>> SERVICE_NOT_UP_INDICATORS; static final AttributeSensor<Map<String,Object>> SERVICE_NOT_UP_DIAGNOSTICS; static final AttributeSensor<Lifecycle> SERVICE_STATE_ACTUAL; static final AttributeSensor<Lifecycle.Transition> SERVICE_STATE_EXPECTED; static final AttributeSensor<Map<String,Object>> SERVICE_PROBLEMS; }
@Test(groups={"WIP", "Broken"}) public void testServiceStateNotCalledExplicitly() throws Exception { ComputeServiceState oldEnricher = (ComputeServiceState) Iterables.find(app.enrichers(), Predicates.instanceOf(ComputeServiceState.class)); String oldUniqueTag = oldEnricher.getUniqueTag(); CountingComputeServiceState enricher = app.enrichers().add(EnricherSpec.create(CountingComputeServiceState.class) .uniqueTag(oldUniqueTag)); Iterable<Enricher> newEnrichers = Iterables.filter(app.enrichers(), Predicates.instanceOf(ComputeServiceState.class)); assertEquals(Iterables.size(newEnrichers), 1, "newEnrichers="+newEnrichers); assertEquals(Iterables.getOnlyElement(newEnrichers), enricher, "newEnrichers="+newEnrichers); ServiceStateLogic.setExpectedState(app, Lifecycle.RUNNING); assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); assertTrue(enricher.cntCalled.get() > 0); assertEquals(enricher.cntCalledWithNull.get(), 0); }