コード例 #1
0
 @Test
 public void testConvertNull() throws Exception {
   SyntheticField field = mock(SyntheticField.class);
   when(field.getType()).thenReturn((Class) SimpleBaseDomain.class);
   String[] tags = new String[] {"a", "b", "c"};
   assertThat(typeConverter.convert(null, field, null, tags)).isNull();
 }
コード例 #2
0
  @Test
  public void testConvert() throws Exception {
    SimpleBaseTo source = new SimpleBaseTo();
    SyntheticField field = mock(SyntheticField.class);
    when(field.getType()).thenReturn((Class) SimpleBaseDomain.class);
    String[] tags = new String[] {"a", "b", "c"};
    typeConverter.convert(source, field, null, tags);

    verify(jTransfo).convertTo(source, SimpleBaseDomain.class, tags);
  }
コード例 #3
0
  @Test
  public void testReverse() throws Exception {
    SimpleBaseDomain source = new SimpleBaseDomain();
    SimpleBaseTo target = new SimpleBaseTo();
    when(reflectionHelper.newInstance(any(Class.class))).thenReturn(target);
    SyntheticField field = mock(SyntheticField.class);
    when(field.getType()).thenReturn((Class) SimpleBaseTo.class);
    String[] tags = new String[] {"a", "b", "c"};
    typeConverter.reverse(source, field, null, tags);

    verify(jTransfo).convert(source, target, tags);
  }
コード例 #4
0
  @Test
  public void testReverseIllegalAccessException() throws Exception {
    SimpleBaseDomain source = new SimpleBaseDomain();
    SimpleBaseTo target = new SimpleBaseTo();
    when(reflectionHelper.newInstance(any(Class.class))).thenThrow(new IllegalAccessException());
    SyntheticField field = mock(SyntheticField.class);
    when(field.getType()).thenReturn((Class) SimpleBaseTo.class);

    exception.expect(JTransfoException.class);
    exception.expectMessage(
        "Cannot create instance of transfer object class org.jtransfo.object.SimpleBaseTo.");

    typeConverter.reverse(source, field, null);
  }
コード例 #5
0
 @Test
 public void testReverseNullHandling() throws Exception {
   SyntheticField field = mock(SyntheticField.class);
   when(field.getType()).thenReturn((Class) SimpleBaseTo.class);
   assertThat(typeConverter.reverse(null, field, null)).isNull();
 }