4b1deb374180e8d158fe38db796bd9c893d0b974
[sdc.git] /
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.activityspec.mocks;
18
19 import org.openecomp.sdc.versioning.VersioningManager;
20 import org.openecomp.sdc.versioning.dao.types.Revision;
21 import org.openecomp.sdc.versioning.dao.types.Version;
22 import org.openecomp.sdc.versioning.dao.types.VersionStatus;
23 import org.openecomp.sdc.versioning.types.VersionCreationMethod;
24
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.UUID;
28
29 import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Certified;
30 import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Deprecated;
31 import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Deleted;
32
33 public class VersionManagerMock implements VersioningManager {
34
35   private String id;
36   private Version version;
37
38
39   @Override
40   public List<Version> list(String itemId) {
41     List<Version> versions = new ArrayList<Version>();
42     versions.add(version);
43     return versions;
44   }
45
46
47   @Override
48   public Version get(String itemId, Version version) {
49     return this.version;
50   }
51
52   @Override
53   public Version create(String itemId, Version version, VersionCreationMethod creationMethod) {
54     this.id = UUID.randomUUID().toString();
55     version.setId(this.id);
56     version.setStatus(VersionStatus.Draft);
57     this.version = version;
58
59     return version;
60   }
61
62   @Override
63   public void submit(String itemId, Version version, String submitDescription) {
64
65   }
66
67
68   @Override
69   public void publish(String itemId, Version version, String message) {
70
71   }
72
73   @Override
74   public void sync(String itemId, Version version) {
75
76   }
77
78   @Override
79   public void forceSync(String itemId, Version version) {
80
81   }
82
83   @Override
84   public void revert(String itemId, Version version, String revisionId) {
85
86   }
87
88   @Override
89   public List<Revision> listRevisions(String itemId, Version version) {
90     return null;
91   }
92
93   @Override
94   public void updateVersion(String itemId, Version version) {
95     if (version.getStatus() == Certified) {
96       this.version.setStatus(Certified);
97     }
98     if (version.getStatus() == Deprecated) {
99       this.version.setStatus(Deprecated);
100     }
101     if (version.getStatus() == Deleted) {
102       this.version.setStatus(Deleted);
103     }
104   }
105 }