| /** |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you 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. |
| */ |
| package org.apache.metron.dataloads.extractor; |
| |
| import org.junit.jupiter.api.BeforeEach; |
| import org.junit.jupiter.api.Test; |
| import org.mockito.Mock; |
| import org.mockito.MockitoAnnotations; |
| |
| import java.io.IOException; |
| import java.util.HashMap; |
| import java.util.Map; |
| |
| import static org.hamcrest.CoreMatchers.notNullValue; |
| import static org.hamcrest.MatcherAssert.assertThat; |
| import static org.mockito.ArgumentMatchers.isA; |
| import static org.mockito.Mockito.verify; |
| |
| public class ExtractorDecoratorTest { |
| |
| @Mock |
| Extractor extractor; |
| |
| @BeforeEach |
| public void before() { |
| MockitoAnnotations.initMocks(this); |
| } |
| |
| @Test |
| public void sets_member_variables() { |
| ExtractorDecorator decorator = new ExtractorDecorator(extractor); |
| assertThat(decorator.decoratedExtractor, notNullValue()); |
| } |
| |
| @Test |
| public void calls_extractor_methods() throws IOException { |
| ExtractorDecorator decorator = new ExtractorDecorator(extractor); |
| decorator.initialize(new HashMap()); |
| decorator.extract("line"); |
| verify(extractor).initialize(isA(Map.class)); |
| verify(extractor).extract("line"); |
| } |
| |
| } |