@Test public void testSamples() throws IOException { SkillModel skill = SkillModel.builder() .withInvocationName(Locales.en_US, "en_US") .withInvocationName(Locales.en_GB, "en_GB") .withInvocationName(Locales.de_DE, "de_DE") .withInvocationName(Locales.fr_FR, "fr_FR") .addModel(Model.builder() .intent(TestIntent.class) .build()) .build(); for (Locale locale : Locales.values()) { Collection<com.amazon.ask.interaction.model.Intent> actual = underTest.render(skill, locale).getLanguageModel().getIntents(); List<com.amazon.ask.interaction.model.Intent> expected = 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_" + stringifyLocale(locale))) ); 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);  }