@Test public void testHelloWorld() throws IOException, SAXException { Generator toTest = new GeneratorFactoryImpl().createGenerator(); ContentHandler handler = mock(ContentHandler.class); doAnswer(invocationOnMock -> { Attributes attributes = invocationOnMock.getArgumentAt(3, Attributes.class); assertAttributes(attributes, "border-color", "#F45E43"); return null; }).when(handler).startElement(eq(""), eq("mj-divider"), eq("mj-divider"), any()); doAnswer(invocationOnMock -> { Attributes attributes = invocationOnMock.getArgumentAt(3, Attributes.class); assertAttributes(attributes, "width", "100px", "src", "https: return null; }).when(handler).startElement(eq(""), eq("mj-image"), eq("mj-image"), any()); doAnswer(invocationOnMock -> { Attributes attributes = invocationOnMock.getArgumentAt(3, Attributes.class); assertAttributes(attributes, "font-size", "20px", "color", "#F45E43", "font-family", "helvetica"); return null; }).when(handler).startElement(eq(""), eq("mj-text"), eq("mj-text"), any()); try (InputStream mjmlIn = this.getClass().getClassLoader().getResourceAsStream("helloworld.mjml")) { assert mjmlIn != null; StringWriter buffer = new StringWriter(); IOUtils.copy(mjmlIn, buffer, StandardCharsets.UTF_8.name()); toTest.setContentHandler(handler); toTest.getWriter().append(buffer.getBuffer()); toTest.finished(); verify(handler).startDocument(); verify(handler).endDocument(); for (String tag : Arrays.asList("mjml", "mj-body", "mj-section", "mj-divider", "mj-image", "mj-text")) { verify(handler).startElement(eq(""), eq(tag), eq(tag), any()); verify(handler).endElement(eq(""), eq(tag), eq(tag)); } verify(handler).characters(aryEq("Hello World".toCharArray()), eq(0), eq(11)); } }
@Override public Generator createGenerator() { return new MjmlGenerator(); }
GeneratorFactoryImpl implements GeneratorFactory { @Override public Generator createGenerator() { return new MjmlGenerator(); } }
GeneratorFactoryImpl implements GeneratorFactory { @Override public Generator createGenerator() { return new MjmlGenerator(); }  }
GeneratorFactoryImpl implements GeneratorFactory { @Override public Generator createGenerator() { return new MjmlGenerator(); }  @Override Generator createGenerator(); }
GeneratorFactoryImpl implements GeneratorFactory { @Override public Generator createGenerator() { return new MjmlGenerator(); }  @Override Generator createGenerator();  }