### Question:
ResourceDefinitionService { @Cacheable("resourceDefinitionCache") public String getResourceDefinition(String cloudPlatform, String resource) { LOGGER.debug("Sending request for {} {} resource property definition", cloudPlatform, resource); CloudPlatformVariant platformVariant = new CloudPlatformVariant(Platform.platform(cloudPlatform), Variant.EMPTY); ResourceDefinitionRequest request = requestProvider.getResourceDefinitionRequest(platformVariant, resource); eventBus.notify(request.selector(), eventFactory.createEvent(request)); try { ResourceDefinitionResult result = request.await(); LOGGER.debug("Resource property definition: {}", result); return result.getDefinition(); } catch (InterruptedException e) { LOGGER.info("Error while sending resource definition request", e); throw new OperationException(e); } }  @Cacheable("resourceDefinitionCache") String getResourceDefinition(String cloudPlatform, String resource);  }### Answer:
@Test public void testResourceDefinitionServiceAnswered() throws InterruptedException { when(requestProvider.getResourceDefinitionRequest(any(), anyString())).thenReturn(resourceDefinitionRequest); when(resourceDefinitionRequest.await()).thenReturn(resourceDefinitionResult); when(resourceDefinitionResult.getDefinition()).thenReturn(SAMPLE_RESULT); Assertions.assertEquals( SAMPLE_RESULT, resourceDefinitionServiceUnderTest.getResourceDefinition(CLOUD_PLATFORM, RESOURCE) ); }
@Test public void testResourceDefinitionServiceUnanswered() throws InterruptedException { when(requestProvider.getResourceDefinitionRequest(any(), anyString())).thenReturn(resourceDefinitionRequest); when(resourceDefinitionRequest.await()).thenThrow(InterruptedException.class); Assertions.assertThrows(OperationException.class, () -> resourceDefinitionServiceUnderTest.getResourceDefinition(CLOUD_PLATFORM, RESOURCE)); }