-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug Fix Integration Test βοΈπ π³β¬
- Loading branch information
1 parent
617cfd4
commit 8a91817
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
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
25 changes: 24 additions & 1 deletion
25
src/test/java/com/hendisantika/sekolah/SekolahApplicationTests.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 |
---|---|---|
@@ -1,15 +1,38 @@ | ||
package com.hendisantika.sekolah; | ||
|
||
import com.hendisantika.sekolah.entity.Guru; | ||
import com.hendisantika.sekolah.repository.GuruRepository; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.testcontainers.junit.jupiter.Testcontainers; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) | ||
@Testcontainers | ||
class SekolahApplicationTests { | ||
@Autowired | ||
private GuruRepository guruRepository; | ||
|
||
@BeforeEach | ||
void init() { | ||
guruRepository.deleteAll(); | ||
} | ||
|
||
@Test | ||
void contextLoads() { | ||
void shouldCreateOnePerson() { | ||
final var guru = guruRepository.saveAll(List.of(new Guru("212", "Itadori Yuji", "L", "Tokyo", LocalDate.now(), "Dukun", | ||
"photo", "photoBase64", "filename", new byte[(int) "Itadori Yuji".length()])) | ||
); | ||
assertEquals(1, guru.size()); | ||
final var person = guru.get(0); | ||
assertEquals("Itadori Yuji", person.getNama()); | ||
assertEquals("212", person.getNip()); | ||
} | ||
|
||
} |