Skip to content

Instantly share code, notes, and snippets.

@gitjs77
Last active February 28, 2018 19:00
Show Gist options
  • Save gitjs77/3675d4d7dbcb23f617850aaa1a95346e to your computer and use it in GitHub Desktop.
Save gitjs77/3675d4d7dbcb23f617850aaa1a95346e to your computer and use it in GitHub Desktop.
@SuppressWarnings("Not presented method findByTwoLetterCode(). Fix it in shortest possible time.")
@Ignore
@Test
public void testFindByTwoLetterCode() {
CountryData countryData = new CountryData();
String twoLetterCode = "AZ";
countryData.code2 = twoLetterCode;
Long countryId = countryDB.create(countryData);
Country country = countryDB.findByTwoLetterCode("AZ");
Assert.assertEquals(countryId, country.id);
Assert.assertEquals(twoLetterCode, country.twoLetterCode);
}
// Try this pattern:
@Test
public void testFindByTwoLetterCode() {
final String expectedTwoLetterCode = "AZ";
final CountryData countryData = new CountryData();
countryData.code2 = expectedTwoLetterCode;
final Long createdCountryId = countryDB.create(countryData);
final Country fetchedCountryByTwoLetterCode = countryDB.findByTwoLetterCode(expectedTwoLetterCode);
Assert.assertEquals(createdCountryId, fetchedCountryByTwoLetterCode.id);
Assert.assertEquals(expectedTwoLetterCode, fetchedCountryByTwoLetterCode.twoLetterCode);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment