Skip to content
Snippets Groups Projects
Commit 563fcc64 authored by Diana Gulčíková's avatar Diana Gulčíková
Browse files

basic test

parent 9aac265a
No related branches found
No related tags found
2 merge requests!60Docker,!38Client to call endpoints
......@@ -51,6 +51,12 @@
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
......
package cz.muni.pa165.driver.rest;
import cz.muni.pa165.driver.data.model.Driver;
import cz.muni.pa165.driver.data.repository.DriverRepository;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@DataJpaTest
class DriverControllerItTest {
@Autowired
private TestEntityManager entityManager;
@Autowired
private DriverRepository driverRepository;
@Test
public void testSave() {
// Create a new instance of MyEntity
Driver driver = Driver.builder()
.name("name")
.surname("surname")
.nationality("nationality")
.characteristics(Map.of()).build();
Driver savedDriver = driverRepository.save(driver);
Assertions.assertEquals(savedDriver, driver);
Assertions.assertEquals(entityManager.find(Driver.class, 1L).getId(), 1);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment