1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/*-
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
* Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
* Modifications copyright (c) 2019 Nokia
* ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
import static org.junit.Assert.assertEquals;
import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import org.junit.Test;
import org.onap.sdc.gab.model.GABQuery;
import org.onap.sdc.gab.model.GABQuery.GABQueryType;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
public class GenericArtifactBrowserBusinessLogicTest extends BaseBusinessLogicMock {
private static String content = "event: {presence: required, action: [ any, any, alarm003,RECO-rebuildVnf ],\n"
+ " structure: {\n"
+ " commonEventHeader: {presence: required, structure: {\n"
+ " domain: {presence: required, value: fault},\n"
+ " eventName: {presence: required, value: Fault\\_vMrf\\_alarm003},\n"
+ " eventId: {presence: required},\n"
+ " nfNamingCode: {value: mrfx},\n"
+ " priority: {presence: required, value: Medium},\n"
+ " reportingEntityId: {presence: required},\n"
+ " reportingEntityName: {presence: required},\n"
+ " sequence: {presence: required},\n"
+ " sourceId: {presence: required},\n"
+ " sourceName: {presence: required},\n"
+ " startEpochMicrosec: {presence: required},\n"
+ " lastEpochMicrosec: {presence: required},\n"
+ " version: {presence: required, value: 3.0}\n"
+ " }},\n"
+ " faultFields: {presence: required, structure: {\n"
+ " alarmCondition: {presence: required, value: alarm003},\n"
+ " eventSeverity: {presence: required, value: MAJOR},\n"
+ " eventSourceType: {presence: required, value: virtualNetworkFunction},\n"
+ " faultFieldsVersion: {presence: required, value: 2.0},\n"
+ " specificProblem: {presence: required, value: \"Configuration file was\n"
+ " corrupt or not present\"},\n"
+ " vfStatus: {presence: required, value: \"Requesting Termination\"}\n"
+ " }}\n"
+ " }}\n"
+ "---\n"
+ "# registration for clearing Fault\\_vMrf\\_alarm003Cleared\n"
+ "# Constants: the values of domain, eventName, priority,\n"
+ "# , version, alarmCondition, eventSeverity, eventSourceType,\n"
+ "# faultFieldsVersion, specificProblem,\n"
+ "# Variables (to be supplied at runtime) include: eventId,lastEpochMicrosec,\n"
+ "# reportingEntityId, reportingEntityName, sequence, sourceId,\n"
+ "# sourceName, startEpochMicrosec, vfStatus\n"
+ "event: {presence: required, action: [ any, any, alarm003, Clear ], structure: {\n"
+ " commonEventHeader: {presence: required, structure: {\n"
+ " domain: {presence: required, value: fault},\n"
+ " eventName: {presence: required, value: Fault\\_vMrf\\_alarm003Cleared},\n"
+ " eventId: {presence: required},\n"
+ " nfNamingCode: {value: mrfx},\n"
+ " priority: {presence: required, value: Medium},\n"
+ " reportingEntityId: {presence: required},\n"
+ " reportingEntityName: {presence: required},\n"
+ " sequence: {presence: required},\n"
+ " sourceId: {presence: required},\n"
+ " sourceName: {presence: required},\n"
+ " startEpochMicrosec: {presence: required},\n"
+ " lastEpochMicrosec: {presence: required},\n"
+ " version: {presence: required, value: 3.0}\n"
+ " }},\n"
+ " faultFields: {presence: required, structure: {\n"
+ " alarmCondition: {presence: required, value: alarm003},\n"
+ " eventSeverity: {presence: required, value: NORMAL},\n"
+ " eventSourceType: {presence: required, value: virtualNetworkFunction},\n"
+ " faultFieldsVersion: {presence: required, value: 2.0},\n"
+ " specificProblem: {presence: required, value: \"Valid configuration file found\"},\n"
+ " vfStatus: {presence: required, value: \"Requesting Termination\"}\n"
+ " }}\n"
+ "}}";
private static String expectedResult = "{\n"
+ " \"data\": [\n"
+ " {\n"
+ " \"event.presence\": \"required\",\n"
+ " \"event.action[0]\": \"any\"\n"
+ " },\n"
+ " {\n"
+ " \"event.presence\": \"required\",\n"
+ " \"event.action[0]\": \"any\"\n"
+ " }\n"
+ " ]\n"
+ "}";
@Test
public void testShouldCorrectlyParseResponse() throws IOException {
GenericArtifactBrowserBusinessLogic genericArtifactBrowserBusinessLogic = new GenericArtifactBrowserBusinessLogic(
elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation);
String result = genericArtifactBrowserBusinessLogic.searchFor(
new GABQuery(ImmutableSet.of("event.presence", "event.action[0]"),
content, GABQueryType.CONTENT));
assertEquals(result, expectedResult);
}
}
|