BucketMapper { public static BucketModel transform(BucketEntity bucketEntity) { BucketModel bucketModel = null; if (bucketEntity != null) { bucketModel = new BucketModel(); if (bucketEntity.getTasks() != null) { bucketModel.setTasks(transform(bucketEntity.getTasks())); } } return bucketModel; }  static BucketModel transform(BucketEntity bucketEntity);  }
@Test public void testTransformEntity() { BucketEntity bucketEntity = createEntity(); TaskEntity taskEntity = new TaskEntity(); taskEntity.setId(FAKE_TASK_ID); TaskEntity taskEntity2 = new TaskEntity(); taskEntity2.setId(FAKE_TASK_ID_2); tasks.put(FAKE_TASK_ID, taskEntity); tasks.put(FAKE_TASK_ID_2, taskEntity2); BucketModel bucketModel = BucketMapper.transform(bucketEntity); assertThat(bucketModel, is(instanceOf(BucketModel.class))); assertThat(bucketModel.getTasks()).hasSize(2); }
@Test public void testTransformEmptyEntity() { BucketEntity bucketEntity = createEntity(); BucketModel bucketModel = BucketMapper.transform(bucketEntity); assertThat(bucketModel, is(instanceOf(BucketModel.class))); assertThat(bucketModel.getTasks()).isEmpty(); assertThat(bucketModel.getTasks()).hasSize(0); }