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.onap.dcae.apod.analytics.cdap.plugins.domain.schema.dmaap;
23 import co.cask.cdap.api.data.schema.Schema;
24 import org.junit.Test;
25 import org.onap.dcae.apod.analytics.cdap.plugins.BaseAnalyticsCDAPPluginsUnitTest;
27 import java.util.LinkedList;
28 import java.util.List;
30 import static org.hamcrest.CoreMatchers.hasItems;
31 import static org.hamcrest.CoreMatchers.is;
32 import static org.junit.Assert.assertThat;
35 * @author Rajiv Singla . Creation Date: 1/25/2017.
37 public class DMaaPSourceOutputSchemaTest extends BaseAnalyticsCDAPPluginsUnitTest {
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"));
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());
56 assertThat(fieldNames, hasItems(
57 DMaaPSourceOutputSchema.TIMESTAMP.getSchemaColumnName(),
58 DMaaPSourceOutputSchema.RESPONSE_CODE.getSchemaColumnName(),
59 DMaaPSourceOutputSchema.RESPONSE_MESSAGE.getSchemaColumnName(),
60 DMaaPSourceOutputSchema.FETCHED_MESSAGE.getSchemaColumnName()));