2 * ===============================LICENSE_START======================================
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
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.openecomp.dcae.apod.analytics.cdap.tca.flow;
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.openecomp.dcae.apod.analytics.cdap.common.CDAPComponentsConstants;
29 import org.openecomp.dcae.apod.analytics.cdap.tca.BaseAnalyticsCDAPTCAUnitTest;
31 import java.util.ArrayList;
32 import java.util.HashMap;
33 import java.util.List;
36 import static org.hamcrest.CoreMatchers.is;
37 import static org.hamcrest.Matchers.containsInAnyOrder;
38 import static org.junit.Assert.assertThat;
41 * @author Rajiv Singla . Creation Date: 1/12/2017.
43 public class TCAVESCollectorFlowTest extends BaseAnalyticsCDAPTCAUnitTest {
46 public void testConfigure() throws Exception {
48 final TCAVESCollectorFlow tcavesCollectorFlow = new TCAVESCollectorFlow(getTCATestAppConfig());
49 final DefaultFlowConfigurer configurer = new DefaultFlowConfigurer(new AllProgramsApp.NoOpFlow());
50 tcavesCollectorFlow.configure(configurer);
51 final String flowName = getPrivateFiledValue(configurer, "name", String.class);
52 final String flowDescription = getPrivateFiledValue(configurer, "description", String.class);
54 assertThat("TCAVESCollectorFlow Name must match with what is defined in CDAPComponents Constants",
55 flowName, is(CDAPComponentsConstants.TCA_FIXED_VES_COLLECTOR_NAME_FLOW));
57 assertThat("TCAVESCollectorFlow Description must match with what is defined in CDAPComponents Constants",
58 flowDescription, is(CDAPComponentsConstants.TCA_FIXED_VES_COLLECTOR_DESCRIPTION_FLOW));
60 final Map<String, FlowletDefinition> flowlets =
61 (Map<String, FlowletDefinition>) getPrivateFiledValue(configurer, "flowlets", HashMap.class);
63 assertThat("TCAVESCollector must contain all TCA VES flowlets", flowlets.keySet(),
64 containsInAnyOrder(CDAPComponentsConstants.TCA_FIXED_VES_MESSAGE_ROUTER_NAME_FLOWLET,
65 CDAPComponentsConstants.TCA_FIXED_VES_THRESHOLD_VIOLATION_CALCULATOR_NAME_FLOWLET,
66 CDAPComponentsConstants.TCA_FIXED_VES_ALERTS_SINK_NAME_FLOWLET));
68 final List<FlowletConnection> connections =
69 (List<FlowletConnection>) getPrivateFiledValue(configurer, "connections", ArrayList.class);
71 assertThat("There must be three connections in VES Collector Flow", connections.size(), is(3));