
driven-adapter.jpa-repository.helper.adapter-operations.unit.test.mustache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scaffold-clean-architecture Show documentation
Show all versions of scaffold-clean-architecture Show documentation
Gradle plugin to create a clean application in Java that already works, It follows our best practices!
package {{package}}.jpa.helper;
import {{package}}.jpa.JPARepository;
import {{package}}.jpa.JPARepositoryAdapter;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.reactivecommons.utils.ObjectMapper;
import org.springframework.data.domain.Example;
import java.util.List;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
class AdapterOperationsTest {
@Mock
private JPARepository repository;
@Mock
private ObjectMapper objectMapper;
private JPARepositoryAdapter adapter;
@BeforeEach
void setUp() {
MockitoAnnotations.openMocks(this);
when(objectMapper.map("value", Object.class)).thenReturn("value");
adapter = new JPARepositoryAdapter(repository, objectMapper);
}
@Test
void testSave() {
Object objectValue = "value";
when(repository.save(objectValue)).thenReturn(objectValue);
Object result = adapter.save(objectValue);
assertEquals(result, objectValue);
}
@Test
void testSaveAllEntities() {
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy