Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Merge branch 'development' for 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWall89 committed Oct 16, 2019
2 parents 6a543e6 + db865b6 commit ba23a50
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
8 changes: 4 additions & 4 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>
<groupId>it.cnit.blueprint</groupId>
<artifactId>validator</artifactId>
<version>0.0.1</version>
<version>0.0.2</version>
<name>blueprint-validator</name>
<description>Simple validator for blueprints defined in 5G EVE</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
import it.nextworks.nfvmano.catalogue.blueprint.elements.CtxBlueprint;
import it.nextworks.nfvmano.catalogue.blueprint.elements.ExpBlueprint;
import it.nextworks.nfvmano.catalogue.blueprint.elements.TestCaseBlueprint;
import it.nextworks.nfvmano.catalogue.blueprint.elements.VsBlueprint;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -56,7 +57,7 @@ private static Namespace parseArguments(String[] args) {
.description("Simple tool to validate blueprints for the 5G EVE platform.");

parser.addArgument("--debug").action(Arguments.storeTrue());
parser.addArgument("-t", "--type").choices("vsb", "cb", "expb", "tstb").required(true)
parser.addArgument("-t", "--type").choices("vsb", "ctx", "expb", "tcb").required(true)
.help("Specify the type of blueprint you want to validate.");
parser.addArgument("file").help("YAML blueprint file path");

Expand All @@ -79,33 +80,43 @@ private static void validateVSB(InputStream is) throws ValidationException, IOEx
}
throw new ValidationException();
}
LOG.debug("Dump:\n{}", OBJECT_MAPPER.writeValueAsString(vsb));
}

private static void validateCB(InputStream is) throws ValidationException, IOException {
CtxBlueprint cb = OBJECT_MAPPER.readValue(is, CtxBlueprint.class);
Set<ConstraintViolation<CtxBlueprint>> violations = VALIDATOR.validate(cb);
private static void validateCtx(InputStream is) throws ValidationException, IOException {
CtxBlueprint ctx = OBJECT_MAPPER.readValue(is, CtxBlueprint.class);
Set<ConstraintViolation<CtxBlueprint>> violations = VALIDATOR.validate(ctx);
if (!violations.isEmpty()) {
for (ConstraintViolation<CtxBlueprint> v : violations) {
LOG.error("Violation: property \'{}\' {}", v.getPropertyPath(), v.getMessage());
}
throw new ValidationException();
}
LOG.debug("Dump:\n{}", OBJECT_MAPPER.writeValueAsString(ctx));
}

private static void validateExpB(InputStream is) throws ValidationException, IOException {
ExpBlueprint expB = OBJECT_MAPPER.readValue(is, ExpBlueprint.class);
Set<ConstraintViolation<ExpBlueprint>> violations = VALIDATOR.validate(expB);
ExpBlueprint expb = OBJECT_MAPPER.readValue(is, ExpBlueprint.class);
Set<ConstraintViolation<ExpBlueprint>> violations = VALIDATOR.validate(expb);
if (!violations.isEmpty()) {
for (ConstraintViolation<ExpBlueprint> v : violations) {
LOG.error("Violation: property \'{}\' {}", v.getPropertyPath(), v.getMessage());
}
throw new ValidationException();
}
LOG.debug("Dump:\n{}", OBJECT_MAPPER.writeValueAsString(expb));
}

private static void validateTstB(InputStream is) throws ValidationException, IOException {
LOG.warn("Not implemented");
throw new ValidationException();
private static void validateTcB(InputStream is) throws ValidationException, IOException {
TestCaseBlueprint tcb = OBJECT_MAPPER.readValue(is, TestCaseBlueprint.class);
Set<ConstraintViolation<TestCaseBlueprint>> violations = VALIDATOR.validate(tcb);
if (!violations.isEmpty()) {
for (ConstraintViolation<TestCaseBlueprint> v : violations) {
LOG.error("Violation: property \'{}\' {}", v.getPropertyPath(), v.getMessage());
}
throw new ValidationException();
}
LOG.debug("Dump:\n{}", OBJECT_MAPPER.writeValueAsString(tcb));
}

@Override
Expand All @@ -126,17 +137,17 @@ public void run(String... args) throws Exception {
LOG.info("Selected type: Vertical Service Blueprint");
validateVSB(is);
break;
case "cb":
case "ctx":
LOG.info("Selected type: Context Blueprint");
validateCB(is);
validateCtx(is);
break;
case "expb":
LOG.info("Selected type: Experiment Blueprint");
validateExpB(is);
break;
case "tstb":
LOG.info("Selected type: Test Blueprint");
validateTstB(is);
case "tcb":
LOG.info("Selected type: Test Case Blueprint");
validateTcB(is);
break;
}
LOG.info("Validation success");
Expand Down

0 comments on commit ba23a50

Please sign in to comment.