2 * ===============================LICENSE_START======================================
\r
4 * ================================================================================
\r
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============================LICENSE_END===========================================
\r
21 package org.openecomp.dcae.apod.analytics.cdap.plugins.domain.schema.dmaap;
\r
23 import co.cask.cdap.api.data.schema.Schema;
\r
24 import org.junit.Test;
\r
25 import org.openecomp.dcae.apod.analytics.cdap.plugins.BaseAnalyticsCDAPPluginsUnitTest;
\r
27 import java.util.LinkedList;
\r
28 import java.util.List;
\r
30 import static org.hamcrest.CoreMatchers.hasItems;
\r
31 import static org.hamcrest.CoreMatchers.is;
\r
32 import static org.junit.Assert.assertThat;
\r
35 * @author Rajiv Singla . Creation Date: 1/25/2017.
\r
37 public class DMaaPSourceOutputSchemaTest extends BaseAnalyticsCDAPPluginsUnitTest {
\r
41 public void testGetSchemaColumnName() throws Exception {
\r
42 assertThat(DMaaPSourceOutputSchema.TIMESTAMP.getSchemaColumnName(), is("ts"));
\r
43 assertThat(DMaaPSourceOutputSchema.RESPONSE_CODE.getSchemaColumnName(), is("responseCode"));
\r
44 assertThat(DMaaPSourceOutputSchema.RESPONSE_MESSAGE.getSchemaColumnName(), is("responseMessage"));
\r
45 assertThat(DMaaPSourceOutputSchema.FETCHED_MESSAGE.getSchemaColumnName(), is("message"));
\r
49 public void testGetSchema() throws Exception {
\r
50 final Schema schema = DMaaPSourceOutputSchema.getSchema();
\r
51 final List<Schema.Field> fields = schema.getFields();
\r
52 final List<String> fieldNames = new LinkedList<>();
\r
53 for (Schema.Field field : fields) {
\r
54 fieldNames.add(field.getName());
\r
56 assertThat(fieldNames, hasItems(
\r
57 DMaaPSourceOutputSchema.TIMESTAMP.getSchemaColumnName(),
\r
58 DMaaPSourceOutputSchema.RESPONSE_CODE.getSchemaColumnName(),
\r
59 DMaaPSourceOutputSchema.RESPONSE_MESSAGE.getSchemaColumnName(),
\r
60 DMaaPSourceOutputSchema.FETCHED_MESSAGE.getSchemaColumnName()));
\r