### Question:
StartPlaceHandler { @Request(value = StartPlaceRequest.NAME, service = true) public void handleStartPlace( PlatformMessage message, Optional<VoiceContext> context, @Named(StartPlaceRequest.ATTR_ASSISTANT) String assistant ) { long startTime = System.nanoTime(); try { if(context.isPresent()) { voiceDao.recordAssistant(context.get().getPlaceId(), assistant); context.get().addAssistant(assistant); VoiceServiceMetrics.timeHandlerSuccess(StartPlaceRequest.NAME, startTime); } else { UUID id = IrisUUID.fromString(message.getPlaceId()); voiceDao.recordAssistant(id, assistant); registry.add(id); } VoiceServiceMetrics.timeHandlerSuccess(StartPlaceRequest.NAME, startTime); } catch(RuntimeException e) { VoiceServiceMetrics.timeHandlerFailure(StartPlaceRequest.NAME, startTime); throw e; } } StartPlaceHandler(VoiceDAO voiceDao, VoiceContextExecutorRegistry registry); @Request(value = StartPlaceRequest.NAME, service = true) void handleStartPlace(
      PlatformMessage message,
      Optional<VoiceContext> context,
      @Named(StartPlaceRequest.ATTR_ASSISTANT) String assistant
   );  }### Answer:
@Test public void testContextNotPresent() { mockVoiceDao.recordAssistant(placeId, VoiceService.StartPlaceRequest.ASSISTANT_ALEXA); EasyMock.expectLastCall(); mockContextRegistry.add(placeId); EasyMock.expectLastCall(); replay(); handler.handleStartPlace(createMessage(), Optional.empty(), VoiceService.StartPlaceRequest.ASSISTANT_ALEXA); verify(); }
@Test public void testContextPresent() { mockVoiceDao.recordAssistant(placeId, VoiceService.StartPlaceRequest.ASSISTANT_ALEXA); EasyMock.expectLastCall(); replay(); handler.handleStartPlace(createMessage(), Optional.of(context), VoiceService.StartPlaceRequest.ASSISTANT_ALEXA); assertTrue(context.getAssistants().anyMatch(VoiceService.StartPlaceRequest.ASSISTANT_ALEXA::equals)); verify(); }