* ================================================================================
* 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
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
@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.
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);
+ }
}