@Test public void testCustomIntentsLanguageModel() throws IOException { SkillModel skill = SkillModel.builder() .withInvocationName(Locales.en_US, "test") .addModel(Model.builder() .intent(TestIntent.class) .build()) .build(); LanguageModel actual = underTest.render(skill, Locales.en_US).getLanguageModel(); LanguageModel expected = LanguageModel.builder() .withInvocationName("test") .withIntents(Collections.singletonList( makeIntent("TestIntent", Arrays.asList( makeIntentSlot("customSlot", "TestCustom"), makeIntentSlot("dateSlot", "AMAZON.DATE"), makeIntentSlot("dayOfWeekSlot", "AMAZON.DayOfWeek"), makeIntentSlot("durationSlot", "AMAZON.DURATION"), makeIntentSlot("listTypeSlot", "AMAZON.Actor"), makeIntentSlot("literalSlot", "AMAZON.LITERAL"), makeIntentSlot("numberSlot", "AMAZON.NUMBER"), makeIntentSlot("timeSlot", "AMAZON.TIME") ), Collections.singletonList("test_en_US")))) .withTypes(Collections.singletonList( makeSlotType("TestCustom", Arrays.asList( makeSlotTypeValue("A", Collections.singletonList("test_A_en_US")), makeSlotTypeValue("B", Collections.singletonList("test_B_en_US")))))) .build(); assertEquals(WRITER.writeValueAsString(expected), WRITER.writeValueAsString(actual)); }
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);  }