Search in sources :

Example 36 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project sonar-go by SonarSource.

the class UastTest method parse_null_and_empty.

@ParameterizedTest
@ValueSource(strings = { "{}", "{ kinds: [], nativeNode: null, token: null, children: null, unknownElement: {} }", "{ kinds: [], nativeNode: '', token: null, children: [] }" })
void parse_null_and_empty(String json) throws Exception {
    Supplier<String> message = () -> "Assertion error for " + json;
    UastNode node = Uast.from(new StringReader(json));
    assertEquals(Collections.emptySet(), node.kinds, message);
    assertEquals("", node.nativeNode, message);
    assertNull(node.token, message);
    assertEquals(Collections.emptyList(), node.children, message);
}
Also used : StringReader(java.io.StringReader) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 37 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project harvest-client by 3AP-AG.

the class ProjectsApiCreateTest method createDefaultBudget.

@ParameterizedTest
@EnumSource(Project.BudgetMethod.class)
void createDefaultBudget(Project.BudgetMethod budgetMethod, TestInfo testInfo) {
    Reference<Client> clientReference = ExistingData.getInstance().getClientReference();
    String name = "Project for test " + testInfo.getDisplayName();
    boolean billable = true;
    Project.BillingMethod billBy = Project.BillingMethod.PROJECT;
    Project creationInfo = ImmutableProject.builder().client(clientReference).name(name).billable(billable).billBy(billBy).budgetBy(budgetMethod).build();
    project = projectsApi.create(creationInfo);
    assertThat(project.getBillable()).isEqualTo(billable);
    assertThat(project.getBillBy()).isEqualTo(billBy);
    assertThat(project.getBudgetBy()).isEqualTo(budgetMethod);
    assertThat(project.getName()).isEqualTo(name);
    assertThat(project.getClient().getId()).isEqualTo(clientReference.getId());
}
Also used : Project(ch.aaap.harvestclient.domain.Project) ImmutableProject(ch.aaap.harvestclient.domain.ImmutableProject) Client(ch.aaap.harvestclient.domain.Client) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 38 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project harvest-client by 3AP-AG.

the class ExceptionsTest method testGeneric.

@ParameterizedTest(name = "http code {1} should throw {0}")
@MethodSource("createCases")
void testGeneric(Class<HarvestHttpException> exceptionClass, int code) {
    server.enqueue(new MockResponse().setBody(ERROR_JSON).setResponseCode(code));
    // Harvest init does one request for the company
    HarvestHttpException httpException = assertThrows(exceptionClass, this::startServer);
    assertThat(httpException.getHttpCode()).isEqualTo(code);
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 39 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project harvest-client by 3AP-AG.

the class ExpensesApiCreateTest method attachReceiptException.

@ParameterizedTest
@ValueSource(strings = { "mp3.mp3" })
void attachReceiptException(String filename) throws IOException {
    try (InputStream in = getClass().getResourceAsStream("/minimal_files/" + filename)) {
        Expense creationInfo = ImmutableExpense.builder().project(project).expenseCategory(expenseCategory).spentDate(LocalDate.now()).user(user).totalCost(22.).build();
        expense = expensesApi.create(creationInfo);
        assertThrows(RequestProcessingException.class, () -> expense = expensesApi.attachReceipt(expense, in, filename));
    }
}
Also used : InputStream(java.io.InputStream) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 40 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.

the class DataTypeTest method get.

@ParameterizedTest
@MethodSource("parametersForGet")
<T> void get(DataType<T> sut, SqlBiConsumer<ResultSet, String> resultSetExtractor, Optional<ZoneId> dbTimeZone, T expected) throws SQLException {
    resultSetExtractor.accept(rs, "someColumn");
    when(db.dialect()).thenReturn(new AnsiDialect());
    dbTimeZone.ifPresent(zone -> when(db.databaseTimeZone()).thenReturn(zone));
    Optional<T> result = sut.get(rs, "someColumn", db);
    assertThat(result, is(Optional.of(expected)));
}
Also used : AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1880 MethodSource (org.junit.jupiter.params.provider.MethodSource)1020 EnumSource (org.junit.jupiter.params.provider.EnumSource)321 ValueSource (org.junit.jupiter.params.provider.ValueSource)270 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)181 Transaction (org.neo4j.graphdb.Transaction)117 ArrayList (java.util.ArrayList)97 ByteBuffer (java.nio.ByteBuffer)78 CsvSource (org.junit.jupiter.params.provider.CsvSource)78 Path (java.nio.file.Path)71 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)67 IOException (java.io.IOException)65 List (java.util.List)59 Test (org.junit.jupiter.api.Test)58 HashMap (java.util.HashMap)55 Map (java.util.Map)54 HashSet (java.util.HashSet)52 lombok.val (lombok.val)52 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)50 TimeUnit (java.util.concurrent.TimeUnit)48