X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=dcae-analytics-cdap-plugins%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fdcae%2Fapod%2Fanalytics%2Fcdap%2Fplugins%2Ftransform%2Ffilter%2FJsonPathFilterTest.java;fp=dcae-analytics-cdap-plugins%2Fsrc%2Ftest%2Fjava%2Forg%2Fopenecomp%2Fdcae%2Fapod%2Fanalytics%2Fcdap%2Fplugins%2Ftransform%2Ffilter%2FJsonPathFilterTest.java;h=8bf91c8c9c14f6a6ba5f7758c9444b59e2a35225;hb=c489a2eb22484e798c39a978bc8b61821b92322f;hp=a0feb99b0b9c54c4eaf5dcd0ffdea6879aa534fd;hpb=baaecfc19132034168beb64a0c1e7813c7c17c4a;p=dcaegen2%2Fanalytics%2Ftca.git diff --git a/dcae-analytics-cdap-plugins/src/test/java/org/openecomp/dcae/apod/analytics/cdap/plugins/transform/filter/JsonPathFilterTest.java b/dcae-analytics-cdap-plugins/src/test/java/org/onap/dcae/apod/analytics/cdap/plugins/transform/filter/JsonPathFilterTest.java similarity index 93% rename from dcae-analytics-cdap-plugins/src/test/java/org/openecomp/dcae/apod/analytics/cdap/plugins/transform/filter/JsonPathFilterTest.java rename to dcae-analytics-cdap-plugins/src/test/java/org/onap/dcae/apod/analytics/cdap/plugins/transform/filter/JsonPathFilterTest.java index a0feb99..8bf91c8 100644 --- a/dcae-analytics-cdap-plugins/src/test/java/org/openecomp/dcae/apod/analytics/cdap/plugins/transform/filter/JsonPathFilterTest.java +++ b/dcae-analytics-cdap-plugins/src/test/java/org/onap/dcae/apod/analytics/cdap/plugins/transform/filter/JsonPathFilterTest.java @@ -1,84 +1,84 @@ -/* - * ===============================LICENSE_START====================================== - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================LICENSE_END=========================================== - */ - -package org.openecomp.dcae.apod.analytics.cdap.plugins.transform.filter; - -import co.cask.cdap.api.data.format.StructuredRecord; -import co.cask.cdap.api.data.schema.Schema; -import co.cask.cdap.etl.api.Emitter; -import co.cask.cdap.etl.api.PipelineConfigurer; -import co.cask.cdap.etl.api.StageConfigurer; -import org.junit.Test; -import org.mockito.ArgumentMatchers; -import org.mockito.Mockito; -import org.openecomp.dcae.apod.analytics.cdap.plugins.BaseAnalyticsCDAPPluginsUnitTest; - -import java.util.Date; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * @author Rajiv Singla . Creation Date: 3/3/2017. - */ -public class JsonPathFilterTest extends BaseAnalyticsCDAPPluginsUnitTest { - - - @Test - public void testInitializeWhenFilterMappingIsValid() throws Exception { - final JsonPathFilter jsonPathFilter = new JsonPathFilter(getJsonPathFilterPluginConfig()); - jsonPathFilter.initialize(null); - } - - - @Test - public void configurePipeline() throws Exception { - final JsonPathFilter jsonPathFilter = new JsonPathFilter(getJsonPathFilterPluginConfig()); - final PipelineConfigurer pipelineConfigurer = mock(PipelineConfigurer.class); - final StageConfigurer stageConfigurer = mock(StageConfigurer.class); - when(pipelineConfigurer.getStageConfigurer()).thenReturn(stageConfigurer); - when(stageConfigurer.getInputSchema()).thenReturn(getSimpleTCAPluginInputSchema()); - doNothing().when(stageConfigurer).setOutputSchema(any(Schema.class)); - jsonPathFilter.configurePipeline(pipelineConfigurer); - verify(stageConfigurer, times(1)).setOutputSchema(any(Schema.class)); - } - - @Test - public void testTransform() throws Exception { - final JsonPathFilter jsonPathFilter = new JsonPathFilter(getJsonPathFilterPluginConfig()); - jsonPathFilter.initialize(null); - final StructuredRecord inputSR = StructuredRecord.builder(getJsonFilterPluginInputSchema()) - .set("ts", new Date().getTime()) - .set("responseCode", 200) - .set("responseMessage", "OK") - .set("message", fromStream(CEF_MESSAGE_JSON_FILE_LOCATION)) - .build(); - - final Emitter emitter = Mockito.mock(Emitter.class); - doNothing().when(emitter).emit(ArgumentMatchers.any(StructuredRecord.class)); - jsonPathFilter.transform(inputSR, emitter); - verify(emitter, times(1)).emit(any(StructuredRecord.class)); - } - -} +/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================LICENSE_END=========================================== + */ + +package org.onap.dcae.apod.analytics.cdap.plugins.transform.filter; + +import co.cask.cdap.api.data.format.StructuredRecord; +import co.cask.cdap.api.data.schema.Schema; +import co.cask.cdap.etl.api.Emitter; +import co.cask.cdap.etl.api.PipelineConfigurer; +import co.cask.cdap.etl.api.StageConfigurer; +import org.junit.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.Mockito; +import org.onap.dcae.apod.analytics.cdap.plugins.BaseAnalyticsCDAPPluginsUnitTest; + +import java.util.Date; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +/** + * @author Rajiv Singla . Creation Date: 3/3/2017. + */ +public class JsonPathFilterTest extends BaseAnalyticsCDAPPluginsUnitTest { + + + @Test + public void testInitializeWhenFilterMappingIsValid() throws Exception { + final JsonPathFilter jsonPathFilter = new JsonPathFilter(getJsonPathFilterPluginConfig()); + jsonPathFilter.initialize(null); + } + + + @Test + public void configurePipeline() throws Exception { + final JsonPathFilter jsonPathFilter = new JsonPathFilter(getJsonPathFilterPluginConfig()); + final PipelineConfigurer pipelineConfigurer = mock(PipelineConfigurer.class); + final StageConfigurer stageConfigurer = mock(StageConfigurer.class); + when(pipelineConfigurer.getStageConfigurer()).thenReturn(stageConfigurer); + when(stageConfigurer.getInputSchema()).thenReturn(getSimpleTCAPluginInputSchema()); + doNothing().when(stageConfigurer).setOutputSchema(any(Schema.class)); + jsonPathFilter.configurePipeline(pipelineConfigurer); + verify(stageConfigurer, times(1)).setOutputSchema(any(Schema.class)); + } + + @Test + public void testTransform() throws Exception { + final JsonPathFilter jsonPathFilter = new JsonPathFilter(getJsonPathFilterPluginConfig()); + jsonPathFilter.initialize(null); + final StructuredRecord inputSR = StructuredRecord.builder(getJsonFilterPluginInputSchema()) + .set("ts", new Date().getTime()) + .set("responseCode", 200) + .set("responseMessage", "OK") + .set("message", fromStream(CEF_MESSAGE_JSON_FILE_LOCATION)) + .build(); + + final Emitter emitter = Mockito.mock(Emitter.class); + doNothing().when(emitter).emit(ArgumentMatchers.any(StructuredRecord.class)); + jsonPathFilter.transform(inputSR, emitter); + verify(emitter, times(1)).emit(any(StructuredRecord.class)); + } + +}