### Question:
TriggerContext implements AutoCloseable { public static TriggerContext set(TriggerContext ctx) { if (currentContext.get() != null) throw new IllegalStateException("Trigger context already set."); currentContext.set(ctx); return ctx; } private  TriggerContext(TriggerEventConsumer triggerEventConsumer); static TriggerContext get(); static TriggerContext set(TriggerContext ctx); static boolean isSet(); static TriggerContext clear(); static Builder builder(); @Override void close(); TriggerContext registerTriggerEvent(TriggerEvent event);  }### Answer:
@Test(expected = IllegalStateException.class) public void testSetContextTwice() throws Exception { try (TriggerContext ignored = TriggerContext.set(context)) { TriggerContext.set(context); } }