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
@ParameterizedTest | |
@CsvSource({ | |
"2021-01-01, JANUARY", | |
"2020-04-15, APRIL" | |
}) | |
void a_test_with_converters(LocalDate date, Month expectedMonth) { | |
assertEquals(expectedMonth, date.getMonth()); | |
} |
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
@ParameterizedTest | |
@CsvSource({ | |
"Programmez, 10", | |
"Magazine, 8" | |
}) | |
void a_test_with_two_parameters(String word, int expectedLength) { | |
assertEquals(expectedLength, word.length()); | |
} |
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
@ParameterizedTest | |
@ValueSource(strings = {"Programmez", "Magazine"}) | |
void a_simple_test(String word) { | |
assertTrue(word.length() > 8); | |
} |
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
@Test | |
void groupedAssertions() { | |
List<String> list = List.of("Programmez", "Magazine", "JUnit"); | |
assertAll( | |
() -> assertEquals(4, list.size()), | |
() -> assertTrue(list.contains("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
@Test | |
void testThrowingException() { | |
Exception exception = assertThrows(RuntimeException.class, | |
() -> failingCodeToTest()); | |
assertEquals("Failure!", exception.getMessage()); | |
} | |
private void failingCodeToTest() { | |
throw new RuntimeException("Failure!")); | |
} |
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
import org.junit.jupiter.api.BeforeEach; | |
import org.junit.jupiter.api.Nested; | |
import org.junit.jupiter.api.Test; | |
public class NestedTests { | |
@BeforeEach | |
void globalSetup() { | |
System.out.println("A"); | |
} |
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
import org.junit.jupiter.api.AfterAll; | |
import org.junit.jupiter.api.AfterEach; | |
import org.junit.jupiter.api.BeforeAll; | |
import org.junit.jupiter.api.BeforeEach; | |
import org.junit.jupiter.api.Test; | |
import org.junit.jupiter.api.TestInstance; | |
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_METHOD; | |
@TestInstance(PER_METHOD) //valeur par défaut, pas besion de le spécifier |
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
internal class Videos(val items: List<Video>) { | |
fun toTalkBuilders(): List<Talk.Builder> { | |
return items.map(Video::toTalkBuilder) | |
} | |
} | |
internal class Video(val id: VideoId, private val snippet: Snippet) { | |
internal fun toTalkBuilder(): Talk.Builder { | |
val videoId = id.videoId | |
return Talk.with { |
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
{ | |
"criteria": { | |
"journeys": [ | |
{ | |
"departureSpacePortId": "http://localhost:1865/spaceports/ddf86b0b-94e3-3566-8486-fd076b9686a6", | |
"departureSchedule": "2020-08-18T10:00", | |
"arrivalSpacePortId": "http://localhost:1865/spaceports/4ed3116c-e359-3245-b8d0-cec742551507" | |
}, | |
{ | |
"departureSpacePortId": "http://localhost:1865/spaceports/4ed3116c-e359-3245-b8d0-cec742551507", |
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
@Resource | |
data class Search(private val id: UUID, | |
val criteria: Criteria) : RepresentationModel<Search>() |