DatabaseEntityMapper { @Contract("null -> null") public DataStripe transform(final @Nullable DatabaseStripe databaseStripe) { DataStripe ret = null; if (databaseStripe != null) { ret = new DataStripe(); ret.setAlt(databaseStripe.getAlt()); ret.setDay(databaseStripe.getDay()); ret.setImg(databaseStripe.getImg()); ret.setLink(databaseStripe.getLink()); ret.setMonth(databaseStripe.getMonth()); ret.setNews(databaseStripe.getNews()); ret.setNum(databaseStripe.getNum()); ret.setSafe_title(databaseStripe.getSafe_title()); ret.setTitle(databaseStripe.getTitle()); ret.setTranscript(databaseStripe.getTranscript()); ret.setYear(databaseStripe.getYear()); } return ret; } @Inject  DatabaseEntityMapper(); @Contract("null -> null") DataStripe transform(final @Nullable DatabaseStripe databaseStripe); @Contract("null -> null") DatabaseStripe transform(final @Nullable DataStripe dataStripe);  }
@Test public void testTransformFromDataNull() { assertThat(mSut.transform((DataStripe) null)).isNull(); }
@Test public void testTransformFromDatabaseNull() { assertThat(mSut.transform((DatabaseStripe) null)).isNull(); }
@Test public void testTransformFromDataAllFieldsNull() { final DataStripe source = new DataStripe(); source.setAlt(generateString(Value.NULL)); source.setDay(generateString(Value.NULL)); source.setImg(generateString(Value.NULL)); source.setLink(generateString(Value.NULL)); source.setMonth(generateString(Value.NULL)); source.setYear(generateString(Value.NULL)); source.setNews(generateString(Value.NULL)); source.setNum(generateLong(Value.NULL)); source.setTitle(generateString(Value.NULL)); source.setSafe_title(generateString(Value.NULL)); source.setTranscript(generateString(Value.NULL)); assertEquivalent(source, mSut.transform(source)); }
@Test public void testTransformFromDataAllFieldsRegular() { final DataStripe source = new DataStripe(); source.setAlt(generateString(Value.REGULAR)); source.setDay(generateString(Value.REGULAR)); source.setImg(generateString(Value.REGULAR)); source.setLink(generateString(Value.REGULAR)); source.setMonth(generateString(Value.REGULAR)); source.setYear(generateString(Value.REGULAR)); source.setNews(generateString(Value.REGULAR)); source.setNum(generateLong(Value.REGULAR)); source.setTitle(generateString(Value.REGULAR)); source.setSafe_title(generateString(Value.REGULAR)); source.setTranscript(generateString(Value.REGULAR)); assertEquivalent(source, mSut.transform(source)); }
@Test public void testTransformFromDatabaseAllFieldsNull() { final DatabaseStripe source = new DatabaseStripe(); source.setAlt(generateString(Value.NULL)); source.setDay(generateString(Value.NULL)); source.setImg(generateString(Value.NULL)); source.setLink(generateString(Value.NULL)); source.setMonth(generateString(Value.NULL)); source.setYear(generateString(Value.NULL)); source.setNews(generateString(Value.NULL)); source.setNum(generateLong(Value.NULL)); source.setTitle(generateString(Value.NULL)); source.setSafe_title(generateString(Value.NULL)); source.setTranscript(generateString(Value.NULL)); assertEquivalent(mSut.transform(source), source); }
@Test public void testTransformFromDatabaseAllFieldsRegular() { final DatabaseStripe source = new DatabaseStripe(); source.setAlt(generateString(Value.REGULAR)); source.setDay(generateString(Value.REGULAR)); source.setImg(generateString(Value.REGULAR)); source.setLink(generateString(Value.REGULAR)); source.setMonth(generateString(Value.REGULAR)); source.setYear(generateString(Value.REGULAR)); source.setNews(generateString(Value.REGULAR)); source.setNum(generateLong(Value.REGULAR)); source.setTitle(generateString(Value.REGULAR)); source.setSafe_title(generateString(Value.REGULAR)); source.setTranscript(generateString(Value.REGULAR)); assertEquivalent(mSut.transform(source), source); }