Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up and update documentation #29

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
dfb196f
#3 DateTime
Sep 15, 2024
55fcfa0
#4 NamedValue
Sep 15, 2024
3dc9755
#5 url & #6 band
Sep 16, 2024
0a979b7
added javadoc
Sep 18, 2024
305110c
Added recursive method to retrieve JSON nodes by name
Oct 1, 2024
f846f16
Refactored the method to support searching for multiple node names us…
Oct 1, 2024
482f95f
Throw exception when invalid.
Oct 2, 2024
9bfd829
bugfix
Oct 11, 2024
68e1a4b
Merge branch 'main' into issues3456
Oct 11, 2024
52f801e
move implemented test to new structure
Oct 11, 2024
4bb65c4
use the com.ethlo.time package to validate the datetime format accord…
Oct 14, 2024
9623c7e
update testng.xml
Oct 14, 2024
9d62fc4
update testng.xml
Oct 14, 2024
860f07d
implement abstract test 10
Oct 14, 2024
bc2d7b8
Add utils, findNodesByType
Oct 15, 2024
32aa5ec
Merge branch 'issues3456' into Abstract-Test-10,12,14,15
Oct 15, 2024
0b85369
implement abstract test 11
Oct 15, 2024
071b390
implement abstract test 14, 15
Oct 15, 2024
5571a34
implement abstract test 16
Nov 2, 2024
6732394
Merge branch 'main' into Abstract-Test-10,12,14,15
Nov 2, 2024
9a896f2
Roll teamengine-spi version from 5.7 to 5.5.2 and fix build error cau…
Nov 2, 2024
c406e4b
Implement abstract test 17,18
Nov 2, 2024
6fc4291
Implement abstract test 19,20,21,22,23
Nov 2, 2024
315885b
Implement abstract test 24,25
Nov 2, 2024
7e4764b
Fix the error thrown by Javadoc during the Maven build.
Nov 18, 2024
c59b5c8
Implement Abstract Test 26
Nov 18, 2024
05fe2d9
Implement Abstract Test 27
Nov 18, 2024
ce214a9
Implement Abstract Test 28
Nov 18, 2024
9d14abc
fix bug of Abstract Test 11,13,14,16
Nov 18, 2024
33cf4d2
fix bug of Abstract Test 18,19,21,22,23
Nov 18, 2024
fab0bce
fix bug of Abstract Test 26,28
Nov 18, 2024
bc4817a
bug fix
Dec 9, 2024
b4dd2fb
Implement abstract test 29
Dec 9, 2024
eea00f8
#28 - remove obsolete classes
Dec 9, 2024
e062d74
#28 - update documentation
Dec 9, 2024
87882b0
Merge branch 'Abstract-Test-10,12,14,15' into Abstract-test-17,23,25
Dec 11, 2024
76dd3d6
Merge branch 'Abstract-test-17,23,25' into Abstract-test-26,27,28
Dec 11, 2024
463e9f0
Merge branch 'Abstract-test-26,27,28' into Clean-up-and-update-docume…
Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
16 changes: 11 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<groupId>org.opengis.cite</groupId>
Expand Down Expand Up @@ -79,6 +79,12 @@
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>com.ethlo.time</groupId>
<artifactId>itu</artifactId>
<version>1.10.2</version>
<classifier>small</classifier>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -87,11 +93,11 @@
<groupId>com.networknt</groupId>
<artifactId>json-schema-validator</artifactId>
<version>1.0.76</version>
</dependency>
</dependency>
<dependency>
<groupId>org.opengis.cite.teamengine</groupId>
<artifactId>teamengine-spi</artifactId>
<version>5.7</version>
<version>5.5.2</version>
</dependency>
<dependency>
<groupId>org.opengis.cite</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.opengis.cite.trainingdmlai10part2;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
Expand Down Expand Up @@ -86,4 +84,22 @@ public String otherConvertInputStreamToString(InputStream is) throws IOException

return result.toString("UTF-8");
}

public JsonSchema getSchema(String schemaName) throws IOException {
InputStream inputStream = getClass().getResourceAsStream(schemaName);
if (inputStream == null) {
throw new IOException("Resource not found: " + schemaName + ".");
}
JsonNode schemaNode = getJsonNodeFromStringContent(otherConvertInputStreamToString(inputStream));
JsonSchema schema = getJsonSchemaFromJsonNodeAutomaticVersion(schemaNode);

schema.initializeValidators();

return schema;
}

public JsonNode getNodeFromFile(java.io.File testSubject) throws IOException {
JsonNode node = getJsonNodeFromStringContent(otherConvertInputStreamToString(new FileInputStream(testSubject)));
return node;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientRequest;
import com.sun.jersey.api.client.ClientResponse;

import java.net.URI;
import java.util.Map;
import javax.ws.rs.core.MediaType;

import org.opengis.cite.trainingdmlai10part2.util.ClientUtils;
import org.testng.ITestContext;
import org.testng.SkipException;
Expand All @@ -23,6 +25,8 @@ public class CommonFixture {
* Root test suite package (absolute path).
*/
public static final String ROOT_PKG_PATH = "/org/opengis/cite/trainingdmlai10part2/";

public static final String SCHEMA_PATH = ROOT_PKG_PATH + "jsonschema/";
/**
* HTTP client component (JAX-RS Client API).
*/
Expand All @@ -37,11 +41,11 @@ public class CommonFixture {
protected ClientResponse response;

/**
* Initializes the common test fixture with a client component for
* Initializes the common test fixture with a client component for
* interacting with HTTP endpoints.
*
* @param testContext The test context that contains all the information for
* a test run, including suite attributes.
* a test run, including suite attributes.
*/
@BeforeClass
public void initCommonFixture(ITestContext testContext) {
Expand All @@ -66,15 +70,14 @@ public void clearMessages() {
* method wraps a static method call to facilitate unit testing (Mockito
* workaround).
*
* @param response A representation of an HTTP response message.
* @param response A representation of an HTTP response message.
* @param targetURI The target URI from which the entity was retrieved (may
* be null).
* be null).
* @return A Document representing the entity.
*
* @see ClientUtils#getResponseEntityAsDocument
*/
public Document getResponseEntityAsDocument(ClientResponse response,
String targetURI) {
String targetURI) {
return ClientUtils.getResponseEntityAsDocument(response, targetURI);
}

Expand All @@ -83,16 +86,15 @@ public Document getResponseEntityAsDocument(ClientResponse response,
* method wraps a static method call to facilitate unit testing (Mockito
* workaround).
*
* @param endpoint A URI indicating the target resource.
* @param qryParams A Map containing query parameters (may be null);
* @param endpoint A URI indicating the target resource.
* @param qryParams A Map containing query parameters (may be null);
* @param mediaTypes A list of acceptable media types; if not specified,
* generic XML ("application/xml") is preferred.
* generic XML ("application/xml") is preferred.
* @return A ClientRequest object.
*
* @see ClientUtils#buildGetRequest
*/
public ClientRequest buildGetRequest(URI endpoint,
Map<String, String> qryParams, MediaType... mediaTypes) {
Map<String, String> qryParams, MediaType... mediaTypes) {
return ClientUtils.buildGetRequest(endpoint, qryParams, mediaTypes);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package org.opengis.cite.trainingdmlai10part2.aidataquality;

import com.fasterxml.jackson.databind.JsonNode;
import com.networknt.schema.JsonSchema;
import com.networknt.schema.ValidationMessage;
import org.apache.jena.atlas.lib.NotImplemented;
import org.opengis.cite.trainingdmlai10part2.BaseJsonSchemaValidatorTest;
import org.opengis.cite.trainingdmlai10part2.CommonFixture;
import org.opengis.cite.trainingdmlai10part2.SuiteAttribute;
import org.opengis.cite.trainingdmlai10part2.util.JsonUtils;
import org.testng.Assert;
import org.testng.ITestContext;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.io.File;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class AIDataQuality extends CommonFixture {
private File testSubject;
Expand Down Expand Up @@ -38,6 +47,39 @@ public void setTestSubject(File testSubject) {

@Test(description = "Implements Abstract Test 28 (/conf/aidataquality/classbalancedegree)")
public void verifyClassBalanceDegree() {
throw new NotImplemented();
if (!testSubject.isFile()) {
Assert.assertTrue(testSubject.isFile(), "No file selected. ");
}

String schemaToApply = SCHEMA_PATH + "ai_classBalanceDegree.json";
String targetType = "AI_ClassBalanceDegree";

StringBuffer sb = new StringBuffer();

try {
BaseJsonSchemaValidatorTest tester = new BaseJsonSchemaValidatorTest();

JsonSchema schema = tester.getSchema(schemaToApply);
JsonNode rootNode = tester.getNodeFromFile(testSubject);
List<JsonNode> targetNode = JsonUtils.findNodesByType(rootNode, targetType);

try {
for (JsonNode node : targetNode) {
Set<ValidationMessage> errors = schema.validate(node);
Iterator it = errors.iterator();
while (it.hasNext()) {
sb.append("Item " + node + " has error " + it.next() + ".\n");
}
}
} catch (Exception e) {
sb.append(e.getMessage());
e.printStackTrace();
}
} catch (Exception e) {
sb.append(e.getMessage());
e.printStackTrace();
}

Assert.assertTrue(sb.toString().length() == 0, sb.toString());
}
}
Loading