### Question:
WishlistDtoFromRecordBuilder extends DtoFromRecordBuilder<WishlistDataDto> { public WishlistDataDto build(CSVRecord csvRecord) throws ImportException { try { return new WishlistDataDto( formatLong(getId(csvRecord)), formatInteger(csvRecord.get("movie_id")), csvRecord.get("title"), csvRecord.get("poster_path"), csvRecord.get("overview"), formatInteger(csvRecord.get("firstYear")), csvRecord.get("release_date"), getWishlistItemTypeFromString(csvRecord.get("wishlistItemType")) ); } catch (ParseException e) { throw new ImportException(context.getString(R.string.import_parsing_line_error_toast, csvRecord.get("title")), e); } } WishlistDtoFromRecordBuilder(Context context);   WishlistDtoFromRecordBuilder(Context context, PreferencesWrapper preferencesWrapper); WishlistDataDto build(CSVRecord csvRecord);  }### Answer:
@Test public void build() throws Exception { doReturn(true).when(csvRecord).isMapped("id"); doReturn("12").when(csvRecord).get("id"); doReturn("24").when(csvRecord).get("movie_id"); doReturn("a good title").when(csvRecord).get("title"); doReturn("overview").when(csvRecord).get("overview"); doReturn("2015").when(csvRecord).get("firstYear"); doReturn("poster path").when(csvRecord).get("poster_path"); doReturn("date release").when(csvRecord).get("release_date"); doReturn("MOVIE").when(csvRecord).get("wishlistItemType"); WishlistDataDto dataDto = new WishlistDataDto( 12L, 24, "a good title", "poster path", "overview", 2015, "date release", WishlistItemType.MOVIE ); assertEquals( dataDto, new WishlistDtoFromRecordBuilder(context, preferencesWrapper).build(csvRecord) ); }
@Test public void build_serie() throws Exception { doReturn(true).when(csvRecord).isMapped("id"); doReturn("12").when(csvRecord).get("id"); doReturn("24").when(csvRecord).get("movie_id"); doReturn("a good title").when(csvRecord).get("title"); doReturn("overview").when(csvRecord).get("overview"); doReturn("2015").when(csvRecord).get("firstYear"); doReturn("poster path").when(csvRecord).get("poster_path"); doReturn("date release").when(csvRecord).get("release_date"); doReturn("SERIE").when(csvRecord).get("wishlistItemType"); WishlistDataDto dataDto = new WishlistDataDto( 12L, 24, "a good title", "poster path", "overview", 2015, "date release", WishlistItemType.SERIE ); assertEquals( dataDto, new WishlistDtoFromRecordBuilder(context, preferencesWrapper).build(csvRecord) ); }
@Test(expected = ImportException.class) public void build_badType() throws Exception { doReturn(true).when(csvRecord).isMapped("id"); doReturn("12").when(csvRecord).get("id"); doReturn("24").when(csvRecord).get("movie_id"); doReturn("a good title").when(csvRecord).get("title"); doReturn("overview").when(csvRecord).get("overview"); doReturn("2015").when(csvRecord).get("firstYear"); doReturn("poster path").when(csvRecord).get("poster_path"); doReturn("date release").when(csvRecord).get("release_date"); doReturn("banane").when(csvRecord).get("wishlistItemType"); new WishlistDtoFromRecordBuilder(context, preferencesWrapper).build(csvRecord); }