Search in sources :

Example 11 with Expense

use of com.example.expenses.model.Expense 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 12 with Expense

use of com.example.expenses.model.Expense 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

Expense (com.example.expenses.model.Expense)12 Person (com.example.expenses.model.Person)7 DisplayName (org.junit.jupiter.api.DisplayName)6 Test (org.junit.jupiter.api.Test)6 APIGatewayProxyResponseEvent (com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)5 APIGatewayProxyRequestEvent (com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent)2 SQSEventNotifier (com.example.expenses.lambda.aws.SQSEventNotifier)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 BigDecimal (java.math.BigDecimal)1 Expression (software.amazon.awssdk.enhanced.dynamodb.Expression)1 AttributeValue (software.amazon.awssdk.services.dynamodb.model.AttributeValue)1