TCA: Replace any openecomp reference by onap
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-tca / src / test / java / org / onap / dcae / apod / analytics / cdap / tca / flow / TCAVESCollectorFlowTest.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
4  * ================================================================================
5  *    Copyright © 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.onap.dcae.apod.analytics.cdap.tca.flow;
22
23 import co.cask.cdap.AllProgramsApp;
24 import co.cask.cdap.api.flow.FlowletConnection;
25 import co.cask.cdap.api.flow.FlowletDefinition;
26 import co.cask.cdap.internal.app.runtime.flow.DefaultFlowConfigurer;
27 import org.junit.Test;
28 import org.onap.dcae.apod.analytics.cdap.common.CDAPComponentsConstants;
29 import org.onap.dcae.apod.analytics.cdap.tca.BaseAnalyticsCDAPTCAUnitTest;
30
31 import java.util.ArrayList;
32 import java.util.HashMap;
33 import java.util.List;
34 import java.util.Map;
35
36 import static org.hamcrest.CoreMatchers.is;
37 import static org.hamcrest.Matchers.containsInAnyOrder;
38 import static org.junit.Assert.assertThat;
39
40 /**
41  * @author Rajiv Singla . Creation Date: 1/12/2017.
42  */
43 public class TCAVESCollectorFlowTest extends BaseAnalyticsCDAPTCAUnitTest {
44
45     @Test
46     @SuppressWarnings("unchecked")
47     public void testConfigure() throws Exception {
48
49         final TCAVESCollectorFlow tcavesCollectorFlow = new TCAVESCollectorFlow(getTCATestAppConfig());
50         final DefaultFlowConfigurer configurer = new DefaultFlowConfigurer(new AllProgramsApp.NoOpFlow());
51         tcavesCollectorFlow.configure(configurer);
52         final String flowName = getPrivateFiledValue(configurer, "name", String.class);
53         final String flowDescription = getPrivateFiledValue(configurer, "description", String.class);
54
55         assertThat("TCAVESCollectorFlow Name must match with what is defined in CDAPComponents Constants",
56                 flowName, is(CDAPComponentsConstants.TCA_FIXED_VES_COLLECTOR_NAME_FLOW));
57
58         assertThat("TCAVESCollectorFlow Description must match with what is defined in CDAPComponents Constants",
59                 flowDescription, is(CDAPComponentsConstants.TCA_FIXED_VES_COLLECTOR_DESCRIPTION_FLOW));
60
61         final Map<String, FlowletDefinition> flowlets =
62                 (Map<String, FlowletDefinition>) getPrivateFiledValue(configurer, "flowlets", HashMap.class);
63
64         assertThat("TCAVESCollector must contain all TCA VES flowlets", flowlets.keySet(),
65                 containsInAnyOrder(CDAPComponentsConstants.TCA_FIXED_VES_MESSAGE_ROUTER_NAME_FLOWLET,
66                         CDAPComponentsConstants.TCA_FIXED_VES_THRESHOLD_VIOLATION_CALCULATOR_NAME_FLOWLET,
67                         CDAPComponentsConstants.TCA_FIXED_VES_ALERTS_ABATEMENT_NAME_FLOWLET,
68                         CDAPComponentsConstants.TCA_FIXED_VES_AAI_ENRICHMENT_NAME_FLOWLET,
69                         CDAPComponentsConstants.TCA_FIXED_VES_ALERTS_SINK_NAME_FLOWLET));
70
71         final List<FlowletConnection> connections =
72                 (List<FlowletConnection>) getPrivateFiledValue(configurer, "connections", ArrayList.class);
73
74         assertThat("There must be four connections in VES Collector Flow", connections.size(), is(5));
75
76     }
77
78
79 }