-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CORE-95] Adding validation endpoints and tests for all server endpoi…
…nts.
- Loading branch information
1 parent
3865a81
commit 4f8c4c9
Showing
19 changed files
with
1,280 additions
and
105 deletions.
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
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
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
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
26 changes: 26 additions & 0 deletions
26
...a-core/src/main/java/io/telicent/jena/graphql/utils/ExcludeFromJacocoGeneratedReport.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright (C) Telicent Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package io.telicent.jena.graphql.utils; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Class for excluding code from coverage as it is unsuitable. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.METHOD) | ||
public @interface ExcludeFromJacocoGeneratedReport { | ||
} |
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
90 changes: 90 additions & 0 deletions
90
...hql-jena-core/src/test/java/io/telicent/jena/graphql/execution/TestDatasetValidation.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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/** | ||
* Copyright (C) Telicent Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package io.telicent.jena.graphql.execution; | ||
|
||
import graphql.ErrorType; | ||
import graphql.GraphQLError; | ||
import graphql.ParseAndValidateResult; | ||
import graphql.validation.ValidationError; | ||
import io.telicent.jena.graphql.schemas.CoreSchema; | ||
import io.telicent.jena.graphql.utils.NodeFilter; | ||
import org.apache.jena.sparql.core.DatasetGraphFactory; | ||
import org.apache.jena.vocabulary.RDFS; | ||
import org.testng.Assert; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static graphql.validation.ValidationErrorType.InvalidSyntax; | ||
|
||
@SuppressWarnings("unchecked") | ||
public class TestDatasetValidation extends AbstractExecutionTests { | ||
|
||
private static final String QUERY_BASE = "/queries/dataset/"; | ||
|
||
private static String loadQuery(String queryResource) { | ||
return loadQuery(QUERY_BASE, queryResource); | ||
} | ||
|
||
public static final String SIMPLE_QUADS_QUERY = loadQuery("simple-quads.graphql"); | ||
|
||
public static final String FILTERED_QUADS_QUERY = loadQuery("filtered-quads.graphql"); | ||
|
||
public static final String VARIABLE_QUADS_QUERY = loadQuery("variable-quads.graphql"); | ||
|
||
public static final String ALIASED_QUADS_QUERY = loadQuery("aliased-quads.graphql"); | ||
|
||
public static final String FRAGMENT_QUADS_QUERY = loadQuery("fragment-quads.graphql"); | ||
|
||
|
||
@DataProvider(name = "validQueries") | ||
private static Object[] validQueryList() { | ||
return new Object[] { | ||
SIMPLE_QUADS_QUERY, | ||
FILTERED_QUADS_QUERY, | ||
ALIASED_QUADS_QUERY, | ||
FRAGMENT_QUADS_QUERY, | ||
VARIABLE_QUADS_QUERY | ||
}; | ||
} | ||
|
||
|
||
@DataProvider(name = "invalidQueries") | ||
private static Object[] invalidQueryList() { | ||
return new Object[] { | ||
"", | ||
"random", | ||
"query={}", | ||
"query={", | ||
"query=query($subject: NodeFilter, $predicate: NodeFilter, $object: NodeFilter, $graph: NodeFilter) {}" | ||
}; | ||
} | ||
|
||
@Test(dataProvider = "validQueries") | ||
public void dataset_valid_queries(String validQuery) throws IOException { | ||
DatasetExecutor execution = new DatasetExecutor(DatasetGraphFactory.create()); | ||
|
||
verifyValidationSuccess(execution, validQuery); | ||
} | ||
|
||
@Test(dataProvider = "invalidQueries") | ||
public void dataset_invalid_queries(String invalidQuery) throws IOException { | ||
DatasetExecutor execution = new DatasetExecutor(DatasetGraphFactory.create()); | ||
|
||
verifyValidationFailure(execution, invalidQuery); | ||
} | ||
|
||
} |
Oops, something went wrong.