Skip to content

Commit

Permalink
fixed error messages, failing tests and renamed test environments
Browse files Browse the repository at this point in the history
  • Loading branch information
holashchand committed Sep 14, 2023
1 parent 9c6dc53 commit 5d186fd
Show file tree
Hide file tree
Showing 40 changed files with 176 additions and 132 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test: build
@docker-compose down
@rm -rf db-data* || echo "no permission to delete"
# test with distributed definition manager and native search
@docker-compose --env-file test_environments/test1.env up -d db keycloak registry certificate-signer certificate-api redis
@docker-compose --env-file test_environments/test_with_distributedDefManager_nativeSearch.env up -d db keycloak registry certificate-signer certificate-api redis
@echo "Starting the test" && sh build/wait_for_port.sh 8080
@echo "Starting the test" && sh build/wait_for_port.sh 8081
@docker-compose ps
Expand All @@ -40,7 +40,7 @@ test: build
@docker-compose down
@rm -rf db-data-1 || echo "no permission to delete"
# test with kafka(async), events, notifications,
@docker-compose --env-file test_environments/test2.env up -d db clickhouse redis es keycloak registry certificate-signer certificate-api kafka zookeeper notification-ms metrics
@docker-compose --env-file test_environments/test_with_asyncCreate_events_notifications.env up -d db clickhouse redis es keycloak registry certificate-signer certificate-api kafka zookeeper notification-ms metrics
@echo "Starting the test" && sh build/wait_for_port.sh 8080
@echo "Starting the test" && sh build/wait_for_port.sh 8081
@docker-compose ps
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "BirthCertificate16",
"schema": "{\n \"$schema\": \"http://json-schema.org/draft-07/schema\",\n \"type\": \"object\",\n \"properties\": {\n \"BirthCertificate\": {\n \"$ref\": \"#/definitions/BirthCertificate\"\n }\n },\n \"required\": [\n \"BirthCertificate\"\n ],\n \"title\": \"BirthCertificate\",\n \"definitions\": {\n \"BirthCertificate\": {\n \"$id\": \"#/properties/BirthCertificate\",\n \"type\": \"object\",\n \"title\": \"The BirthCertificate Schema\",\n \"required\": [\n \"name\",\n \"gender\",\n \"date_of_birth\",\n \"place_of_birth\",\n \"contact\"\n ],\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"gender\": {\n \"type\": \"string\"\n },\n \"date_of_birth\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n },\n \"hospital\": {\n \"type\": \"string\"\n },\n \"place_of_birth\": {\n \"type\": \"string\",\n \"enum\": [\"Bangalore\", \"Mysore\", \"Mandya\"]\n },\n \"name_of_mother\": {\n \"type\": \"string\"\n },\n \"name_of_father\": {\n \"type\": \"string\"\n },\n \"present_address\": {\n \"type\": \"string\",\n \"minLength\": 10,\n \"maxLength\": 50\n },\n \"contact\": {\n \"type\": \"string\"\n }\n }\n }\n },\n \"_osConfig\": {\n \"uniqueIndexFields\": [\n \"contact\"\n ],\n \"ownershipAttributes\": [],\n \"roles\": [],\n \"inviteRoles\": [\n \"anonymous\"\n ],\n \"credentialTemplate\": {\n \"@context\": [\n \"https://www.w3.org/2018/credentials/v1\",\n {\n \"@context\": {\n \"@version\": 1.1,\n \"@protected\": true,\n \"BirthCertificate\": {\n \"@id\": \"https://github.com/sunbird-specs/vc-specs#BirthCertificate\",\n \"@context\": {\n \"id\": \"@id\",\n \"@version\": 1.1,\n \"@protected\": true,\n \"skills\": \"schema:Text\",\n \"name\": \"schema:Text\",\n \"gender\": \"schema:Text\",\n \"date_of_birth\": \"schema:Text\",\n \"hospital\": \"schema:Text\",\n \"place_of_birth\": \"schema:Text\",\n \"name_of_mother\": \"schema:Text\",\n \"name_of_father\": \"schema:Text\",\n \"present_address\": \"schema:Text\",\n \"contact\": \"schema:Text\"\n }\n }\n }\n }\n ],\n \"type\": [\n \"VerifiableCredential\"\n ],\n \"issuanceDate\": \"2021-08-27T10:57:57.237Z\",\n \"credentialSubject\": {\n \"type\": \"BirthCertificate\",\n \"name\": \"{{name}}\",\n \"gender\": \"{{gender}}\",\n \"date_of_birth\": \"{{date_of_birth}}\",\n \"hospital\": \"{{hospital}}\",\n \"place_of_birth\": \"{{place_of_birth}}\",\n \"name_of_mother\": \"{{name_of_mother}}\",\n \"name_of_father\": \"{{name_of_father}}\",\n \"present_address\": \"{{present_address}}\",\n \"contact\": \"{{contact}}\"\n },\n \"issuer\": \"did:web:sunbirdrc.dev/vc/BirthCertificate\"\n },\n \"certificateTemplates\": {\n \"html\": \"https://gist.githubusercontent.com/tejash-jl/56b97ffcb99f93e2e1ec49e88c0c2c7f/raw/1242b9af7f58b9d5ca1e4f11d442aa4815598a31/BirthCertificate.html\"\n }\n }\n}",
"schema": "{\n \"$schema\": \"http://json-schema.org/draft-07/schema\",\n \"type\": \"object\",\n \"properties\": {\n \"BirthCertificate\": {\n \"$ref\": \"#/definitions/BirthCertificate\"\n }\n },\n \"required\": [\n \"BirthCertificate\"\n ],\n \"title\": \"BirthCertificate\",\n \"definitions\": {\n \"BirthCertificate\": {\n \"$id\": \"#/properties/BirthCertificate\",\n \"type\": \"object\",\n \"title\": \"The BirthCertificate Schema\",\n \"required\": [\n \"name\",\n \"gender\",\n \"date_of_birth\",\n \"place_of_birth\",\n \"contact\"\n ],\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"gender\": {\n \"type\": \"string\"\n },\n \"date_of_birth\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n },\n \"hospital\": {\n \"type\": \"string\"\n },\n \"place_of_birth\": {\n \"type\": \"string\",\n \"enum\": [\"Bangalore\", \"Mysore\", \"Mandya\"]\n },\n \"name_of_mother\": {\n \"type\": \"string\"\n },\n \"name_of_father\": {\n \"type\": \"string\"\n },\n \"present_address\": {\n \"type\": \"string\",\n \"minLength\": 10,\n \"maxLength\": 50\n },\n \"contact\": {\n \"type\": \"string\"\n }\n }\n }\n },\n \"_osConfig\": {\n \"uniqueIndexFields\": [\n \"contact\"\n ],\n \"ownershipAttributes\": [],\n \"roles\": [],\n \"inviteRoles\": [\n \"anonymous\"\n ],\n \"credentialTemplate\": {\n \"@context\": [\n \"https://www.w3.org/2018/credentials/v1\",\n {\n \"@context\": {\n \"@version\": 1.1,\n \"@protected\": true,\n \"BirthCertificate\": {\n \"@id\": \"https://github.com/sunbird-specs/vc-specs#BirthCertificate\",\n \"@context\": {\n \"id\": \"@id\",\n \"@version\": 1.1,\n \"@protected\": true,\n \"skills\": \"schema:Text\",\n \"name\": \"schema:Text\",\n \"gender\": \"schema:Text\",\n \"date_of_birth\": \"schema:Text\",\n \"hospital\": \"schema:Text\",\n \"place_of_birth\": \"schema:Text\",\n \"name_of_mother\": \"schema:Text\",\n \"name_of_father\": \"schema:Text\",\n \"present_address\": \"schema:Text\",\n \"contact\": \"schema:Text\"\n }\n }\n }\n }\n ],\n \"type\": [\n \"VerifiableCredential\"\n ],\n \"issuanceDate\": \"2021-08-27T10:57:57.237Z\",\n \"credentialSubject\": {\n \"type\": \"BirthCertificate\",\n \"name\": \"{{name}}\",\n \"gender\": \"{{gender}}\",\n \"date_of_birth\": \"{{date_of_birth}}\",\n \"hospital\": \"{{hospital}}\",\n \"place_of_birth\": \"{{place_of_birth}}\",\n \"name_of_mother\": \"{{name_of_mother}}\",\n \"name_of_father\": \"{{name_of_father}}\",\n \"present_address\": \"{{present_address}}\",\n \"contact\": \"{{contact}}\"\n },\n \"issuer\": \"did:web:sunbirdrc.dev/vc/BirthCertificate\"\n },\n \"certificateTemplates\": {\n \"html\": \"https://gist.githubusercontent.com/holashchand/03785ec73f278f955c2dec749afc9e76/raw/b18edeca22980dd388d498e12cb1223e3d6c3a49/BirthCertificate.html\"\n }\n }\n}",
"status": "PUBLISHED"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "BirthCertificate139",
"schema": "{\n \"$schema\": \"http://json-schema.org/draft-07/schema\",\n \"type\": \"object\",\n \"properties\": {\n \"BirthCertificate1\": {\n \"$ref\": \"#/definitions/BirthCertificate1\"\n }\n },\n \"required\": [\n \"BirthCertificate1\"\n ],\n \"title\": \"BirthCertificate1\",\n \"definitions\": {\n \"BirthCertificate1\": {\n \"$id\": \"#/properties/BirthCertificate1\",\n \"type\": \"object\",\n \"title\": \"The BirthCertificate1 Schema\",\n \"required\": [\n \"name\",\n \"gender\",\n \"date_of_birth\",\n \"place_of_birth\",\n \"contact\"\n ],\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"gender\": {\n \"type\": \"string\"\n },\n \"date_of_birth\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n },\n \"hospital\": {\n \"type\": \"string\"\n },\n \"place_of_birth\": {\n \"type\": \"string\",\n \"enum\": [\"Bangalore\", \"Mysore\", \"Mandya\"]\n },\n \"name_of_mother\": {\n \"type\": \"string\"\n },\n \"name_of_father\": {\n \"type\": \"string\"\n },\n \"present_address\": {\n \"type\": \"string\",\n \"minLength\": 10,\n \"maxLength\": 50\n },\n \"contact\": {\n \"type\": \"string\"\n }\n }\n }\n },\n \"_osConfig\": {\n \"uniqueIndexFields\": [\n \"contact\"\n ],\n \"ownershipAttributes\": [],\n \"roles\": [],\n \"inviteRoles\": [\n \"anonymous\"\n ],\n \"credentialTemplate\": {\n \"@context\": [\n \"https://www.w3.org/2018/credentials/v1\",\n {\n \"@context\": {\n \"@version\": 1.1,\n \"@protected\": true,\n \"BirthCertificate1\": {\n \"@id\": \"https://github.com/sunbird-specs/vc-specs#BirthCertificate1\",\n \"@context\": {\n \"id\": \"@id\",\n \"@version\": 1.1,\n \"@protected\": true,\n \"skills\": \"schema:Text\",\n \"name\": \"schema:Text\",\n \"gender\": \"schema:Text\",\n \"date_of_birth\": \"schema:Text\",\n \"hospital\": \"schema:Text\",\n \"place_of_birth\": \"schema:Text\",\n \"name_of_mother\": \"schema:Text\",\n \"name_of_father\": \"schema:Text\",\n \"present_address\": \"schema:Text\",\n \"contact\": \"schema:Text\"\n }\n }\n }\n }\n ],\n \"type\": [\n \"VerifiableCredential\"\n ],\n \"issuanceDate\": \"2021-08-27T10:57:57.237Z\",\n \"credentialSubject\": {\n \"type\": \"BirthCertificate1\",\n \"name\": \"{{name}}\",\n \"gender\": \"{{gender}}\",\n \"date_of_birth\": \"{{date_of_birth}}\",\n \"hospital\": \"{{hospital}}\",\n \"place_of_birth\": \"{{place_of_birth}}\",\n \"name_of_mother\": \"{{name_of_mother}}\",\n \"name_of_father\": \"{{name_of_father}}\",\n \"present_address\": \"{{present_address}}\",\n \"contact\": \"{{contact}}\"\n },\n \"issuer\": \"did:web:sunbirdrc.dev/vc/BirthCertificate1\"\n },\n \"certificateTemplates\": {\n \"html\": \"https://gist.githubusercontent.com/tejash-jl/56b97ffcb99f93e2e1ec49e88c0c2c7f/raw/1242b9af7f58b9d5ca1e4f11d442aa4815598a31/BirthCertificate1.html\"\n }\n }\n}",
"schema": "{\n \"$schema\": \"http://json-schema.org/draft-07/schema\",\n \"type\": \"object\",\n \"properties\": {\n \"BirthCertificate1\": {\n \"$ref\": \"#/definitions/BirthCertificate1\"\n }\n },\n \"required\": [\n \"BirthCertificate1\"\n ],\n \"title\": \"BirthCertificate1\",\n \"definitions\": {\n \"BirthCertificate1\": {\n \"$id\": \"#/properties/BirthCertificate1\",\n \"type\": \"object\",\n \"title\": \"The BirthCertificate1 Schema\",\n \"required\": [\n \"name\",\n \"gender\",\n \"date_of_birth\",\n \"place_of_birth\",\n \"contact\"\n ],\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"gender\": {\n \"type\": \"string\"\n },\n \"date_of_birth\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n },\n \"hospital\": {\n \"type\": \"string\"\n },\n \"place_of_birth\": {\n \"type\": \"string\",\n \"enum\": [\"Bangalore\", \"Mysore\", \"Mandya\"]\n },\n \"name_of_mother\": {\n \"type\": \"string\"\n },\n \"name_of_father\": {\n \"type\": \"string\"\n },\n \"present_address\": {\n \"type\": \"string\",\n \"minLength\": 10,\n \"maxLength\": 50\n },\n \"contact\": {\n \"type\": \"string\"\n }\n }\n }\n },\n \"_osConfig\": {\n \"uniqueIndexFields\": [\n \"contact\"\n ],\n \"ownershipAttributes\": [],\n \"roles\": [],\n \"inviteRoles\": [\n \"anonymous\"\n ],\n \"credentialTemplate\": {\n \"@context\": [\n \"https://www.w3.org/2018/credentials/v1\",\n {\n \"@context\": {\n \"@version\": 1.1,\n \"@protected\": true,\n \"BirthCertificate1\": {\n \"@id\": \"https://github.com/sunbird-specs/vc-specs#BirthCertificate1\",\n \"@context\": {\n \"id\": \"@id\",\n \"@version\": 1.1,\n \"@protected\": true,\n \"skills\": \"schema:Text\",\n \"name\": \"schema:Text\",\n \"gender\": \"schema:Text\",\n \"date_of_birth\": \"schema:Text\",\n \"hospital\": \"schema:Text\",\n \"place_of_birth\": \"schema:Text\",\n \"name_of_mother\": \"schema:Text\",\n \"name_of_father\": \"schema:Text\",\n \"present_address\": \"schema:Text\",\n \"contact\": \"schema:Text\"\n }\n }\n }\n }\n ],\n \"type\": [\n \"VerifiableCredential\"\n ],\n \"issuanceDate\": \"2021-08-27T10:57:57.237Z\",\n \"credentialSubject\": {\n \"type\": \"BirthCertificate1\",\n \"name\": \"{{name}}\",\n \"gender\": \"{{gender}}\",\n \"date_of_birth\": \"{{date_of_birth}}\",\n \"hospital\": \"{{hospital}}\",\n \"place_of_birth\": \"{{place_of_birth}}\",\n \"name_of_mother\": \"{{name_of_mother}}\",\n \"name_of_father\": \"{{name_of_father}}\",\n \"present_address\": \"{{present_address}}\",\n \"contact\": \"{{contact}}\"\n },\n \"issuer\": \"did:web:sunbirdrc.dev/vc/BirthCertificate1\"\n },\n \"certificateTemplates\": {\n \"html\": \"https://gist.githubusercontent.com/holashchand/03785ec73f278f955c2dec749afc9e76/raw/b18edeca22980dd388d498e12cb1223e3d6c3a49/BirthCertificate.html\"\n }\n }\n}",
"status": "PUBLISHED"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import dev.sunbirdrc.registry.middleware.util.Constants.JsonldConstants;
import dev.sunbirdrc.registry.middleware.util.JSONUtil;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -46,9 +47,9 @@ public Data<Object> transform(Data<Object> data) throws TransformationException
// Insert context to the result
resultNode.setAll(contextNode);
return new Data<>(resultNode);
} catch (Exception ex) {
logger.error("Error trnsx : " + ex.getMessage(), ex);
throw new TransformationException(ex.getMessage(), ex, ErrorCode.JSON_TO_JSONLD_TRANFORMATION_ERROR);
} catch (Exception e) {
logger.error("Error trnsx : {}", ExceptionUtils.getStackTrace(e));
throw new TransformationException(e.getMessage(), e, ErrorCode.JSON_TO_JSONLD_TRANFORMATION_ERROR);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import dev.sunbirdrc.registry.middleware.util.Constants.JsonldConstants;
import dev.sunbirdrc.registry.middleware.util.JSONUtil;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -28,9 +29,9 @@ public Data<Object> transform(Data<Object> data) throws TransformationException
ObjectNode input = (ObjectNode) mapper.readTree(data.getData().toString());
JsonNode jsonNode = getconstructedJson(input, keysToPurge);
return new Data<>(jsonNode);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
throw new TransformationException(ex.getMessage(), ex, ErrorCode.JSONLD_TO_JSON_TRANFORMATION_ERROR);
} catch (Exception e) {
logger.error(ExceptionUtils.getStackTrace(e));
throw new TransformationException(e.getMessage(), e, ErrorCode.JSONLD_TO_JSON_TRANFORMATION_ERROR);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -47,7 +48,8 @@ public void shouldReturnTrueForValidExpression() throws IOException {
try {
resolve = conditionResolverService.resolve(getStudentJsonNode(), requester, condition, attributes);
} catch (IOException e) {
logger.info("Exception occurred: {}", e.getMessage());
logger.error("Exception occurred: {}", ExceptionUtils.getStackTrace(e));
throw e;
}
String attestor = "ATTESTOR";
resolve = conditionResolverService.resolve(getTeacherJsonNode(), attestor, resolve, attributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import dev.sunbirdrc.pojos.AuditRecord;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -122,7 +123,7 @@ public void removeNode() {
// public void findKey() {
// }

private String getContent(String fileName) {
private String getContent(String fileName) throws IOException {
InputStream in;
try {
in = this.getClass().getClassLoader().getResourceAsStream(fileName);
Expand All @@ -135,9 +136,9 @@ private String getContent(String fileName) {
return result.toString(StandardCharsets.UTF_8.name());

} catch (IOException e) {
logger.info("Exception occurred: {}", e.getMessage());
logger.error("Exception occurred: {}", ExceptionUtils.getStackTrace(e));
throw e;
}
return null;
}

@Test
Expand Down
Loading

0 comments on commit 5d186fd

Please sign in to comment.