Last active
February 28, 2018 19:00
-
-
Save gitjs77/3675d4d7dbcb23f617850aaa1a95346e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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