Skip to content

Commit

Permalink
Merge pull request #413 from srallapa/merge_jdk17_master_20240514
Browse files Browse the repository at this point in the history
Merge jdk17 master 20240514
  • Loading branch information
ddiroma authored May 21, 2024
2 parents 27a2d19 + c9f24ca commit eb5d432
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 69 deletions.
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2018 Webdetails, a Hitachi Vantara company. All rights reserved.
* Copyright 2018 - 2024 Webdetails, a Hitachi Vantara company. All rights reserved.
*
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
Expand All @@ -18,7 +18,7 @@
import org.dom4j.io.SAXReader;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;

import org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.ConnectionProvider;
import org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.DriverConnectionProvider;
import pt.webdetails.cda.CdaEngine;
Expand All @@ -40,12 +40,14 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyMap;
import static org.mockito.Matchers.anyString;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyMap;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;


public class DataservicesConnectionTest {
@Before
public void setUp() throws Exception {
Expand All @@ -56,15 +58,15 @@ public void setUp() throws Exception {
ResultSetMetaData resultSetMetaData = mock( ResultSetMetaData.class );
when( resultSet.next() ).thenReturn( true ).thenReturn( false );
when( resultSet.getMetaData() ).thenReturn( resultSetMetaData );
when( statement.executeQuery( anyString() ) ).thenReturn( resultSet );
when( connection.createStatement( Mockito.anyInt(), Mockito.anyInt() ) ).thenReturn( statement );
when( statement.executeQuery( any() ) ).thenReturn( resultSet );
when( connection.createStatement( anyInt(), anyInt() ) ).thenReturn( statement );
DriverConnectionProvider dataserviceLocalConnectionProvider = mock( DriverConnectionProvider.class );
when( dataserviceLocalConnectionProvider.createConnection( anyString(), anyString() ) ).thenReturn( connection );
when( dataserviceLocalConnectionProvider.createConnection( any(), any() ) ).thenReturn( connection );
Properties properties = new Properties();
when( dataserviceLocalConnectionProvider.getProperty( anyString() ) ).thenAnswer(
when( dataserviceLocalConnectionProvider.getProperty( any() ) ).thenAnswer(
invocationOnMock -> properties.getProperty( (String)invocationOnMock.getArguments()[0] )
);
when( dataserviceLocalConnectionProvider.setProperty( anyString(), anyString() ) ).thenAnswer(
when( dataserviceLocalConnectionProvider.setProperty( any(), any() ) ).thenAnswer(
invocationOnMock -> properties.setProperty( (String)invocationOnMock.getArguments()[0], (String)invocationOnMock.getArguments()[1] )
);
when( dataserviceLocalConnectionProvider.getPropertyNames() ).thenReturn( properties.keySet().toArray( new String[0] ) );
Expand Down Expand Up @@ -110,15 +112,15 @@ public void testGetType() {
@Test
public void testNewWithParameters() throws Exception {
Element connection = mock( Element.class );
when( connection.selectObject( anyString() ) ).thenReturn( "" );
when( connection.selectObject( any() ) ).thenReturn( "" );
DataservicesConnection dataservicesConnection = new DataservicesConnection( connection );
assertNotNull( dataservicesConnection );
}

@Test
public void testGetInitializedConnectionProviderWithProperties() throws Exception {
Element connectionElement = mock( Element.class );
when( connectionElement.selectObject( anyString() ) ).thenReturn( "" );
when( connectionElement.selectObject( any() ) ).thenReturn( "" );
ArrayList<Element> properties = new ArrayList<>( );
properties.add( getElementFromSnippet( "<prop name=\"prop1\">will return mock value on test setup</prop>" ) );
when( connectionElement.elements( "Property" ) ).thenReturn( properties );
Expand All @@ -137,7 +139,7 @@ public void testGetInitializedConnectionProviderWithProperties() throws Exceptio
@Test
public void testGetInitializedConnectionProvider() throws Exception {
Element connectionElement = mock( Element.class );
when( connectionElement.selectObject( anyString() ) ).thenReturn( "" );
when( connectionElement.selectObject( any() ) ).thenReturn( "" );
DataservicesConnection dataservicesConnection = new DataservicesConnection( connectionElement );
Map<String, String> dataserviceParameters = new TreeMap<>( );
ConnectionProvider connectionProvider = dataservicesConnection.getInitializedConnectionProvider( dataserviceParameters );
Expand All @@ -155,7 +157,7 @@ public void testEquals() throws Exception {
assertFalse( dataservicesConnection.equals( null ) );

Element connection = mock( Element.class );
when( connection.selectObject( anyString() ) ).thenReturn( "" );
when( connection.selectObject( any() ) ).thenReturn( "" );
differentDataservicesConnection.initializeConnection( connection );
assertFalse( differentDataservicesConnection.equals( dataservicesConnection ) );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2018 Webdetails, a Hitachi Vantara company. All rights reserved.
* Copyright 2018 - 2024 Webdetails, a Hitachi Vantara company. All rights reserved.
*
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
Expand Down Expand Up @@ -41,8 +41,9 @@
import java.util.List;
import java.util.stream.Collectors;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2018 Webdetails, a Hitachi Vantara company. All rights reserved.
* Copyright 2018 - 2024 Webdetails, a Hitachi Vantara company. All rights reserved.
*
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
Expand Down Expand Up @@ -38,7 +38,7 @@
import java.util.List;
import java.util.stream.Collectors;

import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2018 Webdetails, a Hitachi Vantara company. All rights reserved.
* Copyright 2018 - 2024 Webdetails, a Hitachi Vantara company. All rights reserved.
*
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
Expand All @@ -16,7 +16,6 @@
import org.apache.commons.lang.exception.ExceptionUtils;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.DriverConnectionProvider;
import pt.webdetails.cda.CdaEngine;
import pt.webdetails.cda.connections.dataservices.DataservicesConnection;
Expand All @@ -34,7 +33,8 @@
import java.sql.SQLException;
import java.sql.Statement;

import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
Expand All @@ -53,10 +53,10 @@ public void testDatasourceDataservice() throws Exception {
ResultSetMetaData resultSetMetaData = mock( ResultSetMetaData.class );
when( resultSet.next() ).thenReturn( true ).thenReturn( false );
when( resultSet.getMetaData() ).thenReturn( resultSetMetaData );
when( statement.executeQuery( Mockito.anyString() ) ).thenReturn( resultSet );
when( connection.createStatement( Mockito.anyInt(), Mockito.anyInt() ) ).thenReturn( statement );
when( statement.executeQuery( any() ) ).thenReturn( resultSet );
when( connection.createStatement( anyInt(), anyInt() ) ).thenReturn( statement );
DriverConnectionProvider dataserviceLocalConnectionProvider = mock( DriverConnectionProvider.class );
when( dataserviceLocalConnectionProvider.createConnection( Mockito.anyString(), Mockito.anyString() ) ).thenReturn( connection );
when( dataserviceLocalConnectionProvider.createConnection( any(), any() ) ).thenReturn( connection );
IDataservicesLocalConnection dataserviceLocalConnection = mock( IDataservicesLocalConnection.class );
when( dataserviceLocalConnection.getDriverConnectionProvider( any() ) ).thenReturn( dataserviceLocalConnectionProvider );
CdaTestEnvironment testEnvironment = spy( new CdaTestEnvironment( factory ) );
Expand Down Expand Up @@ -107,7 +107,7 @@ public void testDatasourceDataserviceDriverConnectionProviderException() throws
public void testDatasourceDataserviceCreateConnectionException() throws Exception {
CdaTestingContentAccessFactory factory = new CdaTestingContentAccessFactory();
DriverConnectionProvider dataserviceLocalConnectionProvider = mock( DriverConnectionProvider.class );
when( dataserviceLocalConnectionProvider.createConnection( Mockito.anyString(), Mockito.anyString() ) )
when( dataserviceLocalConnectionProvider.createConnection( any(), any() ) )
.thenThrow( new SQLException( "couldn't create connection" ) );
IDataservicesLocalConnection dataserviceLocalConnection = mock( IDataservicesLocalConnection.class );
when( dataserviceLocalConnection.getDriverConnectionProvider( any() ) ).thenReturn( dataserviceLocalConnectionProvider );
Expand Down
13 changes: 6 additions & 7 deletions core/src/test/java/pt/webdetails/cda/filetests/SqlTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2002 - 2017 Webdetails, a Hitachi Vantara company. All rights reserved.
* Copyright 2002 - 2024 Webdetails, a Hitachi Vantara company. All rights reserved.
*
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
Expand All @@ -13,17 +13,11 @@

package pt.webdetails.cda.filetests;

import static org.mockito.Matchers.*;
import static org.mockito.Mockito.*;

import java.math.BigDecimal;
import java.util.Calendar;
import java.util.LinkedList;

import javax.swing.table.TableModel;

import org.pentaho.reporting.engine.classic.core.util.TypedTableModel;

import pt.webdetails.cda.CdaEngine;
import pt.webdetails.cda.cache.IQueryCache;
import pt.webdetails.cda.cache.TableCacheKey;
Expand All @@ -35,6 +29,11 @@
import pt.webdetails.cda.test.util.CdaTestHelper;
import pt.webdetails.cda.test.util.CdaTestHelper.SimpleTableModel;
import pt.webdetails.cda.test.util.TableModelChecker;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

public class SqlTest extends CdaTestCase {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* * Copyright 2018 Hitachi Vantara. All rights reserved.
* * Copyright 2018 - 2024 Hitachi Vantara. 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.
Expand All @@ -21,10 +21,12 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import pt.webdetails.cda.CdaEngine;
import pt.webdetails.cda.ICdaEnvironment;
import pt.webdetails.cda.InitializationException;
import pt.webdetails.cda.dataaccess.StreamingDataservicesDataAccess;
import pt.webdetails.cda.exporter.ExportOptions;
import pt.webdetails.cda.exporter.TableExporter;
import pt.webdetails.cda.settings.CdaSettings;
import pt.webdetails.cda.settings.SettingsManager;
Expand All @@ -35,8 +37,9 @@
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
Expand Down Expand Up @@ -64,9 +67,9 @@ public void setUp() throws Exception {
tableExporter = mock( TableExporter.class );

doReturn( settingsManager ).when( engine ).getSettingsManager();
doReturn( cdaSettings ).when( settingsManager ).parseSettingsFile( anyString() );
doReturn( streamingDataservicesDataAccess ).when( cdaSettings ).getDataAccess( anyString() );
doReturn( tableExporter ).when( engine ).getExporter( anyString() );
doReturn( cdaSettings ).when( settingsManager ).parseSettingsFile( any() );
doReturn( streamingDataservicesDataAccess ).when( cdaSettings ).getDataAccess( any() );
doReturn( tableExporter ).when( engine ).getExporter( Mockito.<ExportOptions>any() );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2002 - 2018 Webdetails, a Hitachi Vantara company. All rights reserved.
* Copyright 2002 - 2024 Webdetails, a Hitachi Vantara company. All rights reserved.
*
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
Expand Down Expand Up @@ -28,7 +28,7 @@
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.junit.ComparisonFailure;
import org.mockito.Matchers;

import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
Expand All @@ -51,6 +51,8 @@
import java.util.Objects;
import java.util.TreeMap;

import static org.mockito.ArgumentMatchers.any;

public class CdaTestHelper {

/**
Expand Down Expand Up @@ -141,7 +143,7 @@ public static ICdaEnvironment getMockEnvironment() {
public static ICdaEnvironment getMockEnvironment( final Map<String, String> configurationProperties ) {
ICdaEnvironment env = Mockito.mock( ICdaEnvironment.class );
Configuration conf = Mockito.mock( Configuration.class );
Mockito.when( conf.getConfigProperty( Matchers.any( String.class ), Matchers.any( String.class ) ) ).thenAnswer(
Mockito.when( conf.getConfigProperty( any( String.class ), any( String.class ) ) ).thenAnswer(
new Answer<String>() {
@Override
public String answer( InvocationOnMock invocation ) throws Throwable {
Expand All @@ -151,7 +153,7 @@ public String answer( InvocationOnMock invocation ) throws Throwable {
}
}
);
Mockito.when( conf.findPropertyKeys( Matchers.any( String.class ) ) ).thenAnswer(
Mockito.when( conf.findPropertyKeys( any( String.class ) ) ).thenAnswer(
new Answer<Iterator<String>>() {
@SuppressWarnings( "unchecked" )
public Iterator<String> answer( final InvocationOnMock invocation ) throws Throwable {
Expand Down
5 changes: 3 additions & 2 deletions core/src/test/java/pt/webdetails/cda/xml/DomVisitorTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2018 Webdetails, a Hitachi Vantara company. All rights reserved.
* Copyright 2018 -2024 Webdetails, a Hitachi Vantara company. All rights reserved.
*
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
Expand Down Expand Up @@ -41,12 +41,13 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;


public class DomVisitorTest {

private DomVisitor domVisitor;
Expand Down
2 changes: 1 addition & 1 deletion osgi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2018 Webdetails, a Hitachi Vantara company. All rights reserved.
* Copyright 2018 -2024 Webdetails, a Hitachi Vantara company. All rights reserved.
*
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
Expand All @@ -21,13 +21,14 @@
import java.io.IOException;
import java.util.function.Consumer;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.same;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;


public class CdaJettyWebsocketTest {
public static final String OUTBOUND_MESSAGE_1 = "Outbound Message 1";
public static final String OUTBOUND_MESSAGE_2 = "Outbound Message 2";
Expand Down
2 changes: 1 addition & 1 deletion pentaho/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
Expand Down
Loading

0 comments on commit eb5d432

Please sign in to comment.