From fc463a460fbe621b7461477d67c12d1ab716ca0e Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Tue, 8 Oct 2019 09:50:53 +0200 Subject: [PATCH 1/5] Update version to 0.0.2-SNAPSHOT. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fa090b4..5a1dbb5 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ it.cnit.blueprint validator - 0.0.1 + 0.0.2-SNAPSHOT blueprint-validator Simple validator for blueprints defined in 5G EVE From 797c1c68ba0399bd8abd2d57a228369c9acb5bc8 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 16 Oct 2019 15:21:39 +0200 Subject: [PATCH 2/5] Update idea file with new module name. --- .idea/compiler.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index eb2359a..2ce1dbf 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -6,16 +6,16 @@ - + - + - \ No newline at end of file + From f61fd7e0de8252da12f2852c7c915585008180f2 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 16 Oct 2019 15:29:23 +0200 Subject: [PATCH 3/5] Add method for testcaseBleuprint validation. Renaming ctx. --- .../BlueprintValidatorApplication.java | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/validator/BlueprintValidatorApplication.java b/src/main/java/it/cnit/blueprint/validator/BlueprintValidatorApplication.java index 68e5408..341c011 100644 --- a/src/main/java/it/cnit/blueprint/validator/BlueprintValidatorApplication.java +++ b/src/main/java/it/cnit/blueprint/validator/BlueprintValidatorApplication.java @@ -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; @@ -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"); @@ -81,9 +82,9 @@ private static void validateVSB(InputStream is) throws ValidationException, IOEx } } - private static void validateCB(InputStream is) throws ValidationException, IOException { - CtxBlueprint cb = OBJECT_MAPPER.readValue(is, CtxBlueprint.class); - Set> violations = VALIDATOR.validate(cb); + private static void validateCtx(InputStream is) throws ValidationException, IOException { + CtxBlueprint ctx = OBJECT_MAPPER.readValue(is, CtxBlueprint.class); + Set> violations = VALIDATOR.validate(ctx); if (!violations.isEmpty()) { for (ConstraintViolation v : violations) { LOG.error("Violation: property \'{}\' {}", v.getPropertyPath(), v.getMessage()); @@ -103,9 +104,15 @@ private static void validateExpB(InputStream is) throws ValidationException, IOE } } - 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> violations = VALIDATOR.validate(tcB); + if (!violations.isEmpty()) { + for (ConstraintViolation v : violations) { + LOG.error("Violation: property \'{}\' {}", v.getPropertyPath(), v.getMessage()); + } + throw new ValidationException(); + } } @Override @@ -126,17 +133,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"); From 92fe444b1ed5f2880e12b90e4faaa556e3a9bf93 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 16 Oct 2019 15:42:46 +0200 Subject: [PATCH 4/5] Add debug line for debug. Rename some variables. --- .../validator/BlueprintValidatorApplication.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/cnit/blueprint/validator/BlueprintValidatorApplication.java b/src/main/java/it/cnit/blueprint/validator/BlueprintValidatorApplication.java index 341c011..60266e7 100644 --- a/src/main/java/it/cnit/blueprint/validator/BlueprintValidatorApplication.java +++ b/src/main/java/it/cnit/blueprint/validator/BlueprintValidatorApplication.java @@ -80,6 +80,7 @@ private static void validateVSB(InputStream is) throws ValidationException, IOEx } throw new ValidationException(); } + LOG.debug("Dump:\n{}", OBJECT_MAPPER.writeValueAsString(vsb)); } private static void validateCtx(InputStream is) throws ValidationException, IOException { @@ -91,28 +92,31 @@ private static void validateCtx(InputStream is) throws ValidationException, IOEx } 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> violations = VALIDATOR.validate(expB); + ExpBlueprint expb = OBJECT_MAPPER.readValue(is, ExpBlueprint.class); + Set> violations = VALIDATOR.validate(expb); if (!violations.isEmpty()) { for (ConstraintViolation v : violations) { LOG.error("Violation: property \'{}\' {}", v.getPropertyPath(), v.getMessage()); } throw new ValidationException(); } + LOG.debug("Dump:\n{}", OBJECT_MAPPER.writeValueAsString(expb)); } private static void validateTcB(InputStream is) throws ValidationException, IOException { - TestCaseBlueprint tcB = OBJECT_MAPPER.readValue(is, TestCaseBlueprint.class); - Set> violations = VALIDATOR.validate(tcB); + TestCaseBlueprint tcb = OBJECT_MAPPER.readValue(is, TestCaseBlueprint.class); + Set> violations = VALIDATOR.validate(tcb); if (!violations.isEmpty()) { for (ConstraintViolation v : violations) { LOG.error("Violation: property \'{}\' {}", v.getPropertyPath(), v.getMessage()); } throw new ValidationException(); } + LOG.debug("Dump:\n{}", OBJECT_MAPPER.writeValueAsString(tcb)); } @Override From db865b6793693d90fcb003f50005b69808065d68 Mon Sep 17 00:00:00 2001 From: Matteo Pergolesi Date: Wed, 16 Oct 2019 15:44:01 +0200 Subject: [PATCH 5/5] Update version to 0.0.2 for release. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5a1dbb5..851e24f 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ it.cnit.blueprint validator - 0.0.2-SNAPSHOT + 0.0.2 blueprint-validator Simple validator for blueprints defined in 5G EVE