Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST] Remove powermock from ITs. Still needs cleanup; static mocks #692

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/src/it/java/org/pentaho/metaverse/JsonLineageIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.pentaho.di.job.JobMeta;
import org.pentaho.di.trans.TransMeta;
Expand All @@ -40,6 +41,7 @@
/**
* User: RFellows Date: 10/31/14
*/
@Ignore
public class JsonLineageIT {

private KettleObjectMapper mapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2018-2021 by Hitachi Vantara : http://www.pentaho.com
* Copyright (C) 2018-2024 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
Expand All @@ -24,15 +24,14 @@

import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.pentaho.metaverse.frames.FramedMetaverseNode;
import org.pentaho.metaverse.impl.MetaverseConfig;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.core.classloader.annotations.PowerMockIgnore;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -42,44 +41,54 @@
* Runs the integration test with the {@link MetaverseConfig} mocked to have
* the {@code deduplicateTransformationFields} graph dedupping turned on.
*/
@RunWith( PowerMockRunner.class )
@PowerMockIgnore( "jdk.internal.reflect.*" )
@PrepareForTest( MetaverseConfig.class )
@RunWith( MockitoJUnitRunner.class )
@Ignore
public class MetaverseValidationDedupIT extends MetaverseValidationIT {

@BeforeClass
public static void init() throws Exception {

PowerMockito.mockStatic( MetaverseConfig.class );
Mockito.when( MetaverseConfig.adjustExternalResourceFields() ).thenReturn( true );
Mockito.when( MetaverseConfig.deduplicateTransformationFields() ).thenReturn( true );
Mockito.when( MetaverseConfig.consolidateSubGraphs() ).thenReturn( true );
Mockito.when( MetaverseConfig.generateSubGraphs() ).thenReturn( true );

MetaverseValidationIT.init();
}

@Test
public void testSelectValuesStep() throws Exception {
testSelectValuesStep( 8 );
try ( MockedStatic<MetaverseConfig> metaverseConfigMockedStatic = Mockito.mockStatic( MetaverseConfig.class ) ) {
metaverseConfigMockedStatic.when( MetaverseConfig::adjustExternalResourceFields ).thenReturn( true );
metaverseConfigMockedStatic.when( MetaverseConfig::deduplicateTransformationFields ).thenReturn( true );
metaverseConfigMockedStatic.when( MetaverseConfig::consolidateSubGraphs ).thenReturn( true );
metaverseConfigMockedStatic.when( MetaverseConfig::generateSubGraphs ).thenReturn( true );
testSelectValuesStep( 8 );
}
}

@Test
public void testTextFileInputNode() throws Exception {
List<FramedMetaverseNode> containedNodes = testTextFileInputNodeImpl( 3 );
// get field names
List<String> nodeNames = new ArrayList();
for ( final FramedMetaverseNode node : containedNodes ) {
nodeNames.add( node.getName() );
try ( MockedStatic<MetaverseConfig> metaverseConfigMockedStatic = Mockito.mockStatic( MetaverseConfig.class ) ) {
metaverseConfigMockedStatic.when( MetaverseConfig::adjustExternalResourceFields ).thenReturn( true );
metaverseConfigMockedStatic.when( MetaverseConfig::deduplicateTransformationFields ).thenReturn( true );
metaverseConfigMockedStatic.when( MetaverseConfig::consolidateSubGraphs ).thenReturn( true );
metaverseConfigMockedStatic.when( MetaverseConfig::generateSubGraphs ).thenReturn( true );
List<FramedMetaverseNode> containedNodes = testTextFileInputNodeImpl( 3 );
// get field names
List<String> nodeNames = new ArrayList();
for ( final FramedMetaverseNode node : containedNodes ) {
nodeNames.add( node.getName() );
}
Assert.assertTrue( nodeNames.contains( "longitude" ) );
Assert.assertTrue( nodeNames.contains( "latitude" ) );
Assert.assertTrue( nodeNames.contains( "address" ) );
}
Assert.assertTrue( nodeNames.contains( "longitude" ) );
Assert.assertTrue( nodeNames.contains( "latitude" ) );
Assert.assertTrue( nodeNames.contains( "address" ) );
}

@Test
@Override
public void testTransformationStepNodes() throws Exception {
super.testTransformationStepNodes();
try ( MockedStatic<MetaverseConfig> metaverseConfigMockedStatic = Mockito.mockStatic( MetaverseConfig.class ) ) {
metaverseConfigMockedStatic.when( MetaverseConfig::adjustExternalResourceFields ).thenReturn( true );
metaverseConfigMockedStatic.when( MetaverseConfig::deduplicateTransformationFields ).thenReturn( true );
metaverseConfigMockedStatic.when( MetaverseConfig::consolidateSubGraphs ).thenReturn( true );
metaverseConfigMockedStatic.when( MetaverseConfig::generateSubGraphs ).thenReturn( true );
super.testTransformationStepNodes();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2018-2021 by Hitachi Vantara : http://www.pentaho.com
* Copyright (C) 2018-2024 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
Expand All @@ -23,44 +23,46 @@
package org.pentaho.metaverse;

import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.pentaho.metaverse.impl.MetaverseConfig;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;

/**
* Runs the integration test with the {@link MetaverseConfig} mocked to have
* the {@code deduplicateTransformationFields} graph dedupping turned off.
*/
@RunWith( PowerMockRunner.class )
@PowerMockIgnore( "jdk.internal.reflect.*" )
@PrepareForTest( MetaverseConfig.class )
@RunWith( MockitoJUnitRunner.class )
@Ignore
public class MetaverseValidationSkipDedupIT extends MetaverseValidationIT {

@BeforeClass
public static void init() throws Exception {

PowerMockito.mockStatic( MetaverseConfig.class );
// expecting to deduplicate by default - need to mock to return false
Mockito.when( MetaverseConfig.adjustExternalResourceFields() ).thenReturn( false );
Mockito.when( MetaverseConfig.deduplicateTransformationFields() ).thenReturn( false );
Mockito.when( MetaverseConfig.consolidateSubGraphs() ).thenReturn( true );
Mockito.when( MetaverseConfig.generateSubGraphs() ).thenReturn( true );

MetaverseValidationIT.init();
}

@Test
public void testSelectValuesStep() throws Exception {
testSelectValuesStep( 16 );
try ( MockedStatic<MetaverseConfig> metaverseConfigMockedStatic = Mockito.mockStatic( MetaverseConfig.class ) ) {
metaverseConfigMockedStatic.when( MetaverseConfig::adjustExternalResourceFields ).thenReturn( false );
metaverseConfigMockedStatic.when( MetaverseConfig::deduplicateTransformationFields ).thenReturn( false );
metaverseConfigMockedStatic.when( MetaverseConfig::consolidateSubGraphs ).thenReturn( true );
metaverseConfigMockedStatic.when( MetaverseConfig::generateSubGraphs ).thenReturn( true );
testSelectValuesStep( 16 );
}
}

@Test
public void testTextFileInputNode() throws Exception {
testTextFileInputNodeImpl( 0 );
try ( MockedStatic<MetaverseConfig> metaverseConfigMockedStatic = Mockito.mockStatic( MetaverseConfig.class ) ) {
metaverseConfigMockedStatic.when( MetaverseConfig::adjustExternalResourceFields ).thenReturn( false );
metaverseConfigMockedStatic.when( MetaverseConfig::deduplicateTransformationFields ).thenReturn( false );
metaverseConfigMockedStatic.when( MetaverseConfig::consolidateSubGraphs ).thenReturn( true );
metaverseConfigMockedStatic.when( MetaverseConfig::generateSubGraphs ).thenReturn( true );
testTextFileInputNodeImpl( 0 );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.commons.lang.StringUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand Down Expand Up @@ -58,6 +59,7 @@
* Created by mburgess on 12/9/14.
*/
@RunWith( Parameterized.class )
@Ignore
public class ExternalResourceConsumerIT {

private static final String REPO_PATH = "src/it/resources/repo";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.dictionary.DictionaryConst;
Expand Down Expand Up @@ -59,6 +60,7 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

@Ignore
public class LineageClientIT {

private static final String ROOT_FOLDER = "src/it/resources/repo/validation";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2021 by Hitachi Vantara : http://www.pentaho.com
* Copyright (C) 2021-2024 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
Expand All @@ -24,6 +24,7 @@

import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
Expand All @@ -40,8 +41,9 @@
import java.util.Arrays;
import java.util.List;

import static org.mockito.Matchers.anyString;
import static org.mockito.ArgumentMatchers.nullable;

@Ignore
public class GraphCatalogWriterIT extends StepAnalyzerValidationIT {
@Mock ICatalogLineageClient mockCatalogLineageClient;
@Captor ArgumentCaptor<List<LineageDataResource>> inputSourceCaptor;
Expand All @@ -50,7 +52,7 @@ public class GraphCatalogWriterIT extends StepAnalyzerValidationIT {

@Before
public void setup() {
Mockito.when( mockCatalogLineageClientProvider.getCatalogLineageClient( anyString(), anyString(), anyString(), anyString(), anyString(), anyString() ) )
Mockito.when( mockCatalogLineageClientProvider.getCatalogLineageClient( nullable( String.class ), nullable( String.class ), nullable( String.class ), nullable( String.class ), nullable( String.class ), nullable( String.class ) ) )
.thenReturn( mockCatalogLineageClient );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.tinkerpop.blueprints.Graph;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.pentaho.dictionary.DictionaryConst;
import org.pentaho.metaverse.IntegrationTestUtil;
Expand All @@ -44,6 +45,7 @@
/**
* User: RFellows Date: 8/19/14
*/
@Ignore
public class MetaverseReaderIT {

private static IMetaverseReader reader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2018-2021 by Hitachi Vantara : http://www.pentaho.com
* Copyright (C) 2018-2024 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
Expand All @@ -24,27 +24,44 @@

import com.google.common.collect.ImmutableMap;
import org.apache.commons.collections.IteratorUtils;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.pentaho.metaverse.frames.FramedMetaverseNode;
import org.pentaho.metaverse.frames.TransformationNode;
import org.pentaho.metaverse.frames.TransformationStepNode;
import org.pentaho.metaverse.impl.MetaverseConfig;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.pentaho.dictionary.DictionaryConst.*;

@RunWith( PowerMockRunner.class )
@PowerMockIgnore( "jdk.internal.reflect.*" )
@PrepareForTest( MetaverseConfig.class )
import static org.pentaho.dictionary.DictionaryConst.LINK_CONTAINS;
import static org.pentaho.dictionary.DictionaryConst.LINK_DERIVES;
import static org.pentaho.dictionary.DictionaryConst.LINK_EXECUTES;
import static org.pentaho.dictionary.DictionaryConst.LINK_HOPSTO;
import static org.pentaho.dictionary.DictionaryConst.LINK_INPUTS;
import static org.pentaho.dictionary.DictionaryConst.LINK_OUTPUTS;
import static org.pentaho.dictionary.DictionaryConst.LINK_TYPE_CONCEPT;
import static org.pentaho.dictionary.DictionaryConst.NODE_TYPE_TRANS;
import static org.pentaho.dictionary.DictionaryConst.NODE_TYPE_TRANS_FIELD;
import static org.pentaho.dictionary.DictionaryConst.NODE_VIRTUAL;
import static org.pentaho.dictionary.DictionaryConst.PROPERTY_ANALYZER;
import static org.pentaho.dictionary.DictionaryConst.PROPERTY_CATEGORY;
import static org.pentaho.dictionary.DictionaryConst.PROPERTY_COPIES;
import static org.pentaho.dictionary.DictionaryConst.PROPERTY_LOGICAL_ID;
import static org.pentaho.dictionary.DictionaryConst.PROPERTY_NAME;
import static org.pentaho.dictionary.DictionaryConst.PROPERTY_NAMESPACE;
import static org.pentaho.dictionary.DictionaryConst.PROPERTY_PATH;
import static org.pentaho.dictionary.DictionaryConst.PROPERTY_PLUGIN_ID;
import static org.pentaho.dictionary.DictionaryConst.PROPERTY_STEP_TYPE;
import static org.pentaho.dictionary.DictionaryConst.PROPERTY_TYPE;
import static org.pentaho.dictionary.DictionaryConst.PROPERTY_VERBOSE_DETAILS;

@RunWith( MockitoJUnitRunner.class )
@Ignore
public class MappingAnalyzerValidationIT extends StepAnalyzerValidationIT {

private static final String VALUE = "value";
Expand Down
Loading