Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Loveneesh Singh lovewithmind

🎯
Focusing
View GitHub Profile
View PersonTestLombok.java
class PersonTest {
@Test
public void shouldReturnFalseForInCorrectEmail() {
Person person = PersonTestData.defaultBuilder()
.email("abc123")
.build();
boolean isValidEmail = person.isValidEmail();
assertFalse(isValidEmail);
}
@lovewithmind
lovewithmind / PersonBuilder.java
Last active Jun 14, 2021
Person data builder
View PersonBuilder.java
class PersonTest {
@Test
public void shouldReturnFalseForInCorrectEmail() {
Person person = PersonBuilder.defaultBuilder()
.email("99999")
.build();
boolean isValidEmail = person.isValidEmail();
assertFalse(isValidEmail);
}
@lovewithmind
lovewithmind / PersonTest.java
Created Jun 12, 2021
Using utility class to build person
View PersonTest.java
class PersonTest {
@Test
public void shouldReturnTrueForCorrectEmail() {
Person person = TestUtil.aPerson(
"John",
"john@gmail.com",
"888888",
"888888"
);
View PersonTest.java
class PersonTest {
@Test
public void shouldReturnTrueForCorrectEmail() {
Person person = new Person(1,
"John",
"john@gmail.com",
"888888",
"888888",
null,
null);
View Address.java
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;
@lovewithmind
lovewithmind / Person.java
Last active Jun 12, 2021
Person data class
View Person.java
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 stepVerifierException.kt
@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
@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")
}
@lovewithmind
lovewithmind / StepVerifier.kt
Last active May 7, 2020
Using StepVerifier to test async Publisher
View StepVerifier.kt
@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()
}
@lovewithmind
lovewithmind / ReactiveBlockTestExample.kt
Last active May 5, 2020
This is an example of reactive test with block
View ReactiveBlockTestExample.kt
@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()