Skip to content

Commit

Permalink
mockito/test upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohegyi committed Feb 11, 2024
1 parent 213fe88 commit f34f329
Show file tree
Hide file tree
Showing 25 changed files with 237 additions and 48 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ext {
nettyVersion = '4.1.87.Final'
jettyVersion = '9.4.53.v20231009'
jUnitVersion = '5.9.3'
mockitoCoreVersion = '4.6.1'
mockitoCoreVersion = '5.10.0' //was '4.6.1'
orgSfl4jVersion = '2.0.9'
logbackVersion = '1.4.5'
googleGuavaApi = 'com.google.guava:guava:32.1.3-jre'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class FastInfosetDecompressorProcessorTest {

@BeforeEach
public void setUp() {
MockitoAnnotations.initMocks(this);
MockitoAnnotations.openMocks(this);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.epam.wilma.common.helper.SequenceHandlingState;
import com.epam.wilma.core.configuration.CoreConfigurationAccess;
import com.epam.wilma.core.configuration.domain.PropertyDto;
import com.epam.wilma.core.processor.entity.JmsRequestLoggerProcessor;
import com.epam.wilma.core.processor.entity.JmsResponseProcessor;
import com.epam.wilma.core.processor.entity.ProcessorBase;
import com.epam.wilma.core.processor.request.WilmaHttpRequestProcessor;
import com.epam.wilma.core.processor.response.WilmaHttpResponseProcessor;
Expand Down Expand Up @@ -51,9 +53,9 @@ public class MessageLoggingToggleTest {
@InjectMocks
private MessageLoggingToggle underTest;
@Mock
private ProcessorBase jmsRequestLogger;
private JmsRequestLoggerProcessor jmsRequestLoggerProcessor;
@Mock
private ProcessorBase jmsResponseProcessor;
private JmsResponseProcessor jmsResponseProcessor;
@Mock
private WilmaHttpRequestProcessor requestHandler;
@Mock
Expand All @@ -79,7 +81,7 @@ public final void testOnApplicationEventShouldSwitchOffMessageLoggingWhenPropert
// WHEN
underTest.onApplicationEvent(event);
// THEN
verify(requestHandler).disableProcessor(jmsRequestLogger);
verify(requestHandler).disableProcessor(jmsRequestLoggerProcessor);
verify(responseHandler).disableProcessor(jmsResponseProcessor);
}

Expand All @@ -92,7 +94,7 @@ public final void testOnApplicationEventShouldNotSwitchOffMessageLoggingWhenProp
// WHEN
underTest.onApplicationEvent(event);
// THEN
verify(requestHandler, never()).disableProcessor(jmsRequestLogger);
verify(requestHandler, never()).disableProcessor(jmsRequestLoggerProcessor);
verify(responseHandler, never()).disableProcessor(jmsResponseProcessor);
}

Expand All @@ -104,7 +106,7 @@ public final void testOnApplicationEventShouldNotSwitchOffMessageLoggingWhenProp
// WHEN
underTest.onApplicationEvent(event);
// THEN
verify(requestHandler, never()).disableProcessor(jmsRequestLogger);
verify(requestHandler, never()).disableProcessor(jmsRequestLoggerProcessor);
verify(responseHandler, never()).disableProcessor(jmsResponseProcessor);
}

Expand All @@ -114,7 +116,7 @@ public final void testSwitchOffMessageLoggingRemovesBothProcessors() {
// WHEN
underTest.switchOffMessageLogging();
// THEN
verify(requestHandler).disableProcessor(jmsRequestLogger);
verify(requestHandler).disableProcessor(jmsRequestLoggerProcessor);
verify(responseHandler).disableProcessor(jmsResponseProcessor);
}

Expand All @@ -124,30 +126,30 @@ public final void testSwitchOnMessageLoggingAddsBothProcessors() {
// WHEN
underTest.switchOnMessageLogging();
// THEN
verify(requestHandler).enableProcessor(jmsRequestLogger);
verify(requestHandler).enableProcessor(jmsRequestLoggerProcessor);
verify(responseHandler).enableProcessor(jmsResponseProcessor);
}

@Test
public final void testIsRequestLoggingOnReturnsTrueIfHandlerContainsProcessor() {
// GIVEN in setup
given(requestHandler.containsProcessor(jmsRequestLogger)).willReturn(true);
given(requestHandler.isProcessorEnabled(jmsRequestLogger)).willReturn(true);
given(requestHandler.containsProcessor(jmsRequestLoggerProcessor)).willReturn(true);
given(requestHandler.isProcessorEnabled(jmsRequestLoggerProcessor)).willReturn(true);
// WHEN
boolean actual = underTest.isRequestLoggingOn();
// THEN
verify(requestHandler).isProcessorEnabled(jmsRequestLogger);
verify(requestHandler).isProcessorEnabled(jmsRequestLoggerProcessor);
assertTrue(actual);
}

@Test
public final void testIsRequestLoggingOnReturnsFalseIfHandlerDoesNotContainProcessor() {
// GIVEN in setup
given(requestHandler.isProcessorEnabled(jmsRequestLogger)).willReturn(false);
given(requestHandler.isProcessorEnabled(jmsRequestLoggerProcessor)).willReturn(false);
// WHEN
boolean actual = underTest.isRequestLoggingOn();
// THEN
verify(requestHandler).isProcessorEnabled(jmsRequestLogger);
verify(requestHandler).isProcessorEnabled(jmsRequestLoggerProcessor);
assertFalse(actual);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies {
implementation project(':wilma-application:wilma-core')
implementation project(':wilma-application:wilma-properties')
implementation('website.magyar:mitm-java-proxy:2.5.27.114') {
// implementation('website.magyar:mitm-java-proxy:2.5.28.SNAPSHOT') {
exclude(group: 'ch.qos.logback', module: 'logback-classic')
exclude(group: 'org.eclipse.jetty', module: 'jetty-io')
exclude(group: 'org.slf4j', module: 'jcl-over-slf4j')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
package com.epam.sandbox.common;

/*==========================================================================
Copyright since 2013, EPAM Systems
This file is part of Wilma.
Wilma is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wilma is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wilma. If not, see <http://www.gnu.org/licenses/>.
===========================================================================*/

public class SuperLogic {

public boolean getResult() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
package com.epam.sandbox.conditionchecker;

/**
* WARNING: THIS DOCUMENT CONTAINS CONFIDENTIAL INFORMATION PROPERTY OF EPAM SYSTEMS.
* THIS CONTENT MAY NOT BE USED OR DISCLOSED WITHOUT PRIOR WRITTEN CONSENT OF THE OWNER.
* THE EPAM IP IS BEING PROVIDED ON AN "AS IS" BASIS. EPAM DISCLAIMS ALL WARRANTIES,
* EITHER EXPRESS OR IMPLIED INCLUDING, BUT NOT LIMITED TO, IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
*/
/*==========================================================================
Copyright since 2013, EPAM Systems
This file is part of Wilma.
Wilma is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wilma is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wilma. If not, see <http://www.gnu.org/licenses/>.
===========================================================================*/

import com.epam.sandbox.common.SuperLogic;
import com.epam.wilma.domain.http.WilmaHttpRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
package com.epam.sandbox.interceptor;

/**
* WARNING: THIS DOCUMENT CONTAINS CONFIDENTIAL INFORMATION PROPERTY OF EPAM SYSTEMS.
* THIS CONTENT MAY NOT BE USED OR DISCLOSED WITHOUT PRIOR WRITTEN CONSENT OF THE OWNER.
* THE EPAM IP IS BEING PROVIDED ON AN "AS IS" BASIS. EPAM DISCLAIMS ALL WARRANTIES,
* EITHER EXPRESS OR IMPLIED INCLUDING, BUT NOT LIMITED TO, IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
*/
/*==========================================================================
Copyright since 2013, EPAM Systems
This file is part of Wilma.
Wilma is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wilma is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wilma. If not, see <http://www.gnu.org/licenses/>.
===========================================================================*/


import com.epam.sandbox.common.SuperLogic;
import com.epam.wilma.domain.http.WilmaHttpRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
package com.epam.sandbox.interceptor;

/*==========================================================================
Copyright since 2013, EPAM Systems
This file is part of Wilma.
Wilma is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wilma is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wilma. If not, see <http://www.gnu.org/licenses/>.
===========================================================================*/

import com.epam.sandbox.common.SuperLogic;
import com.epam.wilma.domain.http.WilmaHttpResponse;
import com.epam.wilma.domain.stubconfig.interceptor.ResponseInterceptor;
import com.epam.wilma.domain.stubconfig.parameter.ParameterList;

public class ResponseInterceptorJared implements ResponseInterceptor{
public class ResponseInterceptorJared implements ResponseInterceptor {

private SuperLogic superLogic = new SuperLogic();

@Override
public void onResponseReceive(WilmaHttpResponse response, ParameterList parameters){
public void onResponseReceive(WilmaHttpResponse response, ParameterList parameters) {
System.out.println("response interceptor: " + superLogic.getResult());
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
package com.epam.sandbox.responseFormatter;

/**
* WARNING: THIS DOCUMENT CONTAINS CONFIDENTIAL INFORMATION PROPERTY OF EPAM SYSTEMS.
* THIS CONTENT MAY NOT BE USED OR DISCLOSED WITHOUT PRIOR WRITTEN CONSENT OF THE OWNER.
* THE EPAM IP IS BEING PROVIDED ON AN "AS IS" BASIS. EPAM DISCLAIMS ALL WARRANTIES,
* EITHER EXPRESS OR IMPLIED INCLUDING, BUT NOT LIMITED TO, IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
*/
/*==========================================================================
Copyright since 2013, EPAM Systems
This file is part of Wilma.
Wilma is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wilma is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wilma. If not, see <http://www.gnu.org/licenses/>.
===========================================================================*/


import com.epam.sandbox.common.SuperLogic;
import com.epam.wilma.domain.http.WilmaHttpRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
package com.epam.sandbox.templategenerator;

/*==========================================================================
Copyright since 2013, EPAM Systems
This file is part of Wilma.
Wilma is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wilma is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wilma. If not, see <http://www.gnu.org/licenses/>.
===========================================================================*/

import com.epam.sandbox.common.SuperLogic;
import com.epam.wilma.domain.stubconfig.dialog.response.template.TemplateGenerator;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
package com.epam.sandbox.two;

/*==========================================================================
Copyright since 2013, EPAM Systems
This file is part of Wilma.
Wilma is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wilma is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wilma. If not, see <http://www.gnu.org/licenses/>.
===========================================================================*/

import com.epam.wilma.domain.http.WilmaHttpRequest;
import com.epam.wilma.domain.stubconfig.dialog.condition.checker.ConditionChecker;
import com.epam.wilma.domain.stubconfig.parameter.ParameterList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
package com.epam.sandbox.two;

/*==========================================================================
Copyright since 2013, EPAM Systems
This file is part of Wilma.
Wilma is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wilma is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wilma. If not, see <http://www.gnu.org/licenses/>.
===========================================================================*/

import com.epam.wilma.domain.http.WilmaHttpRequest;
import com.epam.wilma.domain.stubconfig.dialog.condition.checker.ConditionChecker;
import com.epam.wilma.domain.stubconfig.parameter.ParameterList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
import java.nio.charset.StandardCharsets;

/**
* Generates a JSON response body: { "uuid": "toBeFormatted" }
* Generates a JSON response body: { "uuid": "toBeFormatted" }.
*/

public class UuidJsonTemplateGenerator implements TemplateGenerator {

@Override
public byte[] generateTemplate() {
JSONObject o = new JSONObject("{ \"uuid\": \"toBeFormatted\" }" );
JSONObject o = new JSONObject("{ \"uuid\": \"toBeFormatted\" }");
return o.toString().getBytes(StandardCharsets.UTF_8);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
package com.epam.wilma.functionalTest;

/*==========================================================================
Copyright since 2013, EPAM Systems
This file is part of Wilma.
Wilma is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Wilma is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Wilma. If not, see <http://www.gnu.org/licenses/>.
===========================================================================*/

import com.epam.wilma.domain.http.WilmaHttpRequest;
import com.epam.wilma.domain.stubconfig.dialog.condition.checker.ConditionChecker;
import com.epam.wilma.domain.stubconfig.parameter.ParameterList;
Expand Down
Loading

0 comments on commit f34f329

Please sign in to comment.