org.assertj.core.api.AssertProvider Java Examples

The following examples show how to use org.assertj.core.api.AssertProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryAssertions.java    From presto with Apache License 2.0 5 votes vote down vote up
static AssertProvider<ExpressionAssert> newExpressionAssert(String expression, QueryRunner runner, Session session)
{
    MaterializedResult result = runner.execute(session, "VALUES " + expression);
    Type type = result.getTypes().get(0);
    Object value = result.getOnlyColumnAsSet().iterator().next();
    return () -> new ExpressionAssert(runner, session, value, type)
            .withRepresentation(TYPE_RENDERER);
}
 
Example #2
Source File: ParserAssert.java    From presto with Apache License 2.0 5 votes vote down vote up
private static <T extends Node> AssertProvider<ParserAssert> createAssertion(Function<String, T> parser, String sql)
{
    return () -> new ParserAssert(parser.apply(sql), newRecursiveComparisonConfig())
            .withRepresentation(NODE_REPRESENTATION)
            .satisfies(parsed -> new ParserAssert(parser.apply(formatSql((Node) parsed)), newRecursiveComparisonConfig())
                    .describedAs("Validate SQL->AST->SQL roundtrip")
                    .withRepresentation(NODE_REPRESENTATION)
                    .ignoringLocation()
                    .isEqualTo(parser.apply(sql)));
}
 
Example #3
Source File: GroovyDslGradleSettingsAssertTests.java    From initializr with Apache License 2.0 5 votes vote down vote up
private AssertProvider<GroovyDslGradleSettingsAssert> forSampleGradleSettings() {
	String path = "project/build/gradle/sample-settings.gradle";
	try (InputStream in = new ClassPathResource(path).getInputStream()) {
		String content = StreamUtils.copyToString(in, StandardCharsets.UTF_8);
		return () -> new GroovyDslGradleSettingsAssert(content);
	}
	catch (IOException ex) {
		throw new IllegalStateException("No content found at " + path, ex);
	}
}
 
Example #4
Source File: GroovyDslGradleBuildAssertTests.java    From initializr with Apache License 2.0 5 votes vote down vote up
private AssertProvider<GroovyDslGradleBuildAssert> forSampleGradleBuild() {
	String path = "project/build/gradle/sample-build.gradle";
	try (InputStream in = new ClassPathResource(path).getInputStream()) {
		String content = StreamUtils.copyToString(in, StandardCharsets.UTF_8);
		return () -> new GroovyDslGradleBuildAssert(content);
	}
	catch (IOException ex) {
		throw new IllegalStateException("No content found at " + path, ex);
	}
}
 
Example #5
Source File: MavenBuildAssertTests.java    From initializr with Apache License 2.0 5 votes vote down vote up
private AssertProvider<MavenBuildAssert> forMavenBuild(String name) {
	try (InputStream in = new ClassPathResource("project/build/maven/" + name).getInputStream()) {
		String content = StreamUtils.copyToString(in, StandardCharsets.UTF_8);
		return () -> new MavenBuildAssert(content);
	}
	catch (IOException ex) {
		throw new IllegalStateException("No content found at " + name, ex);
	}
}
 
Example #6
Source File: QueryAssertions.java    From presto with Apache License 2.0 4 votes vote down vote up
static AssertProvider<QueryAssert> newQueryAssert(String query, QueryRunner runner, Session session)
{
    MaterializedResult result = runner.execute(session, query);
    return () -> new QueryAssert(runner, session, result);
}
 
Example #7
Source File: ParserAssert.java    From presto with Apache License 2.0 4 votes vote down vote up
public static AssertProvider<ParserAssert> type(String sql)
{
    return createAssertion(new SqlParser()::createType, sql);
}
 
Example #8
Source File: ParserAssert.java    From presto with Apache License 2.0 4 votes vote down vote up
public static AssertProvider<ParserAssert> expression(String sql)
{
    return createAssertion(expression -> new SqlParser().createExpression(expression, new ParsingOptions(AS_DECIMAL)), sql);
}
 
Example #9
Source File: ParserAssert.java    From presto with Apache License 2.0 4 votes vote down vote up
public static AssertProvider<ParserAssert> statement(String sql)
{
    return createAssertion(statement -> new SqlParser().createStatement(statement, new ParsingOptions(AS_DECIMAL)), sql);
}
 
Example #10
Source File: AbstractExtensionTests.java    From start.spring.io with Apache License 2.0 4 votes vote down vote up
protected AssertProvider<MavenBuildAssert> mavenPom(ProjectRequest request) {
	request.setType("maven-build");
	String content = new String(getInvoker().invokeBuildGeneration(request));
	return () -> new MavenBuildAssert(content);
}
 
Example #11
Source File: AbstractExtensionTests.java    From start.spring.io with Apache License 2.0 4 votes vote down vote up
protected AssertProvider<GroovyDslGradleBuildAssert> gradleBuild(ProjectRequest request) {
	request.setType("gradle-build");
	String content = new String(getInvoker().invokeBuildGeneration(request));
	return () -> new GroovyDslGradleBuildAssert(content);
}
 
Example #12
Source File: ModuleAssertTests.java    From initializr with Apache License 2.0 4 votes vote down vote up
private AssertProvider<ModuleAssert> forDirectory(Path projectDirectory) {
	return () -> new ModuleAssert(projectDirectory);
}
 
Example #13
Source File: JvmModuleAssertTests.java    From initializr with Apache License 2.0 4 votes vote down vote up
private AssertProvider<AbstractJvmModuleAssert<?>> forJavaProject(Path root) {
	return () -> new JvmModuleAssert(root, JAVA_LANGUAGE);
}
 
Example #14
Source File: MavenBuildAssertTests.java    From initializr with Apache License 2.0 4 votes vote down vote up
private AssertProvider<MavenBuildAssert> forSampleMavenBuild() {
	return forMavenBuild("sample-pom.xml");
}
 
Example #15
Source File: TextAssertTests.java    From initializr with Apache License 2.0 4 votes vote down vote up
private AssertProvider<TextAssert> forContent(String content) {
	return () -> new TextAssert(content);
}
 
Example #16
Source File: TextAssertTests.java    From initializr with Apache License 2.0 4 votes vote down vote up
private AssertProvider<TextAssert> forContent(Path file) {
	return () -> new TextAssert(file);
}