@Test public void testLocales() throws GeneratorException, IOException { File mockEnFile = Mockito.mock(File.class); File mockFrFile = Mockito.mock(File.class); Generator generator = new Generator(mockWriter, mockRenderer, mockApplication, mockDir, Arrays.asList(en_US, fr_FR)) { @Override protected File getDestFile(String name) { if (name.equals("en-US.json")) return mockEnFile; if (name.equals("fr-FR.json")) return mockFrFile; fail("expected en-US.json or fr-FR.json"); return null; } }; InteractionModelEnvelope mockEnModel = InteractionModelEnvelope.builder() .withInteractionModel(InteractionModel.builder().build()) .build(); InteractionModelEnvelope mockFrModel = InteractionModelEnvelope.builder().build(); Mockito.when(mockRenderer.render(mockSkill, en_US)).thenReturn(mockEnModel); Mockito.when(mockRenderer.render(mockSkill, fr_FR)).thenReturn(mockFrModel); Mockito.when(mockDir.exists()) .thenReturn(true) .thenReturn(false); generator.generate(); Mockito.verify(mockWriter).writeValue(mockEnFile, mockEnModel); Mockito.verify(mockWriter).writeValue(mockFrFile, mockFrModel); }
public void generate() throws GeneratorException { try { SkillModel skillModel = skillModelSupplier.getSkillModel(); if (!destdir.exists()) { destdir.mkdirs(); } for (Locale locale : locales) { File out = getDestFile(locale.toLanguageTag() + ".json"); writer.writeValue(out, renderer.render(skillModel, locale)); } } catch (IOException | RuntimeException ex) { throw new GeneratorException(ex); } }
Generator { public void generate() throws GeneratorException { try { SkillModel skillModel = skillModelSupplier.getSkillModel(); if (!destdir.exists()) { destdir.mkdirs(); } for (Locale locale : locales) { File out = getDestFile(locale.toLanguageTag() + ".json"); writer.writeValue(out, renderer.render(skillModel, locale)); } } catch (IOException | RuntimeException ex) { throw new GeneratorException(ex); } } }
Generator { public void generate() throws GeneratorException { try { SkillModel skillModel = skillModelSupplier.getSkillModel(); if (!destdir.exists()) { destdir.mkdirs(); } for (Locale locale : locales) { File out = getDestFile(locale.toLanguageTag() + ".json"); writer.writeValue(out, renderer.render(skillModel, locale)); } } catch (IOException | RuntimeException ex) { throw new GeneratorException(ex); } } Generator(SkillModelSupplier skillModelSupplier, File destdir, List<Locale> locales);  Generator(ObjectWriter writer, SkillModelRenderer renderer, SkillModelSupplier skillModelSupplier, File destdir, List<Locale> locales); }
Generator { public void generate() throws GeneratorException { try { SkillModel skillModel = skillModelSupplier.getSkillModel(); if (!destdir.exists()) { destdir.mkdirs(); } for (Locale locale : locales) { File out = getDestFile(locale.toLanguageTag() + ".json"); writer.writeValue(out, renderer.render(skillModel, locale)); } } catch (IOException | RuntimeException ex) { throw new GeneratorException(ex); } } Generator(SkillModelSupplier skillModelSupplier, File destdir, List<Locale> locales);  Generator(ObjectWriter writer, SkillModelRenderer renderer, SkillModelSupplier skillModelSupplier, File destdir, List<Locale> locales); void generate(); }
Generator { public void generate() throws GeneratorException { try { SkillModel skillModel = skillModelSupplier.getSkillModel(); if (!destdir.exists()) { destdir.mkdirs(); } for (Locale locale : locales) { File out = getDestFile(locale.toLanguageTag() + ".json"); writer.writeValue(out, renderer.render(skillModel, locale)); } } catch (IOException | RuntimeException ex) { throw new GeneratorException(ex); } } Generator(SkillModelSupplier skillModelSupplier, File destdir, List<Locale> locales);  Generator(ObjectWriter writer, SkillModelRenderer renderer, SkillModelSupplier skillModelSupplier, File destdir, List<Locale> locales); void generate();  }