ViewFormMapper { @NonNull public List<ViewForm> transform(@Nullable List<FormInfo> forms, SurveyGroup mSurveyGroup, String deletedString) { int capacity = forms == null ? 0 : forms.size(); List<ViewForm> viewForms = new ArrayList<>(capacity); if (forms == null) { return viewForms; } for (FormInfo formInfo : forms) { if (formInfo != null) { viewForms.add(transform(formInfo, mSurveyGroup, deletedString)); } } return viewForms; }  @NonNull List<ViewForm> transform(@Nullable List<FormInfo> forms, SurveyGroup mSurveyGroup,
            String deletedString);  }
@Test public void transformShouldReturnEmptyArrayIfNull() { ViewFormMapper mapper = new ViewFormMapper(); List<FormInfo> original = null; List<ViewForm> mapped = mapper.transform(original, mockSurveyGroup, "deleted"); assertNotNull(mapped); assertTrue(mapped.isEmpty()); }
@Test public void transformShouldIgnoreNullItems() { ViewFormMapper mapper = new ViewFormMapper(); List<FormInfo> original = new ArrayList<>(); original.add(null); original.add(mockSurveyItem); List<ViewForm> mapped = mapper.transform(original, mockSurveyGroup, "deleted"); assertNotNull(mapped); assertEquals(1, mapped.size()); }
@Test public void transformShouldTransformCorrectlyDeletedSurvey() { ViewFormMapper mapper = new ViewFormMapper(); given(mockSurveyItem.isDeleted()).willReturn(true); given(mockSurveyItem.getVersion()).willReturn("1.0"); ViewForm mapped = mapper.transform(mockSurveyItem, mockSurveyGroup, "deleted"); assertFalse(mapped.isEnabled()); assertEquals(" v1.0 - deleted", mapped.getSurveyExtraInfo()); }