Initial TCA commit into DCAEGEN2
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-plugins / src / test / java / org / openecomp / dcae / apod / analytics / cdap / plugins / domain / schema / dmaap / DMaaPSourceOutputSchemaTest.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.openecomp.dcae.apod.analytics.cdap.plugins.domain.schema.dmaap;
22
23 import co.cask.cdap.api.data.schema.Schema;
24 import org.junit.Test;
25 import org.openecomp.dcae.apod.analytics.cdap.plugins.BaseAnalyticsCDAPPluginsUnitTest;
26
27 import java.util.LinkedList;
28 import java.util.List;
29
30 import static org.hamcrest.CoreMatchers.hasItems;
31 import static org.hamcrest.CoreMatchers.is;
32 import static org.junit.Assert.assertThat;
33
34 /**
35  * @author Rajiv Singla . Creation Date: 1/25/2017.
36  */
37 public class DMaaPSourceOutputSchemaTest extends BaseAnalyticsCDAPPluginsUnitTest {
38
39
40     @Test
41     public void testGetSchemaColumnName() throws Exception {
42         assertThat(DMaaPSourceOutputSchema.TIMESTAMP.getSchemaColumnName(), is("ts"));
43         assertThat(DMaaPSourceOutputSchema.RESPONSE_CODE.getSchemaColumnName(), is("responseCode"));
44         assertThat(DMaaPSourceOutputSchema.RESPONSE_MESSAGE.getSchemaColumnName(), is("responseMessage"));
45         assertThat(DMaaPSourceOutputSchema.FETCHED_MESSAGE.getSchemaColumnName(), is("message"));
46     }
47
48     @Test
49     public void testGetSchema() throws Exception {
50         final Schema schema = DMaaPSourceOutputSchema.getSchema();
51         final List<Schema.Field> fields = schema.getFields();
52         final List<String> fieldNames = new LinkedList<>();
53         for (Schema.Field field : fields) {
54             fieldNames.add(field.getName());
55         }
56         assertThat(fieldNames, hasItems(
57                 DMaaPSourceOutputSchema.TIMESTAMP.getSchemaColumnName(),
58                 DMaaPSourceOutputSchema.RESPONSE_CODE.getSchemaColumnName(),
59                 DMaaPSourceOutputSchema.RESPONSE_MESSAGE.getSchemaColumnName(),
60                 DMaaPSourceOutputSchema.FETCHED_MESSAGE.getSchemaColumnName()));
61     }
62
63 }