IntentSlotRenderer { public List<Prompt> renderSlotPrompts(IntentDefinition intentDefinition, String slotName, IntentSlotData slotData) { assertNotNull(intentDefinition, "intentDefinition"); assertNotNull(slotName, "slotName"); assertNotNull(slotData, "slotData"); List<Prompt> prompts = new ArrayList<>(); if (!slotData.getConfirmations().isEmpty()) { String promptName = getConfirmPromptName(intentDefinition, slotName, slotData); prompts.add(getPrompt(promptName, slotData.getConfirmations())); } if (!slotData.getElicitations().isEmpty()) { String promptName = getElicitPromptName(intentDefinition, slotName, slotData); prompts.add(getPrompt(promptName, slotData.getElicitations())); } return prompts; }  Slot renderSlot(String slotName, SlotTypeDefinition slotType, IntentData intentData); DialogSlot renderDialogSlot(IntentDefinition intentDefinition, String slotName, SlotTypeDefinition slotType, IntentSlotData slotData); List<Prompt> renderSlotPrompts(IntentDefinition intentDefinition, String slotName, IntentSlotData slotData);  }
@Test(expected = IllegalArgumentException.class) public void testRenderSlotPrompts_NullIntentDefinition() { underTest.renderSlotPrompts(null, "slot_name", mockSlotMetadata); }
@Test(expected = IllegalArgumentException.class) public void testRenderSlotPrompts_NullSlotName() { underTest.renderSlotPrompts(mockIntentDefinition, null, mockSlotMetadata); }
@Test(expected = IllegalArgumentException.class) public void testRenderSlotPrompts_NullSlotMetadata() { underTest.renderSlotPrompts(mockIntentDefinition, "slot_name", null); }
@Test public void testRenderSlotPrompts_EmptyMetadata() { assertEquals(0, underTest.renderSlotPrompts(mockIntentDefinition, "slot_name", mockSlotMetadata).size()); }
@Test public void testRenderSlotPrompts_GeneratedConfirmationPromptId() { when(mockSlotMetadata.getConfirmations()).thenReturn(confirmations); List<Prompt> prompts = underTest.renderSlotPrompts(mockIntentDefinition, "slot_name", mockSlotMetadata); assertEquals(prompts, Collections.singletonList( Prompt.builder() .withId("Confirm.Intent-intent_name.IntentSlot-slot_name") .withVariations(new ArrayList<>(confirmations)) .build() )); }
@Test public void testRenderSlotPrompts_ExplicitConfirmationPromptId() { when(mockSlotMetadata.getConfirmations()).thenReturn(confirmations); when(mockSlotMetadata.getPrompts()).thenReturn(DialogSlotPrompt.builder() .withConfirmation("explicit.confirmation") .build()); List<Prompt> prompts = underTest.renderSlotPrompts(mockIntentDefinition, "slot_name", mockSlotMetadata); assertEquals(prompts, Collections.singletonList( Prompt.builder() .withId("explicit.confirmation") .withVariations(new ArrayList<>(confirmations)) .build() )); }
@Test public void testRenderSlotPrompts_GeneratedElicitationPromptId() { when(mockSlotMetadata.getConfirmations()).thenReturn(confirmations); List<Prompt> prompts = underTest.renderSlotPrompts(mockIntentDefinition, "slot_name", mockSlotMetadata); assertEquals(prompts, Collections.singletonList( Prompt.builder() .withId("Confirm.Intent-intent_name.IntentSlot-slot_name") .withVariations(new ArrayList<>(confirmations)) .build() )); }
@Test public void testRenderSlotPrompts_ExplicitElicitationPromptId() { when(mockSlotMetadata.getElicitations()).thenReturn(elicitations); when(mockSlotMetadata.getPrompts()).thenReturn(DialogSlotPrompt.builder() .withElicitation("explicit.elicitation") .build()); List<Prompt> prompts = underTest.renderSlotPrompts(mockIntentDefinition, "slot_name", mockSlotMetadata); assertEquals(prompts, Collections.singletonList( Prompt.builder() .withId("explicit.elicitation") .withVariations(new ArrayList<>(elicitations)) .build() )); }