@Test public void testSlotExplicitPromptIds() { SkillModel skill = SkillModel.builder() .withInvocationName(Locales.en_US, "en_US") .addModel(Model.builder() .intent(TestPrompts.class) .build()) .build(); InteractionModel model = underTest.render(skill, Locales.en_US); DialogSlot slot = model.getDialog().getIntents().get(0).getSlots().stream() .filter(s -> s.getName().equals("customSlot")) .findFirst().get(); assertEquals(slot.getPrompts().getConfirmation(), "customSlot.confirmation"); assertEquals(slot.getPrompts().getElicitation(), "customSlot.elicitation"); assertEquals( model.getPrompts().stream().filter(p -> p.getId().equals("customSlot.confirmation")).findFirst().get().getVariations(), Collections.singletonList(PromptVariation.builder().withType("PlainText").withValue("test_en_US customSlot confirmation").build())); assertEquals( model.getPrompts().stream().filter(p -> p.getId().equals("customSlot.elicitation")).findFirst().get().getVariations(), Collections.singletonList(PromptVariation.builder().withType("PlainText").withValue("test_en_US customSlot elicitation").build())); }
public InteractionModel render(SkillModel skillModel, Locale locale) { assertNotNull(skillModel, "skillDefinition"); assertNotNull(locale, "locale"); if (!skillModel.getInvocationNames().containsKey(locale)) { throw new IllegalArgumentException("no invocation name specified for locale: " + locale); } SubModel subModel = modelRenderer.render(skillModel.getModel(), locale); LanguageModel languageModel = LanguageModel.builder() .withInvocationName(skillModel.getInvocationNames().get(locale)) .withIntents(new ArrayList<>(subModel.getLanguageModel().getIntents())) .withTypes(new ArrayList<>(subModel.getLanguageModel().getTypes())) .build(); return InteractionModel.builder() .withLanguageModel(languageModel) .withDialog(subModel.getDialog()) .withPrompts(subModel.getPrompts()) .build(); }
InteractionModelRenderer { public InteractionModel render(SkillModel skillModel, Locale locale) { assertNotNull(skillModel, "skillDefinition"); assertNotNull(locale, "locale"); if (!skillModel.getInvocationNames().containsKey(locale)) { throw new IllegalArgumentException("no invocation name specified for locale: " + locale); } SubModel subModel = modelRenderer.render(skillModel.getModel(), locale); LanguageModel languageModel = LanguageModel.builder() .withInvocationName(skillModel.getInvocationNames().get(locale)) .withIntents(new ArrayList<>(subModel.getLanguageModel().getIntents())) .withTypes(new ArrayList<>(subModel.getLanguageModel().getTypes())) .build(); return InteractionModel.builder() .withLanguageModel(languageModel) .withDialog(subModel.getDialog()) .withPrompts(subModel.getPrompts()) .build(); } }
InteractionModelRenderer { public InteractionModel render(SkillModel skillModel, Locale locale) { assertNotNull(skillModel, "skillDefinition"); assertNotNull(locale, "locale"); if (!skillModel.getInvocationNames().containsKey(locale)) { throw new IllegalArgumentException("no invocation name specified for locale: " + locale); } SubModel subModel = modelRenderer.render(skillModel.getModel(), locale); LanguageModel languageModel = LanguageModel.builder() .withInvocationName(skillModel.getInvocationNames().get(locale)) .withIntents(new ArrayList<>(subModel.getLanguageModel().getIntents())) .withTypes(new ArrayList<>(subModel.getLanguageModel().getTypes())) .build(); return InteractionModel.builder() .withLanguageModel(languageModel) .withDialog(subModel.getDialog()) .withPrompts(subModel.getPrompts()) .build(); } InteractionModelRenderer(ModelRenderer modelRenderer);  InteractionModelRenderer(); }
InteractionModelRenderer { public InteractionModel render(SkillModel skillModel, Locale locale) { assertNotNull(skillModel, "skillDefinition"); assertNotNull(locale, "locale"); if (!skillModel.getInvocationNames().containsKey(locale)) { throw new IllegalArgumentException("no invocation name specified for locale: " + locale); } SubModel subModel = modelRenderer.render(skillModel.getModel(), locale); LanguageModel languageModel = LanguageModel.builder() .withInvocationName(skillModel.getInvocationNames().get(locale)) .withIntents(new ArrayList<>(subModel.getLanguageModel().getIntents())) .withTypes(new ArrayList<>(subModel.getLanguageModel().getTypes())) .build(); return InteractionModel.builder() .withLanguageModel(languageModel) .withDialog(subModel.getDialog()) .withPrompts(subModel.getPrompts()) .build(); } InteractionModelRenderer(ModelRenderer modelRenderer);  InteractionModelRenderer(); InteractionModel render(SkillModel skillModel, Locale locale); }
InteractionModelRenderer { public InteractionModel render(SkillModel skillModel, Locale locale) { assertNotNull(skillModel, "skillDefinition"); assertNotNull(locale, "locale"); if (!skillModel.getInvocationNames().containsKey(locale)) { throw new IllegalArgumentException("no invocation name specified for locale: " + locale); } SubModel subModel = modelRenderer.render(skillModel.getModel(), locale); LanguageModel languageModel = LanguageModel.builder() .withInvocationName(skillModel.getInvocationNames().get(locale)) .withIntents(new ArrayList<>(subModel.getLanguageModel().getIntents())) .withTypes(new ArrayList<>(subModel.getLanguageModel().getTypes())) .build(); return InteractionModel.builder() .withLanguageModel(languageModel) .withDialog(subModel.getDialog()) .withPrompts(subModel.getPrompts()) .build(); } InteractionModelRenderer(ModelRenderer modelRenderer);  InteractionModelRenderer(); InteractionModel render(SkillModel skillModel, Locale locale);  }