### Question:
IdempotentMessageContextService { void set(MessageContext messageContext) { Assert.isNull(CONTEXT.get(), "The messageContext was not null before setting it! Clear should have been used!"); CONTEXT.set(messageContext); }    }### Answer:
@Test void testSet() { MessageContext expectedContext = IdempotencyTestUtils.createIdempotentContext(); idempotentMessageContextService.set(expectedContext); MessageContext actualContext = idempotentMessageContextService.get(); assertThat(actualContext, sameInstance(expectedContext)); }
@Test void testSetWhenNotEmpty() { MessageContext expectedContext = IdempotencyTestUtils.createIdempotentContext(); idempotentMessageContextService.set(expectedContext); assertThrows(IllegalArgumentException.class, () -> idempotentMessageContextService.set(expectedContext)); }