/** Verify that contextualization fails if already contextualized. */
 @Test
 public void contextualizationWhenAlreadyContextualized() {
   thrown.expect(IllegalStateException.class);
   thrown.expectMessage("Already contextualized");
   new PassivateCapabilityDuringUpdateCondition(eventBus)
       .setContext(reference.context())
       .setContext(reference.context());
 }
  @Before
  public final void setUpPassivateCapabilityDuringUpdateCondition() throws Exception {
    final CapabilityIdentity id = capabilityIdentity("test");

    final CapabilityContext context = mock(CapabilityContext.class);
    when(context.id()).thenReturn(id);

    when(reference.context()).thenReturn(context);

    underTest = new PassivateCapabilityDuringUpdateCondition(eventBus);
    underTest.setContext(context);
    underTest.bind();

    verify(eventBus).register(underTest);
  }
 boolean isSatisfiedBy(final CapabilityReference reference) {
   return type.equals(reference.context().type());
 }
 /** Verify that binding succeeds after contextualization. */
 @Test
 public void bindAfterContextualization() {
   new PassivateCapabilityDuringUpdateCondition(eventBus).setContext(reference.context()).bind();
 }
 /** Verify that contextualization fails if already bounded. */
 @Test
 public void contextualizationWhenAlreadyBounded() {
   thrown.expect(IllegalStateException.class);
   thrown.expectMessage("Cannot contextualize when already bounded");
   underTest.setContext(reference.context());
 }