Improve test coverage
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / auditing / impl / resourceadmin / AuditResourceAdminEventFactory.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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 package org.openecomp.sdc.be.auditing.impl.resourceadmin;
21
22 import org.openecomp.sdc.be.auditing.impl.AuditBaseEventFactory;
23 import org.openecomp.sdc.be.model.User;
24 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
25 import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
26 import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent;
27 import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
28 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
29 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
30
31 public abstract class AuditResourceAdminEventFactory extends AuditBaseEventFactory {
32
33     protected final ResourceAdminEvent event;
34
35     AuditResourceAdminEventFactory(AuditingActionEnum action, CommonAuditData commonFields, ResourceCommonInfo resourceCommonInfo,
36                                    ResourceVersionInfo prevParams, ResourceVersionInfo currParams, String invariantUuid, User modifier,
37                                    String artifactData, String comment, String did, String toscaNodeType) {
38         this(action, commonFields, resourceCommonInfo, prevParams, currParams, invariantUuid, AuditBaseEventFactory.buildUserName(modifier),
39             artifactData, AuditBaseEventFactory.replaceNullNameWithEmpty(comment), did, toscaNodeType);
40     }
41
42     AuditResourceAdminEventFactory(AuditingActionEnum action, CommonAuditData commonFields, ResourceCommonInfo resourceCommonInfo,
43                                    ResourceVersionInfo prevParams, ResourceVersionInfo currParams, String invariantUuid, String modifier,
44                                    String artifactData, String comment, String did, String toscaNodeType, String timestamp) {
45         this(action, commonFields, resourceCommonInfo, prevParams, currParams, invariantUuid, modifier, artifactData, comment, did, toscaNodeType);
46         this.event.setTimestamp1(timestamp);
47     }
48
49     private AuditResourceAdminEventFactory(AuditingActionEnum action, CommonAuditData commonFields, ResourceCommonInfo resourceCommonInfo,
50                                            ResourceVersionInfo prevParams, ResourceVersionInfo currParams, String invariantUuid, String modifier,
51                                            String artifactData, String comment, String did, String toscaNodeType) {
52         super(action);
53         this.event = new ResourceAdminEvent(getAction().getName(), commonFields, resourceCommonInfo, prevParams, currParams, invariantUuid, modifier,
54             artifactData, comment, did, toscaNodeType);
55     }
56
57     @Override
58     public AuditingGenericEvent getDbEvent() {
59         return event;
60     }
61 }