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.onap.sdc.generator;
23 import org.onap.sdc.generator.data.*;
24 import org.onap.sdc.generator.intf.ArtifactGenerator;
25 import org.onap.sdc.generator.intf.Generator;
27 import java.util.Date;
28 import java.util.List;
31 @Generator(artifactType = ArtifactType.OTHER)
32 public class MockArtifactGenerator implements ArtifactGenerator {
35 public GenerationData generateArtifact(List<Artifact> input,
36 Map<String, String> additionalParams) {
37 final GenerationData data = new GenerationData();
39 String staticArtifactName = "MOCK_Generator-Static-Artifact.xml";
40 String staticArtifactLabel = "MOCK-Generator-Static-Artifact";
41 final String dynamicArtifactName = "MOCK_Generator-Dynamic-Artifact.xml";
42 final String dynamicArtifactLabel = "MOCK-Generator-Dynamic-Artifact";
43 String staticArtifact = getStaticArtifact();
44 String dynamicArtifact = getDynamicArtifact();
46 Artifact staticArtifactModel = new Artifact(ArtifactType.OTHER.name(), GroupType.OTHER.name(),
47 GeneratorUtil.checkSum(staticArtifact.getBytes()),
48 GeneratorUtil.encode(staticArtifact.getBytes()));
49 staticArtifactModel.setName(staticArtifactName);
50 staticArtifactModel.setLabel(staticArtifactLabel);
51 staticArtifactModel.setDescription("Mock Generator");
53 Artifact dynamicArtifactModel = new Artifact(ArtifactType.OTHER.name(), GroupType.OTHER.name(),
54 GeneratorUtil.checkSum(dynamicArtifact.getBytes()),
55 GeneratorUtil.encode(dynamicArtifact.getBytes()));
56 dynamicArtifactModel.setName(dynamicArtifactName);
57 dynamicArtifactModel.setLabel(dynamicArtifactLabel);
58 dynamicArtifactModel.setDescription("Mock Generator");
60 data.add(staticArtifactModel);
61 data.add(dynamicArtifactModel);
67 private String getStaticArtifact() {
68 return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><theObj><name>Hi I'm Static</name></theObj>";
71 private String getDynamicArtifact() {
73 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><theObj><name>Hi I'm Static</name><timestamp>"
74 + new Date() + "</timestamp></theObj>";