SentryStateBank { public static void enableState(String component, SentryState state) { lock.writeLock().lock(); try { states.put(component, states.get(component) | state.getValue()); allStates.put(component, states.get(component) | state.getValue()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("{} entered state {}", component, state.toString()); } } finally { lock.writeLock().unlock(); } } protected  SentryStateBank(); static void enableState(String component, SentryState state); static void disableState(String component, SentryState state); static boolean isEnabled(String component, SentryState state); static boolean hasStatesEnabled(String component, Set<SentryState> passedStates); static boolean wereStatesEnabled(String component, Set<SentryState> passedStates);  }
@Test public void testEnableState() { SentryStateBank.enableState(TestState.COMPONENT, TestState.FIRST_STATE); assertTrue("Expected FIRST_STATE to be enabled", SentryStateBank.isEnabled(TestState.COMPONENT, TestState.FIRST_STATE)); assertFalse("Expected SECOND_STATE to be disabled", SentryStateBank.isEnabled(TestState.COMPONENT, TestState.SECOND_STATE)); }