X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Fclamp%2Fclds%2Ftosca%2Fupdate%2FToscaConverterWithDictionarySupportItCase.java;h=b5b0247c8fdb0cc8919def4015b81afb25d1c1f4;hb=536db7b811eba341aef48a745b495da068d170eb;hp=b4f8b12458deb2315f84e545542abaf957165b40;hpb=723de7f63f0951d0cfe7a23956cf9d00128809b1;p=clamp.git diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java index b4f8b124..b5b0247c 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights * reserved. - * ================================================================================ + * ================================================================================ * 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 @@ -29,20 +29,24 @@ import javax.transaction.Transactional; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.Application; +import org.onap.clamp.clds.tosca.update.execution.ToscaMetadataExecutor; import org.onap.clamp.clds.tosca.update.parser.metadata.ToscaMetadataParserWithDictionarySupport; import org.onap.clamp.clds.tosca.update.templates.JsonTemplateManager; import org.onap.clamp.clds.util.JsonUtils; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; +import org.onap.clamp.loop.service.Service; import org.onap.clamp.tosca.Dictionary; import org.onap.clamp.tosca.DictionaryElement; import org.onap.clamp.tosca.DictionaryService; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = Application.class) +@ActiveProfiles({"clamp-default","clamp-default-user","default-dictionary-elements"}) public class ToscaConverterWithDictionarySupportItCase { @Autowired @@ -51,6 +55,9 @@ public class ToscaConverterWithDictionarySupportItCase { @Autowired private ToscaMetadataParserWithDictionarySupport toscaMetadataParserWithDictionarySupport; + @Autowired + private ToscaMetadataExecutor toscaMetadataExecutor; + /** * This Test validates Tosca yaml with metadata tag that contains policy_model_type and acronym * parameters which defines the Tosca Policy name and its short name. @@ -103,16 +110,39 @@ public class ToscaConverterWithDictionarySupportItCase { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("tosca/tosca_metadata_clamp_possible_values.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils + .getResourceAsString("tosca/new-converter/tosca_metadata_clamp_possible_values.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); JsonObject jsonSchema = jsonTemplateManager.getJsonSchemaForPolicyType( - "onap.policies.monitoring.cdap.tca.hi.lo.app", toscaMetadataParserWithDictionarySupport); + "onap.policies.monitoring.cdap.tca.hi.lo.app", toscaMetadataParserWithDictionarySupport, null); JSONAssert.assertEquals( - ResourceFileUtil + ResourceFileUtils .getResourceAsString("tosca/new-converter/tca-with-metadata.json"), JsonUtils.GSON.toJson(jsonSchema), true); } + + @Test + @Transactional + public final void testMetadataClampPossibleValueWithExecutor() throws IOException, UnknownComponentException { + Service service = new Service(ResourceFileUtils.getResourceAsString("tosca/service-details.json"), + ResourceFileUtils.getResourceAsString("tosca/resource-details-cds.json")); + JsonTemplateManager jsonTemplateManager = + new JsonTemplateManager( + ResourceFileUtils.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + + ".policies.controlloop.operational.common.Apex/versions/1.0" + + ".0?connectionTimeToLive=5000/.file"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); + + JsonObject jsonSchema = jsonTemplateManager.getJsonSchemaForPolicyType( + "onap.policies.controlloop.operational.common.Apex", toscaMetadataParserWithDictionarySupport, service); + + JSONAssert.assertEquals( + ResourceFileUtils + .getResourceAsString("tosca/new-converter/tosca_apex_with_metadata.json"), + JsonUtils.GSON.toJson(jsonSchema), true); + } }