Search in sources :

Example 6 with Person

use of com.example.expenses.model.Person in project aws-java-serverless by hermanlintvelt.

the class DataRepositoryTest method addTwoExpensesForPerson.

@Test
@DisplayName("If multiple expenses are added for a person, it should be found")
void addTwoExpensesForPerson() {
    Person me = new Person("me@me.com");
    Expense expense1 = new Expense(BigDecimal.valueOf(150.0), me);
    dataRepository.addExpense(expense1);
    Expense expense2 = new Expense(BigDecimal.valueOf(80.0), me);
    dataRepository.addExpense(expense2);
    List<Expense> foundExpenses = dataRepository.findExpensesPaidBy(me);
    assertThat(foundExpenses).isNotNull();
    assertThat(foundExpenses).asList().isNotEmpty();
    assertThat(foundExpenses).asList().contains(expense1, expense2);
}
Also used : Expense(com.example.expenses.model.Expense) Person(com.example.expenses.model.Person) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 7 with Person

use of com.example.expenses.model.Person in project aws-java-serverless by hermanlintvelt.

the class DataRepositoryTest method addPersonTest.

@Test
@DisplayName("A new person added to repository should be found")
void addPersonTest() {
    Person me = new Person("me@me.com");
    dataRepository.addPerson(me);
    assertThat(dataRepository.findPerson("me@me.com")).isNotEmpty().contains(me);
}
Also used : Person(com.example.expenses.model.Person) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 8 with Person

use of com.example.expenses.model.Person in project aws-java-serverless by hermanlintvelt.

the class DataRepositoryTest method allPersons.

@Test
@DisplayName("If multiple people are added to repository, then they should be retrieved")
void allPersons() {
    Person me = new Person("me@me.com");
    dataRepository.addPerson(me);
    Person you = new Person("you@me.com");
    dataRepository.addPerson(you);
    List<Person> people = dataRepository.allPersons();
    assertThat(people).isNotNull();
    assertThat(people).asList().isNotEmpty();
    assertThat(people).asList().containsOnly(me, you);
}
Also used : Person(com.example.expenses.model.Person) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 9 with Person

use of com.example.expenses.model.Person in project aws-java-serverless by hermanlintvelt.

the class DataRepositoryTest method addExpenseTest.

@Test
@DisplayName("A new expense added to repository should be found")
void addExpenseTest() {
    Person me = new Person("me@me.com");
    Expense expense = new Expense(BigDecimal.valueOf(150.0), me);
    dataRepository.addExpense(expense);
    assertThat(dataRepository.allExpenses()).asList().contains(expense);
}
Also used : Expense(com.example.expenses.model.Expense) Person(com.example.expenses.model.Person) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

Person (com.example.expenses.model.Person)9 Expense (com.example.expenses.model.Expense)7 DisplayName (org.junit.jupiter.api.DisplayName)6 Test (org.junit.jupiter.api.Test)6 APIGatewayProxyResponseEvent (com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 BigDecimal (java.math.BigDecimal)1