2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.generator;
23 import org.openecomp.sdc.generator.data.Artifact;
24 import org.openecomp.sdc.generator.data.ArtifactType;
25 import org.openecomp.sdc.generator.data.GenerationData;
26 import org.openecomp.sdc.generator.data.GeneratorUtil;
27 import org.openecomp.sdc.generator.data.GroupType;
28 import org.openecomp.sdc.generator.intf.ArtifactGenerator;
29 import org.openecomp.sdc.generator.intf.Generator;
31 import java.util.Date;
32 import java.util.List;
35 @Generator(artifactType = ArtifactType.OTHER)
36 public class MockArtifactGenerator implements ArtifactGenerator {
39 public GenerationData generateArtifact(List<Artifact> input,
40 Map<String, String> additionalParams) {
41 final GenerationData data = new GenerationData();
43 String staticArtifactName = "MOCK_Generator-Static-Artifact.xml";
44 String staticArtifactLabel = "MOCK-Generator-Static-Artifact";
45 final String dynamicArtifactName = "MOCK_Generator-Dynamic-Artifact.xml";
46 final String dynamicArtifactLabel = "MOCK-Generator-Dynamic-Artifact";
47 String staticArtifact = getStaticArtifact();
48 String dynamicArtifact = getDynamicArtifact();
50 Artifact staticArtifactModel = new Artifact(ArtifactType.OTHER.name(), GroupType.OTHER.name(),
51 GeneratorUtil.checkSum(staticArtifact.getBytes()),
52 GeneratorUtil.encode(staticArtifact.getBytes()));
53 staticArtifactModel.setName(staticArtifactName);
54 staticArtifactModel.setLabel(staticArtifactLabel);
55 staticArtifactModel.setDescription("Mock Generator");
57 Artifact dynamicArtifactModel = new Artifact(ArtifactType.OTHER.name(), GroupType.OTHER.name(),
58 GeneratorUtil.checkSum(dynamicArtifact.getBytes()),
59 GeneratorUtil.encode(dynamicArtifact.getBytes()));
60 dynamicArtifactModel.setName(dynamicArtifactName);
61 dynamicArtifactModel.setLabel(dynamicArtifactLabel);
62 dynamicArtifactModel.setDescription("Mock Generator");
64 data.add(staticArtifactModel);
65 data.add(dynamicArtifactModel);
71 private String getStaticArtifact() {
72 return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><theObj><name>Hi I'm Static</name></theObj>";
75 private String getDynamicArtifact() {
77 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><theObj><name>Hi I'm Static</name><timestamp>"
78 + new Date() + "</timestamp></theObj>";