### Question:
JpaPageTemplateConverter implements ModelConverter<PageTemplate, JpaPageTemplate> { @Override public JpaPageTemplate convert(PageTemplate source) { if (source != null) { source.setPageType(source.getPageType() == null ? null : source.getPageType().toUpperCase()); return source instanceof JpaPageTemplate ? (JpaPageTemplate) source : createEntity(source); } return null; }  @Override Class<PageTemplate> getSourceType(); @Override JpaPageTemplate convert(PageTemplate source);  }### Answer:
@Test public void testNoConversion() { JpaPageTemplate template = new JpaPageTemplate(); assertThat(converter.convert(template), is(sameInstance(template))); }
@Test public void nullConversion() { PageTemplate template = null; assertThat(converter.convert(template), is(nullValue())); }
@Test public void convertValid() { PageTemplate template = new PageTemplateImpl("1"); template.setName("name"); template.setSubPageTemplates(new ArrayList<PageTemplate>()); template.setDefaultTemplate(true); template.setRenderSequence(1); template.setPageTemplateRegions(new ArrayList<PageTemplateRegion>()); template.setPageLayout(new PageLayoutImpl()); template.setParentPageTemplate(new PageTemplateImpl("1")); template.setDescription("Description"); template.setPageType(PageType.USER.toString()); JpaPageTemplate jpaTemplate = converter.convert(template); assertThat(jpaTemplate, is(not(sameInstance(template)))); assertThat(jpaTemplate, is(instanceOf(JpaPageTemplate.class))); assertThat(jpaTemplate.getId().toString(), is(equalTo(template.getId()))); assertThat(jpaTemplate.getPageType(), is(equalTo(template.getPageType()))); assertThat(jpaTemplate.getName(), is(equalTo(template.getName()))); assertThat(jpaTemplate.getDescription(), is(equalTo(template.getDescription()))); assertThat(jpaTemplate.getParentPageTemplate(), is(instanceOf(JpaPageTemplate.class))); assertThat(jpaTemplate.getPageLayout(), is(instanceOf(JpaPageLayout.class))); assertThat(jpaTemplate.getPageTemplateRegions(), is(equalTo(template.getPageTemplateRegions()))); assertThat(jpaTemplate.getRenderSequence(), is(equalTo(template.getRenderSequence()))); assertThat(jpaTemplate.isDefaultTemplate(), is(equalTo(template.isDefaultTemplate()))); assertThat(jpaTemplate.getSubPageTemplates(), is(equalTo(template.getSubPageTemplates()))); }