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);
}
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());
}
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);
}
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));
}
}
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)));
}
Aggregations