IntentSlotRenderer { public DialogSlot renderDialogSlot(IntentDefinition intentDefinition, String slotName, SlotTypeDefinition slotType, IntentSlotData slotData) { assertNotNull(intentDefinition, "intentDefinition"); assertStringNotEmpty(slotName, "slotName"); assertNotNull(slotType, "slotType"); assertNotNull(slotData, "slotData"); return DialogSlot.builder() .withName(slotName) .withType(slotType.getName()) .withElicitationRequired(slotData.getElicitationRequired()) .withConfirmationRequired(slotData.getConfirmationRequired()) .withPrompts(DialogSlotPrompt.builder() .withConfirmation(getConfirmPromptName(intentDefinition, slotName, slotData)) .withElicitation(getElicitPromptName(intentDefinition, slotName, slotData)) .build()) .build(); }  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 public void testRenderDialogSlot_GeneratedElicitationPromptId() { when(mockSlotMetadata.getElicitations()).thenReturn(elicitations); assertEquals( "Elicit.Intent-intent_name.IntentSlot-slot_name", underTest.renderDialogSlot(mockIntentDefinition, "slot_name", mockSlotTypeDefinition, mockSlotMetadata).getPrompts().getElicitation() ); }
@Test public void testRenderDialogSlot_ExplicitElicitationPromptId() { when(mockSlotMetadata.getElicitations()).thenReturn(elicitations); when(mockSlotMetadata.getPrompts()).thenReturn(DialogSlotPrompt.builder() .withElicitation("explicit.elicitation") .build()); assertEquals( "explicit.elicitation", underTest.renderDialogSlot(mockIntentDefinition, "slot_name", mockSlotTypeDefinition, mockSlotMetadata).getPrompts().getElicitation() ); }
@Test(expected = IllegalArgumentException.class) public void testRenderDialogSlot_NullIntentDefinition() { underTest.renderDialogSlot(null, "slot_name", mockSlotTypeDefinition, mockSlotMetadata); }
@Test(expected = IllegalArgumentException.class) public void testRenderDialogSlot_NullSlotName() { underTest.renderDialogSlot(mockIntentDefinition, null, mockSlotTypeDefinition, mockSlotMetadata); }
@Test(expected = IllegalArgumentException.class) public void testRenderDialogSlot_NullSlotTypeDefinition() { underTest.renderDialogSlot(mockIntentDefinition, "slot_name", null, mockSlotMetadata); }
@Test(expected = IllegalArgumentException.class) public void testRenderDialogSlot_NullSlotMetadata() { underTest.renderDialogSlot(mockIntentDefinition, "slot_name", mockSlotTypeDefinition, null); }
@Test public void testRenderDialogSlot_SlotName() { assertEquals( "slot_name", underTest.renderDialogSlot(mockIntentDefinition, "slot_name", mockSlotTypeDefinition, mockSlotMetadata).getName()); }
@Test public void testRenderDialogSlot_SlotType() { assertEquals( "slot_type", underTest.renderDialogSlot(mockIntentDefinition, "slot_name", mockSlotTypeDefinition, mockSlotMetadata).getType()); }
@Test public void testRenderDialogSlot_NullConfirmationRequired() { DialogSlot dialog = underTest.renderDialogSlot(mockIntentDefinition, "slot_name", mockSlotTypeDefinition, mockSlotMetadata); assertNull(dialog.getConfirmationRequired()); assertNull(dialog.getPrompts().getConfirmation()); }
@Test public void testRenderDialogSlot_ConfirmationRequired() { when(mockSlotMetadata.getConfirmationRequired()).thenReturn(true); assertTrue(underTest.renderDialogSlot(mockIntentDefinition, "slot_name", mockSlotTypeDefinition, mockSlotMetadata).getConfirmationRequired()); when(mockSlotMetadata.getConfirmationRequired()).thenReturn(false); assertFalse(underTest.renderDialogSlot(mockIntentDefinition, "slot_name", mockSlotTypeDefinition, mockSlotMetadata).getConfirmationRequired()); }
@Test public void testRenderDialogSlot_NullElicitationRequired() { DialogSlot dialog = underTest.renderDialogSlot(mockIntentDefinition, "slot_name", mockSlotTypeDefinition, mockSlotMetadata); assertNull(dialog.getElicitationRequired()); assertNull(dialog.getPrompts().getElicitation()); }
@Test public void testRenderDialogSlot_ElicitationRequired() { when(mockSlotMetadata.getElicitationRequired()).thenReturn(true); assertTrue(underTest.renderDialogSlot(mockIntentDefinition, "slot_name", mockSlotTypeDefinition, mockSlotMetadata).getElicitationRequired()); when(mockSlotMetadata.getElicitationRequired()).thenReturn(false); assertFalse(underTest.renderDialogSlot(mockIntentDefinition, "slot_name", mockSlotTypeDefinition, mockSlotMetadata).getElicitationRequired()); }
@Test public void testRenderDialogSlot_GeneratedConfirmationPromptId() { when(mockSlotMetadata.getConfirmations()).thenReturn(confirmations); assertEquals( "Confirm.Intent-intent_name.IntentSlot-slot_name", underTest.renderDialogSlot(mockIntentDefinition, "slot_name", mockSlotTypeDefinition, mockSlotMetadata).getPrompts().getConfirmation() ); }
@Test public void testRenderDialogSlot_ExplicitConfirmationPromptId() { when(mockSlotMetadata.getConfirmations()).thenReturn(confirmations); when(mockSlotMetadata.getPrompts()).thenReturn(DialogSlotPrompt.builder() .withConfirmation("explicit.confirmation") .build()); assertEquals( "explicit.confirmation", underTest.renderDialogSlot(mockIntentDefinition, "slot_name", mockSlotTypeDefinition, mockSlotMetadata).getPrompts().getConfirmation() ); }