0

Mockito – thenReturn or thenAnswer?

Mockito – thenReturn or thenAnswer?

This post demonstrates that thenReturn is designed to return the same value every time the stubbed method is invoked and that thenAnswer provides a way to vary the returned values after each method invocation. Generally, we use thenReturn to return “hardcoded” values; we use thenAnswer to use some complex logic to generate and return a value. Continue Reading

0

JPA – How to use @Embeddable and @Embedded

In Java Persistence API (JPA), a class can either be an @Entity or a value type. If a class is an @Entity, it is a persistent class. It represents a database table (or set of tables). If a class is a value type, it is not a persistent class. It may not represent a database table or a set of database tables. It may be used as a reusable component whose properties are used across multiple tables. Continue Reading