View PersonBuilder.java
This file contains 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
class PersonTest { | |
@Test | |
public void shouldReturnFalseForInCorrectEmail() { | |
Person person = PersonBuilder.defaultBuilder() | |
.email("99999") | |
.build(); | |
boolean isValidEmail = person.isValidEmail(); | |
assertFalse(isValidEmail); | |
} |
View PersonTestLombok.java
This file contains 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
class PersonTest { | |
@Test | |
public void shouldReturnFalseForInCorrectEmail() { | |
Person person = PersonTestData.defaultBuilder() | |
.email("abc123") | |
.build(); | |
boolean isValidEmail = person.isValidEmail(); | |
assertFalse(isValidEmail); | |
} |
View PersonTest.java
This file contains 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
class PersonTest { | |
@Test | |
public void shouldReturnTrueForCorrectEmail() { | |
Person person = TestUtil.aPerson( | |
"John", | |
"john@gmail.com", | |
"888888", | |
"888888" | |
); |
View PersonTest.java
This file contains 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
class PersonTest { | |
@Test | |
public void shouldReturnTrueForCorrectEmail() { | |
Person person = new Person(1, | |
"John", | |
"john@gmail.com", | |
"888888", | |
"888888", | |
null, | |
null); |
View Address.java
This file contains 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
public class Address{ | |
private final String addressLine1; | |
private final String AddressLine2; | |
private final Integer postalCode; | |
Address(final String addressLine1, | |
final String addressLine2, | |
final Integer postalCode) { | |
this.addressLine1 = addressLine1; | |
this.AddressLine2 = addressLine2; |
View Person.java
This file contains 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
public class Person { | |
private final Integer identificationNumber; | |
private final String name; | |
private final String email; | |
private final String phoneNumber; | |
private final String mobileNumber; | |
private final Address homeAddress; | |
private final Address officeAddress; | |
public Person(final Integer identificationNumber, |
View StepVerifier.kt
This file contains 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
@Test | |
fun `should return person data given name of the person`(){ | |
val monoPerson = PersonManager.getProfile("PersonX") | |
val expectedResult = Person(name = "PersonX", age = 18) | |
StepVerifier.create(monoPerson) | |
.expectNext(expectedResult) | |
.verifyComplete() | |
} |
View stepVerifierException.kt
This file contains 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
@Test | |
fun `should throw Exception for mono`(){ | |
val monoError = Mono.error<Exception>(Exception()) | |
StepVerifier.create(mono) | |
.expectError(Exception::class.java) | |
.verify() | |
} | |
@Test | |
fun `should consume thrown exception from flux`() { |
View blockException.kt
This file contains 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
@Test | |
fun `should throw exception while fetching person data`(){ | |
val personService = PersonService() | |
assertThatThrownBy{ | |
personService.getPerson("name") | |
}.isInstanceOf(PersonNotFound::class.java) | |
.hasMessage("No person found in the database") | |
} |
View ReactiveBlockTestExample.kt
This file contains 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
@Test | |
fun `should return person data given name of the person`(){ | |
val monoPerson = PersonManager.getProfile("PersonX") | |
val expectedResult = Person(name = "PersonX", age = 18) | |
assertThat(monoPerson.block()).isEqual(expectedResult) | |
} | |
@Test | |
fun `should return list of person data`(){ | |
val fluxList = PersonManager.getAllProfile() |
NewerOlder