### Question:
JpaWidgetCommentConverter { public JpaWidgetComment convert(WidgetComment source, String widgetId) { return source instanceof JpaWidgetComment ? (JpaWidgetComment) source : createEntity(source, widgetId); }  Class<WidgetComment> getSourceType(); JpaWidgetComment convert(WidgetComment source, String widgetId);  }### Answer:
@Test public void noConversion() { WidgetComment comment = new JpaWidgetComment(); assertThat(widgetCommentConverter.convert(comment, null), is(sameInstance(comment))); }
@Test public void nullConversion() { WidgetComment template = null; assertThat(widgetCommentConverter.convert(template, null), is(nullValue())); }
@Test public void newComment() { WidgetComment comment = new WidgetCommentImpl("9"); comment.setCreatedDate(new Date()); comment.setLastModifiedDate(new Date()); comment.setText("hello"); comment.setUserId("1"); JpaWidgetComment converted = widgetCommentConverter.convert(comment, "9"); assertThat(converted, is(not(sameInstance(comment)))); assertThat(converted, is(instanceOf(JpaWidgetComment.class))); assertThat(converted.getCreatedDate(), is(equalTo(comment.getCreatedDate()))); assertThat(converted.getEntityId().toString(), is(equalTo(comment.getId()))); assertThat(converted.getId(), is(equalTo(comment.getId()))); assertThat(converted.getLastModifiedDate(), is(equalTo(comment.getLastModifiedDate()))); assertThat(converted.getText(), is(equalTo(comment.getText()))); assertThat(converted.getUserId(), is(equalTo(comment.getUserId()))); }