-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/test/java/com/pos/app/repository/ClientRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.pos.app.repository; | ||
|
||
|
||
import com.github.javafaker.Faker; | ||
import com.pos.app.entities.Client; | ||
import com.pos.app.repositories.ClientRepository; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
@RunWith(SpringRunner.class) | ||
@DataJpaTest | ||
@ExtendWith(MockitoExtension.class) | ||
public class ClientRepositoryTest { | ||
Faker faker = new Faker(); | ||
String name = faker.name().fullName(); | ||
|
||
@Autowired | ||
private ClientRepository clientRepository; | ||
|
||
@Test | ||
public void contextLoads() { | ||
Assertions.assertThat(clientRepository).isNotNull(); | ||
} | ||
|
||
@Test | ||
public void testSave() { | ||
Client client = saveClient(); | ||
Assertions.assertThat(client).isNotNull(); | ||
Assertions.assertThat(client.getId()).isNotNull(); | ||
Assertions.assertThat(client.getName()).isEqualTo(name); | ||
} | ||
|
||
|
||
|
||
private Client saveClient() { | ||
Client client = Client.builder() | ||
.name(name) | ||
.createdBy(name) | ||
.build(); | ||
return clientRepository.save(client); | ||
} | ||
|
||
} |