ActivitySpec - Correcting logger messages
[sdc.git] / common / openecomp-sdc-artifact-generator-lib / openecomp-sdc-artifact-generator-core / src / main / java / org / openecomp / sdc / generator / MockArtifactGenerator.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.generator;
22
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;
30
31 import java.util.Date;
32 import java.util.List;
33 import java.util.Map;
34
35 @Generator(artifactType = ArtifactType.OTHER)
36 public class MockArtifactGenerator implements ArtifactGenerator {
37
38   @Override
39   public GenerationData generateArtifact(List<Artifact> input,
40                                          Map<String, String> additionalParams) {
41     final GenerationData data = new GenerationData();
42
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();
49
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");
56
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");
63
64     data.add(staticArtifactModel);
65     data.add(dynamicArtifactModel);
66
67     return data;
68
69   }
70
71   private String getStaticArtifact() {
72     return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><theObj><name>Hi I'm Static</name></theObj>";
73   }
74
75   private String getDynamicArtifact() {
76     return
77         "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><theObj><name>Hi I'm Static</name><timestamp>"
78             + new Date() + "</timestamp></theObj>";
79   }
80
81 }