From 622bdb653b20bd758276d029e2c7c6c5a229c1e1 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 15 Oct 2023 12:53:04 +0200 Subject: [PATCH 1/3] Move Tests to Mockito4 --- OCPP-J/pom.xml | 2 +- .../wss/test/BaseWssSocketBuilderTest.java | 2 +- ocpp-common/pom.xml | 2 +- .../eu/chargetime/ocpp/test/ClientTest.java | 19 ++++++----- .../ocpp/test/CommunicatorTest.java | 12 +++---- .../eu/chargetime/ocpp/test/ServerTest.java | 20 ++++++----- .../eu/chargetime/ocpp/test/SessionTest.java | 34 +++++++++++-------- .../test/SimpleRequestDispatcherTest.java | 10 +++--- ocpp-v1_6/pom.xml | 2 +- .../profile/test/ClientCoreProfileTest.java | 20 +++++------ .../ClientFirmwareManagementProfileTest.java | 8 ++--- .../test/ClientLocalAuthListProfileTest.java | 8 ++--- .../test/ClientRemoteTriggerProfileTest.java | 4 +-- .../test/ClientReservationProfileTest.java | 8 ++--- .../test/ClientSmartChargingProfileTest.java | 6 ++-- .../profile/test/ServerCoreProfileTest.java | 20 +++++------ .../ServerFirmwareManagementProfileTest.java | 9 +++-- .../test/ServerLocalAuthListProfileTest.java | 2 +- .../test/ServerRemoteTriggerProfileTest.java | 2 +- .../test/ServerReservationProfileTest.java | 2 +- .../test/ServerSmartChargingProfileTest.java | 2 +- .../ClientSecurityExtProfileTest.java | 3 +- .../ServerSecurityExtProfileTest.java | 3 +- .../GetLocalListVersionConfirmationTest.java | 2 +- .../test/GetLocalListVersionRequestTest.java | 2 +- .../test/SendLocalListConfirmationTest.java | 2 +- .../test/SendLocalListRequestTest.java | 6 ++-- .../model/test/AuthorizeConfirmationTest.java | 4 +-- .../ocpp/model/test/ChargingScheduleTest.java | 2 +- .../test/GetCompositeScheduleRequestTest.java | 2 +- .../GetConfigurationConfirmationTest.java | 2 +- .../ocpp/model/test/MeterValueTest.java | 6 ++-- .../model/test/MeterValuesRequestTest.java | 4 +-- .../RemoteStartTransactionRequestTest.java | 2 +- .../StartTransactionConfirmationTest.java | 2 +- .../test/StopTransactionConfirmationTest.java | 2 +- .../test/StopTransactionRequestTest.java | 2 +- .../ocpp/test/JSONCommunicatorTest.java | 6 ++-- .../ocpp/test/SOAPCommunicatorTest.java | 2 +- .../ocpp/test/TimeoutSessionTest.java | 20 +++++------ ocpp-v2-test/pom.xml | 2 +- .../OCPP201MultiProtocolIntegrationTest.java | 2 +- ocpp-v2/pom.xml | 2 +- ocpp-v2_0/pom.xml | 2 +- .../test/BootNotificationRequestTest.java | 2 +- 45 files changed, 142 insertions(+), 136 deletions(-) diff --git a/OCPP-J/pom.xml b/OCPP-J/pom.xml index 3e0f10a6f..e320bce06 100644 --- a/OCPP-J/pom.xml +++ b/OCPP-J/pom.xml @@ -72,7 +72,7 @@ org.mockito mockito-core - 1.10.19 + 4.11.0 test diff --git a/OCPP-J/src/test/java/eu/chargetime/ocpp/wss/test/BaseWssSocketBuilderTest.java b/OCPP-J/src/test/java/eu/chargetime/ocpp/wss/test/BaseWssSocketBuilderTest.java index 6ca62c104..517af993b 100644 --- a/OCPP-J/src/test/java/eu/chargetime/ocpp/wss/test/BaseWssSocketBuilderTest.java +++ b/OCPP-J/src/test/java/eu/chargetime/ocpp/wss/test/BaseWssSocketBuilderTest.java @@ -2,7 +2,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.*; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; import eu.chargetime.ocpp.wss.BaseWssFactoryBuilder; diff --git a/ocpp-common/pom.xml b/ocpp-common/pom.xml index 3d3e6e2a5..b0d6b8831 100644 --- a/ocpp-common/pom.xml +++ b/ocpp-common/pom.xml @@ -80,7 +80,7 @@ org.mockito mockito-core - 1.10.19 + 4.11.0 test diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java index c0ea87ee4..45baf02fc 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java @@ -41,7 +41,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ClientTest { @@ -59,7 +59,7 @@ public class ClientTest { @Before public void setup() { when(request.validate()).thenReturn(true); - doAnswer(invocation -> eventHandler = invocation.getArgumentAt(1, SessionEvents.class)) + doAnswer(invocation -> eventHandler = invocation.getArgument(1, SessionEvents.class)) .when(session) .open(any(), any()); @@ -77,7 +77,7 @@ public void connect_connects() { client.connect(someUrl, events); // Then - verify(session, times(1)).open(eq(someUrl), anyObject()); + verify(session).open(eq(someUrl), any()); } @Test @@ -89,7 +89,7 @@ public void connect_connectionOpenedEvent() { this.eventHandler.handleConnectionOpened(); // Then - verify(events, times(1)).connectionOpened(); + verify(events).connectionOpened(); verify(events, never()).connectionClosed(); } @@ -102,7 +102,7 @@ public void connect_connectionClosedEvent() { this.eventHandler.handleConnectionClosed(); // Then - verify(events, times(1)).connectionClosed(); + verify(events).connectionClosed(); verify(events, never()).connectionOpened(); } @@ -112,14 +112,15 @@ public void send_aMessage_isCommunicated() throws Exception { client.send(request); // Then - verify(session, times(1)).sendRequest(anyString(), eq(request), anyString()); + // TODO action and uuid should not be nullable + verify(session).sendRequest(nullable(String.class), eq(request), nullable(String.class)); } @Test public void responseReceived_aMessageWasSend_PromiseIsCompleted() throws Exception { // Given String someUniqueId = "Some id"; - when(session.storeRequest(any())).thenReturn(someUniqueId); + lenient().when(session.storeRequest(any())).thenReturn(someUniqueId); when(promiseRepository.getPromise(any())).thenReturn(Optional.of(completableFuture)); // When @@ -152,7 +153,7 @@ public void handleRequest_callsFeatureHandleRequest() throws UnsupportedFeatureE eventHandler.handleRequest(request); // Then - verify(feature, times(1)).handleRequest(any(), eq(request)); + verify(feature).handleRequest(any(), eq(request)); } @Test @@ -161,6 +162,6 @@ public void send_aMessage_validatesMessage() throws Exception { client.send(request); // Then - verify(request, times(1)).validate(); + verify(request).validate(); } } diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java index 9f6da1055..e44a5eb4e 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java @@ -1,6 +1,6 @@ package eu.chargetime.ocpp.test; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.*; import eu.chargetime.ocpp.*; @@ -12,7 +12,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP @@ -57,7 +57,7 @@ public void setup() throws Exception { when(transactionRelatedRequest.transactionRelated()).thenReturn(true); when(normalRequest.transactionRelated()).thenReturn(false); - doAnswer(invocation -> eventHandler = invocation.getArgumentAt(0, RadioEvents.class)) + doAnswer(invocation -> eventHandler = invocation.getArgument(0, RadioEvents.class)) .when(receiver) .accept(any()); setupCommunicator(true); @@ -126,7 +126,7 @@ public void sendCall_aNormalRequestAndRadioThrowsNotConnectedException_onErrorIs communicator.sendCall(uniqueId, action, normalRequest); // Then - verify(events, times(1)).onError(eq(uniqueId), any(), any(), any()); + verify(events).onError(eq(uniqueId), any(), any(), any()); } @Test @@ -164,7 +164,7 @@ public void sendCall_queueNotEmpty_messagesAreProcessInSequence() throws Excepti // Then verify(receiver, times(2)).send(eq(firstId)); - verify(receiver, times(1)).send(eq(secondId)); + verify(receiver).send(eq(secondId)); } @Test @@ -222,7 +222,7 @@ public boolean validate() { communicator.sendCallResult(uniqueId, action, conf); // Then - verify(handler, times(1)).onConfirmationCompleted(); + verify(handler).onConfirmationCompleted(); } @Test diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java index c6013ce71..3d9b379a7 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java @@ -12,7 +12,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP @@ -65,13 +65,14 @@ public void setup() { UUID sessionId = UUID.randomUUID(); when(request.validate()).thenReturn(true); when(session.getSessionId()).thenReturn(sessionId); - doAnswer(invocation -> listenerEvents = invocation.getArgumentAt(2, ListenerEvents.class)) +// when(session.storeRequest(any())).thenReturn(UUID.randomUUID().toString()); + doAnswer(invocation -> listenerEvents = invocation.getArgument(2, ListenerEvents.class)) .when(listener) .open(anyString(), anyInt(), any()); - doAnswer(invocation -> sessionEvents = invocation.getArgumentAt(0, SessionEvents.class)) + doAnswer(invocation -> sessionEvents = invocation.getArgument(0, SessionEvents.class)) .when(session) .accept(any()); - doAnswer(invocation -> sessionIndex = invocation.getArgumentAt(0, UUID.class)) + doAnswer(invocation -> sessionIndex = invocation.getArgument(0, UUID.class)) .when(serverEvents) .newSession(any(), any()); @@ -89,7 +90,7 @@ public void newSession_serverIsListening_sessionIsAccepted() { listenerEvents.newSession(session, information); // Then - verify(session, times(1)).accept(any()); + verify(session).accept(any()); } @Test @@ -101,7 +102,7 @@ public void newSession_serverIsListening_callbackWithIndex0() { listenerEvents.newSession(session, information); // Then - verify(serverEvents, times(1)).newSession(any(UUID.class), eq(information)); + verify(serverEvents).newSession(any(UUID.class), eq(information)); } @Test @@ -114,7 +115,8 @@ public void send_aMessage_isCommunicated() throws Exception { server.send(sessionIndex, request); // Then - verify(session, times(1)).sendRequest(anyString(), eq(request), anyString()); + // TODO action and uuid should not be nullable + verify(session).sendRequest(nullable(String.class), eq(request), nullable(String.class)); } @Test @@ -127,7 +129,7 @@ public void handleRequest_callsFeatureHandleRequest() throws UnsupportedFeatureE sessionEvents.handleRequest(request); // Then - verify(feature, times(1)).handleRequest(any(UUID.class), eq(request)); + verify(feature).handleRequest(any(UUID.class), eq(request)); } @Test @@ -140,6 +142,6 @@ public void send_aMessage_validatesMessage() throws Exception { server.send(sessionIndex, request); // Then - verify(request, times(1)).validate(); + verify(request).validate(); } } diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java index ef55cdfd8..1a616bf5e 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java @@ -16,7 +16,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP @@ -63,7 +63,7 @@ public class SessionTest { public void setup() throws Exception { when(featureRepository.findFeature(any())).thenReturn(Optional.of(feature)); session = new Session(communicator, queue, fulfiller, featureRepository); - doAnswer(invocation -> eventHandler = invocation.getArgumentAt(1, CommunicatorEvents.class)) + doAnswer(invocation -> eventHandler = invocation.getArgument(1, CommunicatorEvents.class)) .when(communicator) .connect(any(), any()); session.open(null, sessionEvents); @@ -103,7 +103,8 @@ public boolean validate() { session.sendRequest(someAction, someRequest, null); // Then - verify(communicator, times(1)).sendCall(anyString(), eq(someAction), eq(someRequest)); + // TODO uniqueid should not be nullable + verify(communicator).sendCall(nullable(String.class), eq(someAction), eq(someRequest)); } @Test @@ -115,7 +116,8 @@ public void sendRequest_someUniqueId_sendsUniqueIdToCommunicator() { session.sendRequest(null, null, someUniqueId); // Then - verify(communicator, times(1)).sendCall(eq(someUniqueId), anyString(), any()); + // TODO uuid and request should not be nullable + verify(communicator).sendCall(eq(someUniqueId), nullable(String.class), nullable(Request.class)); } @Test @@ -134,7 +136,7 @@ public boolean validate() { session.sendConfirmation(someUniqueId, action, conf); // Then - verify(communicator, times(1)).sendCallResult(eq(someUniqueId), eq(action), eq(conf)); + verify(communicator).sendCallResult(eq(someUniqueId), eq(action), eq(conf)); } @Test @@ -146,14 +148,14 @@ public void open_connectsViaCommunicator() { session.open(someUri, null); // Then - verify(communicator, times(1)).connect(eq(someUri), any()); + verify(communicator).connect(eq(someUri), any()); } @Test public void onCall_unhandledCallback_callSendCallError() throws Exception { // Given String someId = "Some id"; - doAnswer(invocation -> invocation.getArgumentAt(0, CompletableFuture.class).complete(null)) + doAnswer(invocation -> invocation.getArgument(0, CompletableFuture.class).complete(null)) .when(fulfiller) .fulfill(any(), any(), any()); when(communicator.unpackPayload(any(), any())).thenReturn(new TestRequest()); @@ -162,7 +164,8 @@ public void onCall_unhandledCallback_callSendCallError() throws Exception { eventHandler.onCall(someId, null, null); // then - verify(communicator, times(1)).sendCallError(eq(someId), anyString(), anyString(), anyString()); + // TODO action should not be nullable + verify(communicator).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); } @Test @@ -178,7 +181,7 @@ public boolean validate() { doAnswer( invocation -> - invocation.getArgumentAt(0, CompletableFuture.class).complete(aConfirmation)) + invocation.getArgument(0, CompletableFuture.class).complete(aConfirmation)) .when(fulfiller) .fulfill(any(), any(), any()); when(communicator.unpackPayload(any(), any())).thenReturn(new TestRequest()); @@ -187,7 +190,8 @@ public boolean validate() { eventHandler.onCall(someId, null, null); // then - verify(communicator, times(1)).sendCallResult(anyString(), anyString(), eq(aConfirmation)); + // TODO action should not be nullable + verify(communicator).sendCallResult(anyString(), nullable(String.class), eq(aConfirmation)); } @Test @@ -197,7 +201,7 @@ public void onCall_callbackThrowsException_callSendCallResult() throws Exception doAnswer( invocation -> invocation - .getArgumentAt(0, CompletableFuture.class) + .getArgument(0, CompletableFuture.class) .completeExceptionally(new Exception())) .when(fulfiller) .fulfill(any(), any(), any()); @@ -207,7 +211,8 @@ public void onCall_callbackThrowsException_callSendCallResult() throws Exception eventHandler.onCall(someId, null, null); // then - verify(communicator, times(1)).sendCallError(eq(someId), anyString(), anyString(), anyString()); + // TODO uniqueid should not be nullable + verify(communicator).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); } @Test @@ -216,7 +221,7 @@ public void close_disconnects() { session.close(); // Then - verify(communicator, times(1)).disconnect(); + verify(communicator).disconnect(); } @Test @@ -229,6 +234,7 @@ public void onCall_unknownAction_callSendCallError() { eventHandler.onCall(someId, null, null); // Then - verify(communicator, times(1)).sendCallError(eq(someId), anyString(), anyString(), anyString()); + // TODO uniqueid should not be nullable + verify(communicator).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); } } diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SimpleRequestDispatcherTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SimpleRequestDispatcherTest.java index 511cafad1..8d230ab6d 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SimpleRequestDispatcherTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SimpleRequestDispatcherTest.java @@ -25,9 +25,8 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import eu.chargetime.ocpp.SessionEvents; @@ -35,10 +34,11 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.UnsupportedFeatureException; import eu.chargetime.ocpp.model.Confirmation; import java.util.concurrent.CompletableFuture; + import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class SimpleRequestDispatcherTest { @@ -65,6 +65,6 @@ public void fulfill_throwsException_completesWithException() throws UnsupportedF sut.fulfill(promise, eventsMock, null); // Then - assertThat(result[0], is(expectedException)); + assertEquals(result[0], expectedException); } } diff --git a/ocpp-v1_6/pom.xml b/ocpp-v1_6/pom.xml index 97dc7c344..ca3cac30b 100644 --- a/ocpp-v1_6/pom.xml +++ b/ocpp-v1_6/pom.xml @@ -71,7 +71,7 @@ org.mockito mockito-core - 1.10.19 + 4.11.0 test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientCoreProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientCoreProfileTest.java index 997d96537..bd2957cc8 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientCoreProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientCoreProfileTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP @@ -303,7 +303,7 @@ public void handleRequest_aChangeAvailabilityRequest_callsHandleChangeAvailabili core.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleChangeAvailabilityRequest(eq(request)); + verify(handler).handleChangeAvailabilityRequest(eq(request)); } @Test @@ -316,7 +316,7 @@ public void handleRequest_aChangeAvailabilityRequest_callsHandleChangeAvailabili core.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleRemoteStartTransactionRequest(eq(request)); + verify(handler).handleRemoteStartTransactionRequest(eq(request)); } @Test @@ -329,7 +329,7 @@ public void handleRequest_aChangeAvailabilityRequest_callsHandleChangeAvailabili core.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleRemoteStopTransactionRequest(eq(request)); + verify(handler).handleRemoteStopTransactionRequest(eq(request)); } @Test @@ -341,7 +341,7 @@ public void handleRequest_aResetRequest_callsHandleResetRequest() { core.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleResetRequest(eq(request)); + verify(handler).handleResetRequest(eq(request)); } @Test @@ -353,7 +353,7 @@ public void handleRequest_anUnlockConnectorRequest_callsHandleUnlockConnectorReq core.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleUnlockConnectorRequest(eq(request)); + verify(handler).handleUnlockConnectorRequest(eq(request)); } @Test @@ -380,7 +380,7 @@ public void handleRequest_aGetConfigurationRequest_callsHandleGetConfigurationRe core.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleGetConfigurationRequest(eq(request)); + verify(handler).handleGetConfigurationRequest(eq(request)); } @Test @@ -406,7 +406,7 @@ public void handleRequest_aDataTransferRequest_callsHandleDataTransferRequest() core.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleDataTransferRequest(eq(request)); + verify(handler).handleDataTransferRequest(eq(request)); } @Test @@ -431,7 +431,7 @@ public void handleRequest_aChangeConfigurationRequest_callsHandleChangeConfigura core.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleChangeConfigurationRequest(eq(request)); + verify(handler).handleChangeConfigurationRequest(eq(request)); } @Test @@ -457,7 +457,7 @@ public void handleRequest_aClearCacheRequest_callsHandleClearCacheRequest() { core.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleClearCacheRequest(request); + verify(handler).handleClearCacheRequest(request); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientFirmwareManagementProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientFirmwareManagementProfileTest.java index 07442192b..9f2cc15b0 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientFirmwareManagementProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientFirmwareManagementProfileTest.java @@ -29,7 +29,7 @@ of this software and associated documentation files (the "Software"), to deal import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -43,7 +43,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ClientFirmwareManagementProfileTest extends ProfileTest { @@ -86,7 +86,7 @@ public void handleRequest_aGetDiagnosticsRequest_callsHandleGetDiagnosticsReques profile.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleGetDiagnosticsRequest(eq(request)); + verify(handler).handleGetDiagnosticsRequest(eq(request)); } @Test @@ -98,7 +98,7 @@ public void handleRequest_aUpdateFirmwareRequest_callsHandleUpdateFirmwareReques profile.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleUpdateFirmwareRequest(eq(request)); + verify(handler).handleUpdateFirmwareRequest(eq(request)); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientLocalAuthListProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientLocalAuthListProfileTest.java index e4286b89e..6e9ab6eb3 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientLocalAuthListProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientLocalAuthListProfileTest.java @@ -28,7 +28,7 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -45,7 +45,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ClientLocalAuthListProfileTest extends ProfileTest { @@ -89,7 +89,7 @@ public void handleRequest_GetLocalListVersion_callsHandleGetLocalListVersionRequ profile.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleGetLocalListVersionRequest(eq(request)); + verify(handler).handleGetLocalListVersionRequest(eq(request)); } public void handleRequest_SendLocalList_callsHandleSendLocalListRequest() { @@ -100,6 +100,6 @@ public void handleRequest_SendLocalList_callsHandleSendLocalListRequest() { profile.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleSendLocalListRequest(eq(request)); + verify(handler).handleSendLocalListRequest(eq(request)); } } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientRemoteTriggerProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientRemoteTriggerProfileTest.java index f8b4d1800..d5ff48edd 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientRemoteTriggerProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientRemoteTriggerProfileTest.java @@ -16,7 +16,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP @@ -68,7 +68,7 @@ public void handleRequest_TriggerMessageReqest_callsHandleTriggerMessageReqestRe profile.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleTriggerMessageRequest(request); + verify(handler).handleTriggerMessageRequest(request); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientReservationProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientReservationProfileTest.java index 4edc50d6e..554765e1b 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientReservationProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientReservationProfileTest.java @@ -30,7 +30,7 @@ of this software and associated documentation files (the "Software"), to deal import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -47,7 +47,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ClientReservationProfileTest extends ProfileTest { @@ -89,7 +89,7 @@ public void handleRequest_aReserveNowRequest_callsHandleReserveNowRequest() { profile.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleReserveNowRequest(eq(request)); + verify(handler).handleReserveNowRequest(eq(request)); } @Test @@ -101,6 +101,6 @@ public void handleRequest_aCancelReservationRequest_callsHandleCancelReservation profile.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleCancelReservationRequest(eq(request)); + verify(handler).handleCancelReservationRequest(eq(request)); } } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientSmartChargingProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientSmartChargingProfileTest.java index 47e74d51d..038f6c4a7 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientSmartChargingProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientSmartChargingProfileTest.java @@ -14,7 +14,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP @@ -65,7 +65,7 @@ public void handleRequest_SetChargingProfileRequest_callsHandleSetChargingProfil smartCharging.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleSetChargingProfileRequest(request); + verify(handler).handleSetChargingProfileRequest(request); } @Test @@ -91,7 +91,7 @@ public void handleRequest_GetCompositeSchedule_callsHandleGetCompositeScheduleRe smartCharging.handleRequest(SESSION_NULL, request); // Then - verify(handler, times(1)).handleGetCompositeScheduleRequest(request); + verify(handler).handleGetCompositeScheduleRequest(request); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerCoreProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerCoreProfileTest.java index 9e8c6370c..e3d224fb7 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerCoreProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerCoreProfileTest.java @@ -3,7 +3,7 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -17,7 +17,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP @@ -77,7 +77,7 @@ public void handleRequest_anAuthorizeRequest_callsHandleAuthorizeRequest() { core.handleRequest(sessionId, request); // Then - verify(handler, times(1)).handleAuthorizeRequest(eq(sessionId), eq(request)); + verify(handler).handleAuthorizeRequest(eq(sessionId), eq(request)); } @Test @@ -100,7 +100,7 @@ public void handleRequest_aBootNotificationRequest_callsHandleBootNotificationRe core.handleRequest(sessionId, request); // Then - verify(handler, times(1)).handleBootNotificationRequest(eq(sessionId), eq(request)); + verify(handler).handleBootNotificationRequest(eq(sessionId), eq(request)); } @Test @@ -202,7 +202,7 @@ public void handleRequest_aDataTransferRequest_callsHandleDataTransferRequest() core.handleRequest(sessionId, request); // Then - verify(handler, times(1)).handleDataTransferRequest(eq(sessionId), eq(request)); + verify(handler).handleDataTransferRequest(eq(sessionId), eq(request)); } @Test @@ -244,7 +244,7 @@ public void handleRequest_aHeartbeatRequest_callsHandleHeartbeatRequest() { core.handleRequest(sessionId, request); // Then - verify(handler, times(1)).handleHeartbeatRequest(eq(sessionId), eq(request)); + verify(handler).handleHeartbeatRequest(eq(sessionId), eq(request)); } @Test @@ -266,7 +266,7 @@ public void handleRequest_aMeterValuesRequest_callsHandleMeterValuesRequest() { core.handleRequest(sessionId, request); // Then - verify(handler, times(1)).handleMeterValuesRequest(eq(sessionId), eq(request)); + verify(handler).handleMeterValuesRequest(eq(sessionId), eq(request)); } @Test @@ -359,7 +359,7 @@ public void handleRequest_aStartTransactionRequest_callsHandleStartTransactionRe core.handleRequest(sessionId, request); // Then - verify(handler, times(1)).handleStartTransactionRequest(eq(sessionId), eq(request)); + verify(handler).handleStartTransactionRequest(eq(sessionId), eq(request)); } @Test @@ -385,7 +385,7 @@ public void handleRequest_aStatusNotificationRequest_callsHandleStatusNotificati core.handleRequest(sessionId, request); // Then - verify(handler, times(1)).handleStatusNotificationRequest(eq(sessionId), eq(request)); + verify(handler).handleStatusNotificationRequest(eq(sessionId), eq(request)); } @Test @@ -408,7 +408,7 @@ public void handleRequest_aStopTransactionRequest_callsHandleStopTransactionRequ core.handleRequest(sessionId, request); // Then - verify(handler, times(1)).handleStopTransactionRequest(eq(sessionId), eq(request)); + verify(handler).handleStopTransactionRequest(eq(sessionId), eq(request)); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerFirmwareManagementProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerFirmwareManagementProfileTest.java index b937ad829..06a9608df 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerFirmwareManagementProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerFirmwareManagementProfileTest.java @@ -28,7 +28,7 @@ of this software and associated documentation files (the "Software"), to deal import static org.hamcrest.CoreMatchers.instanceOf; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -45,7 +45,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ServerFirmwareManagementProfileTest extends ProfileTest { @@ -92,8 +92,7 @@ public void getFeatureList_containsFirmwareStatusNotificationFeature() { profile.handleRequest(sessionId, request); // Then - verify(handler, times(1)) - .handleDiagnosticsStatusNotificationRequest(eq(sessionId), eq(request)); + verify(handler).handleDiagnosticsStatusNotificationRequest(eq(sessionId), eq(request)); } @Test @@ -108,6 +107,6 @@ public void getFeatureList_containsFirmwareStatusNotificationFeature() { profile.handleRequest(sessionId, request); // Then - verify(handler, times(1)).handleFirmwareStatusNotificationRequest(eq(sessionId), eq(request)); + verify(handler).handleFirmwareStatusNotificationRequest(eq(sessionId), eq(request)); } } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerLocalAuthListProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerLocalAuthListProfileTest.java index 71576d009..be68e20a1 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerLocalAuthListProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerLocalAuthListProfileTest.java @@ -37,7 +37,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ServerLocalAuthListProfileTest extends ProfileTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerRemoteTriggerProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerRemoteTriggerProfileTest.java index 777eb98b3..f9fcc9f86 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerRemoteTriggerProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerRemoteTriggerProfileTest.java @@ -12,7 +12,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerReservationProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerReservationProfileTest.java index eec5a27bb..47bbcae17 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerReservationProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerReservationProfileTest.java @@ -36,7 +36,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ServerReservationProfileTest extends ProfileTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerSmartChargingProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerSmartChargingProfileTest.java index 8ab9297b8..582972935 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerSmartChargingProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerSmartChargingProfileTest.java @@ -14,7 +14,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ClientSecurityExtProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ClientSecurityExtProfileTest.java index 95c98fe0d..3378c66f8 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ClientSecurityExtProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ClientSecurityExtProfileTest.java @@ -40,8 +40,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - +import org.mockito.junit.MockitoJUnitRunner; import java.time.ZonedDateTime; import java.util.UUID; diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ServerSecurityExtProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ServerSecurityExtProfileTest.java index 85e74f702..7aa325283 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ServerSecurityExtProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ServerSecurityExtProfileTest.java @@ -41,8 +41,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - +import org.mockito.junit.MockitoJUnitRunner; import java.util.UUID; import static org.junit.Assert.assertEquals; diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionConfirmationTest.java index db8bace37..326a1d132 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionConfirmationTest.java @@ -11,7 +11,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class GetLocalListVersionConfirmationTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionRequestTest.java index c1a6eb086..1e0541d67 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionRequestTest.java @@ -8,7 +8,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class GetLocalListVersionRequestTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListConfirmationTest.java index aba577136..c106aa1dc 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListConfirmationTest.java @@ -12,7 +12,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class SendLocalListConfirmationTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListRequestTest.java index b46545cd2..aaa95c648 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListRequestTest.java @@ -20,7 +20,7 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class SendLocalListRequestTest { @@ -120,8 +120,8 @@ public void validate_updateTypeFullWithTagInfo_isValid() { // Then assertThat(request.validate(), equalTo(true)); - verify(data, times(1)).getIdTagInfo(); - verify(data, times(1)).validate(); + verify(data).getIdTagInfo(); + verify(data).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/AuthorizeConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/AuthorizeConfirmationTest.java index 5d798c3d2..e082d32e3 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/AuthorizeConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/AuthorizeConfirmationTest.java @@ -11,7 +11,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP @@ -69,6 +69,6 @@ public void validate_idTagInfoSet_callsValidateOnIdTagInfo() { confirmation.validate(); // Then - verify(infoTag, times(1)).validate(); + verify(infoTag).validate(); } } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/ChargingScheduleTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/ChargingScheduleTest.java index 2088c6b8a..16f3075cc 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/ChargingScheduleTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/ChargingScheduleTest.java @@ -120,7 +120,7 @@ public void validate_chargingSchedulePeriodIsSet_chargingSchedulePeriodIsValidat chargingSchedule.validate(); // Then - verify(chargingSchedulePeriod, times(1)).validate(); + verify(chargingSchedulePeriod).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetCompositeScheduleRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetCompositeScheduleRequestTest.java index 1baeaad2b..3d6d4b717 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetCompositeScheduleRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetCompositeScheduleRequestTest.java @@ -11,7 +11,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetConfigurationConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetConfigurationConfirmationTest.java index 6e31752d2..dd63c627d 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetConfigurationConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetConfigurationConfirmationTest.java @@ -135,7 +135,7 @@ public void validate_configurationKeyIsSet_configurationKeyIsValidated() { confirmation.validate(); // Then - verify(keyValueType, times(1)).validate(); + verify(keyValueType).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValueTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValueTest.java index f5643ad0b..93e4e0848 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValueTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValueTest.java @@ -13,7 +13,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP @@ -84,7 +84,7 @@ public void validate_sampledValueIsSet_validatesSampledValue() { meterValue.validate(); // Then - verify(sampledValueMock, times(1)).validate(); + verify(sampledValueMock).validate(); } @Test @@ -107,7 +107,7 @@ public void validate_missingTimestamp_returnFalse() { // Given meterValue.setSampledValue(aList(sampledValueMock)); - when(sampledValueMock.validate()).thenReturn(true); + lenient().when(sampledValueMock.validate()).thenReturn(true); // When boolean isValid = meterValue.validate(); diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValuesRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValuesRequestTest.java index bcb50c849..b4ef707ea 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValuesRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValuesRequestTest.java @@ -14,7 +14,7 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP @@ -123,7 +123,7 @@ public void validate_meterValueIsSet_validatesMeterValue() { request.validate(); // Then - verify(meterValueMock, times(1)).validate(); + verify(meterValueMock).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/RemoteStartTransactionRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/RemoteStartTransactionRequestTest.java index fbbd3c7f1..e19cf6bce 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/RemoteStartTransactionRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/RemoteStartTransactionRequestTest.java @@ -137,7 +137,7 @@ public void validate_chargingProfileIsSet_chargingsProfileIsValidated() { request.validate(); // Then - verify(chargingProfile, times(1)).validate(); + verify(chargingProfile).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StartTransactionConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StartTransactionConfirmationTest.java index 69142d461..d1d9fc1e4 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StartTransactionConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StartTransactionConfirmationTest.java @@ -113,7 +113,7 @@ public void validate_idTagInfoAndTransactionIdIsSet_idTagInfoIsValidated() { confirmation.validate(); // Then - verify(idTagInfo, times(1)).validate(); + verify(idTagInfo).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionConfirmationTest.java index 040e7c1d2..a5189eec8 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionConfirmationTest.java @@ -74,7 +74,7 @@ public void validate_idTagInfoIsSet_idTagInfoIsValidated() { confirmation.validate(); // Then - verify(idTagInfo, times(1)).validate(); + verify(idTagInfo).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionRequestTest.java index 559ff95fb..6d36e7e6d 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionRequestTest.java @@ -182,7 +182,7 @@ public void validate_transactionDataIsSet_transactionDataIsValidated() { request.validate(); // Then - verify(meterValue, times(1)).validate(); + verify(meterValue).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/JSONCommunicatorTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/JSONCommunicatorTest.java index 20aba0130..07b8d1b88 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/JSONCommunicatorTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/JSONCommunicatorTest.java @@ -19,7 +19,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP @@ -300,7 +300,7 @@ public void disconnect_disconnects() { communicator.disconnect(); // Then - verify(transmitter, times(1)).disconnect(); + verify(transmitter).disconnect(); } @Test @@ -313,7 +313,7 @@ public void sendError_transmitsError() throws Exception { communicator.sendCallError(null, null, errorCode, errorDescription); // Then - verify(transmitter, times(1)).send(anyString()); + verify(transmitter).send(anyString()); } private ZonedDateTime createDateTimeInMillis(long dateInMillis) { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/SOAPCommunicatorTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/SOAPCommunicatorTest.java index 848974b3c..05e2b3e5a 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/SOAPCommunicatorTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/SOAPCommunicatorTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.w3c.dom.Document; import org.xml.sax.InputSource; diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/TimeoutSessionTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/TimeoutSessionTest.java index 9f33fe77d..a715d06c1 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/TimeoutSessionTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/TimeoutSessionTest.java @@ -1,6 +1,6 @@ package eu.chargetime.ocpp.test; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; import eu.chargetime.ocpp.ISession; @@ -11,7 +11,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP @@ -50,10 +50,10 @@ public class TimeoutSessionTest { @Before public void setup() throws Exception { session = new TimeoutSessionDecorator(timeoutTimer, sessionMock); - doAnswer(invocation -> sessionEvents = invocation.getArgumentAt(0, SessionEvents.class)) + doAnswer(invocation -> sessionEvents = invocation.getArgument(0, SessionEvents.class)) .when(sessionMock) .accept(any()); - doAnswer(invocation -> sessionEvents = invocation.getArgumentAt(1, SessionEvents.class)) + doAnswer(invocation -> sessionEvents = invocation.getArgument(1, SessionEvents.class)) .when(sessionMock) .open(any(), any()); } @@ -67,7 +67,7 @@ public void handleConnectionOpened_opened_beginTimeout() throws Exception { sessionEvents.handleConnectionOpened(); // Then - verify(timeoutTimer, times(1)).begin(); + verify(timeoutTimer).begin(); } @Test @@ -79,7 +79,7 @@ public void handleConnectionClosed_opened_endTimeout() throws Exception { sessionEvents.handleConnectionClosed(); // Then - verify(timeoutTimer, times(1)).end(); + verify(timeoutTimer).end(); } @Test @@ -91,7 +91,7 @@ public void handleConnectionOpened_accepted_beginTimeout() throws Exception { sessionEvents.handleConnectionOpened(); // Then - verify(timeoutTimer, times(1)).begin(); + verify(timeoutTimer).begin(); } @Test @@ -103,7 +103,7 @@ public void handleConnectionClosed_accepted_endTimeout() throws Exception { sessionEvents.handleConnectionClosed(); // Then - verify(timeoutTimer, times(1)).end(); + verify(timeoutTimer).end(); } @Test @@ -115,7 +115,7 @@ public void handleRequest_any_resetTimeout() throws Exception { sessionEvents.handleRequest(null); // Then - verify(timeoutTimer, times(1)).reset(); + verify(timeoutTimer).reset(); } @Test @@ -127,6 +127,6 @@ public void handleConfirmation_any_resetTimeout() throws Exception { sessionEvents.handleConfirmation(null, null); // Then - verify(timeoutTimer, times(1)).reset(); + verify(timeoutTimer).reset(); } } diff --git a/ocpp-v2-test/pom.xml b/ocpp-v2-test/pom.xml index 235a1c404..056f3e1ba 100644 --- a/ocpp-v2-test/pom.xml +++ b/ocpp-v2-test/pom.xml @@ -85,7 +85,7 @@ org.mockito mockito-core - 1.10.19 + 4.11.0 test diff --git a/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolIntegrationTest.java b/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolIntegrationTest.java index 41cc59b73..e2a2f0635 100644 --- a/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolIntegrationTest.java +++ b/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolIntegrationTest.java @@ -42,7 +42,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /** multiple protocol capable client and server integration test up to OCPP 2.0.1 */ @RunWith(MockitoJUnitRunner.class) diff --git a/ocpp-v2/pom.xml b/ocpp-v2/pom.xml index 3104cb90a..df5596931 100644 --- a/ocpp-v2/pom.xml +++ b/ocpp-v2/pom.xml @@ -81,7 +81,7 @@ org.mockito mockito-core - 1.10.19 + 4.11.0 test diff --git a/ocpp-v2_0/pom.xml b/ocpp-v2_0/pom.xml index e531addcf..94e70c886 100644 --- a/ocpp-v2_0/pom.xml +++ b/ocpp-v2_0/pom.xml @@ -71,7 +71,7 @@ org.mockito mockito-core - 1.10.19 + 4.11.0 test diff --git a/ocpp-v2_0/src/test/java/eu/chargetime/ocpp/model/basic/test/BootNotificationRequestTest.java b/ocpp-v2_0/src/test/java/eu/chargetime/ocpp/model/basic/test/BootNotificationRequestTest.java index 6999c66d7..bd001be6e 100644 --- a/ocpp-v2_0/src/test/java/eu/chargetime/ocpp/model/basic/test/BootNotificationRequestTest.java +++ b/ocpp-v2_0/src/test/java/eu/chargetime/ocpp/model/basic/test/BootNotificationRequestTest.java @@ -35,7 +35,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class BootNotificationRequestTest { From 4f120303acacc0540fddc899e7ceb27e38e99809 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 15 Oct 2023 14:11:39 +0200 Subject: [PATCH 2/3] Update also Gradle build used by CodeQL GHA --- OCPP-J/build.gradle | 4 ++-- ocpp-common/build.gradle | 4 ++-- ocpp-v1_6/build.gradle | 6 +++--- ocpp-v2-test/build.gradle | 4 ++-- ocpp-v2/build.gradle | 4 ++-- ocpp-v2_0/build.gradle | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/OCPP-J/build.gradle b/OCPP-J/build.gradle index c96ef980f..90a522759 100644 --- a/OCPP-J/build.gradle +++ b/OCPP-J/build.gradle @@ -6,8 +6,8 @@ dependencies { compile project(':common') compile 'com.google.code.gson:gson:2.8.0' compile 'org.java-websocket:Java-WebSocket:1.5.3' - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + testCompile 'junit:junit:4.13.2' + testCompile 'org.mockito:mockito-core:4.11.0' testCompile 'org.hamcrest:hamcrest-core:1.3' } diff --git a/ocpp-common/build.gradle b/ocpp-common/build.gradle index 18b6757ca..88c6566f7 100644 --- a/ocpp-common/build.gradle +++ b/ocpp-common/build.gradle @@ -5,8 +5,8 @@ dependencies { compile group: 'javax.xml.soap', name: 'javax.xml.soap-api', version: '1.4.0' compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.1' - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + testCompile 'junit:junit:4.13.2' + testCompile 'org.mockito:mockito-core:4.11.0' testCompile 'org.hamcrest:hamcrest-all:1.3' } diff --git a/ocpp-v1_6/build.gradle b/ocpp-v1_6/build.gradle index a324cfb3d..6d7b823e4 100644 --- a/ocpp-v1_6/build.gradle +++ b/ocpp-v1_6/build.gradle @@ -7,9 +7,9 @@ dependencies { compile project(':OCPP-J') compile 'org.java-websocket:Java-WebSocket:1.5.3' compile group: 'javax.xml.soap', name: 'javax.xml.soap-api', version: '1.4.0' - - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + + testCompile 'junit:junit:4.13.2' + testCompile 'org.mockito:mockito-core:4.11.0' testCompile 'org.hamcrest:hamcrest-core:1.3' } diff --git a/ocpp-v2-test/build.gradle b/ocpp-v2-test/build.gradle index 8db4729d5..3ebd002dc 100644 --- a/ocpp-v2-test/build.gradle +++ b/ocpp-v2-test/build.gradle @@ -8,8 +8,8 @@ dependencies { compile project(':v1_6-test') compile project(':ocpp-v2') compile 'com.google.code.findbugs:jsr305:3.0.1' - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + testCompile 'junit:junit:4.13.2' + testCompile 'org.mockito:mockito-core:4.11.0' testCompile 'org.hamcrest:hamcrest-core:1.3' } diff --git a/ocpp-v2/build.gradle b/ocpp-v2/build.gradle index cf284dd60..666c85463 100644 --- a/ocpp-v2/build.gradle +++ b/ocpp-v2/build.gradle @@ -8,8 +8,8 @@ dependencies { compile project(':v1_6') compile 'com.google.code.findbugs:jsr305:3.0.1' compile 'org.java-websocket:Java-WebSocket:1.5.3' - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + testCompile 'junit:junit:4.13.2' + testCompile 'org.mockito:mockito-core:4.11.0' testCompile 'org.hamcrest:hamcrest-core:1.3' } diff --git a/ocpp-v2_0/build.gradle b/ocpp-v2_0/build.gradle index 1026b166d..2d831fe5d 100644 --- a/ocpp-v2_0/build.gradle +++ b/ocpp-v2_0/build.gradle @@ -6,8 +6,8 @@ dependencies { compile project(':common') compile project(':OCPP-J') compile 'org.java-websocket:Java-WebSocket:1.5.3' - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + testCompile 'junit:junit:4.13.2' + testCompile 'org.mockito:mockito-core:4.11.0' testCompile 'org.hamcrest:hamcrest-core:1.3' } From 0d014bca7702c6b11bdbaa700c30492f66608e30 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Mon, 16 Oct 2023 10:55:46 +0200 Subject: [PATCH 3/3] Revert not necessary for Mockito code cleanups --- .../eu/chargetime/ocpp/test/ClientTest.java | 12 ++++++------ .../chargetime/ocpp/test/CommunicatorTest.java | 6 +++--- .../eu/chargetime/ocpp/test/ServerTest.java | 11 +++++------ .../eu/chargetime/ocpp/test/SessionTest.java | 18 +++++++++--------- .../ocpp/test/SimpleRequestDispatcherTest.java | 6 +++--- .../profile/test/ClientCoreProfileTest.java | 18 +++++++++--------- .../ClientFirmwareManagementProfileTest.java | 4 ++-- .../test/ClientLocalAuthListProfileTest.java | 4 ++-- .../test/ClientRemoteTriggerProfileTest.java | 2 +- .../test/ClientReservationProfileTest.java | 4 ++-- .../test/ClientSmartChargingProfileTest.java | 4 ++-- .../profile/test/ServerCoreProfileTest.java | 16 ++++++++-------- .../ServerFirmwareManagementProfileTest.java | 5 +++-- .../test/SendLocalListRequestTest.java | 4 ++-- .../model/test/AuthorizeConfirmationTest.java | 2 +- .../ocpp/model/test/ChargingScheduleTest.java | 2 +- .../test/GetConfigurationConfirmationTest.java | 2 +- .../ocpp/model/test/MeterValueTest.java | 2 +- .../model/test/MeterValuesRequestTest.java | 2 +- .../RemoteStartTransactionRequestTest.java | 2 +- .../test/StartTransactionConfirmationTest.java | 2 +- .../test/StopTransactionConfirmationTest.java | 2 +- .../model/test/StopTransactionRequestTest.java | 2 +- .../ocpp/test/JSONCommunicatorTest.java | 4 ++-- .../ocpp/test/TimeoutSessionTest.java | 12 ++++++------ 25 files changed, 74 insertions(+), 74 deletions(-) diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java index 45baf02fc..4c6aebd08 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java @@ -77,7 +77,7 @@ public void connect_connects() { client.connect(someUrl, events); // Then - verify(session).open(eq(someUrl), any()); + verify(session, times(1)).open(eq(someUrl), any()); } @Test @@ -89,7 +89,7 @@ public void connect_connectionOpenedEvent() { this.eventHandler.handleConnectionOpened(); // Then - verify(events).connectionOpened(); + verify(events, times(1)).connectionOpened(); verify(events, never()).connectionClosed(); } @@ -102,7 +102,7 @@ public void connect_connectionClosedEvent() { this.eventHandler.handleConnectionClosed(); // Then - verify(events).connectionClosed(); + verify(events, times(1)).connectionClosed(); verify(events, never()).connectionOpened(); } @@ -113,7 +113,7 @@ public void send_aMessage_isCommunicated() throws Exception { // Then // TODO action and uuid should not be nullable - verify(session).sendRequest(nullable(String.class), eq(request), nullable(String.class)); + verify(session, times(1)).sendRequest(nullable(String.class), eq(request), nullable(String.class)); } @Test @@ -153,7 +153,7 @@ public void handleRequest_callsFeatureHandleRequest() throws UnsupportedFeatureE eventHandler.handleRequest(request); // Then - verify(feature).handleRequest(any(), eq(request)); + verify(feature, times(1)).handleRequest(any(), eq(request)); } @Test @@ -162,6 +162,6 @@ public void send_aMessage_validatesMessage() throws Exception { client.send(request); // Then - verify(request).validate(); + verify(request, times(1)).validate(); } } diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java index e44a5eb4e..b506f608e 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java @@ -126,7 +126,7 @@ public void sendCall_aNormalRequestAndRadioThrowsNotConnectedException_onErrorIs communicator.sendCall(uniqueId, action, normalRequest); // Then - verify(events).onError(eq(uniqueId), any(), any(), any()); + verify(events, times(1)).onError(eq(uniqueId), any(), any(), any()); } @Test @@ -164,7 +164,7 @@ public void sendCall_queueNotEmpty_messagesAreProcessInSequence() throws Excepti // Then verify(receiver, times(2)).send(eq(firstId)); - verify(receiver).send(eq(secondId)); + verify(receiver, times(1)).send(eq(secondId)); } @Test @@ -222,7 +222,7 @@ public boolean validate() { communicator.sendCallResult(uniqueId, action, conf); // Then - verify(handler).onConfirmationCompleted(); + verify(handler, times(1)).onConfirmationCompleted(); } @Test diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java index 3d9b379a7..1fedbe141 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java @@ -65,7 +65,6 @@ public void setup() { UUID sessionId = UUID.randomUUID(); when(request.validate()).thenReturn(true); when(session.getSessionId()).thenReturn(sessionId); -// when(session.storeRequest(any())).thenReturn(UUID.randomUUID().toString()); doAnswer(invocation -> listenerEvents = invocation.getArgument(2, ListenerEvents.class)) .when(listener) .open(anyString(), anyInt(), any()); @@ -90,7 +89,7 @@ public void newSession_serverIsListening_sessionIsAccepted() { listenerEvents.newSession(session, information); // Then - verify(session).accept(any()); + verify(session, times(1)).accept(any()); } @Test @@ -102,7 +101,7 @@ public void newSession_serverIsListening_callbackWithIndex0() { listenerEvents.newSession(session, information); // Then - verify(serverEvents).newSession(any(UUID.class), eq(information)); + verify(serverEvents, times(1)).newSession(any(UUID.class), eq(information)); } @Test @@ -116,7 +115,7 @@ public void send_aMessage_isCommunicated() throws Exception { // Then // TODO action and uuid should not be nullable - verify(session).sendRequest(nullable(String.class), eq(request), nullable(String.class)); + verify(session, times(1)).sendRequest(nullable(String.class), eq(request), nullable(String.class)); } @Test @@ -129,7 +128,7 @@ public void handleRequest_callsFeatureHandleRequest() throws UnsupportedFeatureE sessionEvents.handleRequest(request); // Then - verify(feature).handleRequest(any(UUID.class), eq(request)); + verify(feature, times(1)).handleRequest(any(UUID.class), eq(request)); } @Test @@ -142,6 +141,6 @@ public void send_aMessage_validatesMessage() throws Exception { server.send(sessionIndex, request); // Then - verify(request).validate(); + verify(request, times(1)).validate(); } } diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java index 1a616bf5e..24e92ec7d 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java @@ -104,7 +104,7 @@ public boolean validate() { // Then // TODO uniqueid should not be nullable - verify(communicator).sendCall(nullable(String.class), eq(someAction), eq(someRequest)); + verify(communicator, times(1)).sendCall(nullable(String.class), eq(someAction), eq(someRequest)); } @Test @@ -117,7 +117,7 @@ public void sendRequest_someUniqueId_sendsUniqueIdToCommunicator() { // Then // TODO uuid and request should not be nullable - verify(communicator).sendCall(eq(someUniqueId), nullable(String.class), nullable(Request.class)); + verify(communicator, times(1)).sendCall(eq(someUniqueId), nullable(String.class), nullable(Request.class)); } @Test @@ -136,7 +136,7 @@ public boolean validate() { session.sendConfirmation(someUniqueId, action, conf); // Then - verify(communicator).sendCallResult(eq(someUniqueId), eq(action), eq(conf)); + verify(communicator, times(1)).sendCallResult(eq(someUniqueId), eq(action), eq(conf)); } @Test @@ -148,7 +148,7 @@ public void open_connectsViaCommunicator() { session.open(someUri, null); // Then - verify(communicator).connect(eq(someUri), any()); + verify(communicator, times(1)).connect(eq(someUri), any()); } @Test @@ -165,7 +165,7 @@ public void onCall_unhandledCallback_callSendCallError() throws Exception { // then // TODO action should not be nullable - verify(communicator).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); + verify(communicator, times(1)).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); } @Test @@ -191,7 +191,7 @@ public boolean validate() { // then // TODO action should not be nullable - verify(communicator).sendCallResult(anyString(), nullable(String.class), eq(aConfirmation)); + verify(communicator, times(1)).sendCallResult(anyString(), nullable(String.class), eq(aConfirmation)); } @Test @@ -212,7 +212,7 @@ public void onCall_callbackThrowsException_callSendCallResult() throws Exception // then // TODO uniqueid should not be nullable - verify(communicator).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); + verify(communicator, times(1)).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); } @Test @@ -221,7 +221,7 @@ public void close_disconnects() { session.close(); // Then - verify(communicator).disconnect(); + verify(communicator, times(1)).disconnect(); } @Test @@ -235,6 +235,6 @@ public void onCall_unknownAction_callSendCallError() { // Then // TODO uniqueid should not be nullable - verify(communicator).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); + verify(communicator, times(1)).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); } } diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SimpleRequestDispatcherTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SimpleRequestDispatcherTest.java index 8d230ab6d..030808ab9 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SimpleRequestDispatcherTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SimpleRequestDispatcherTest.java @@ -25,7 +25,8 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ -import static org.junit.Assert.assertEquals; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; @@ -34,7 +35,6 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.UnsupportedFeatureException; import eu.chargetime.ocpp.model.Confirmation; import java.util.concurrent.CompletableFuture; - import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -65,6 +65,6 @@ public void fulfill_throwsException_completesWithException() throws UnsupportedF sut.fulfill(promise, eventsMock, null); // Then - assertEquals(result[0], expectedException); + assertThat(result[0], is(expectedException)); } } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientCoreProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientCoreProfileTest.java index bd2957cc8..d0c73ae61 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientCoreProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientCoreProfileTest.java @@ -303,7 +303,7 @@ public void handleRequest_aChangeAvailabilityRequest_callsHandleChangeAvailabili core.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleChangeAvailabilityRequest(eq(request)); + verify(handler, times(1)).handleChangeAvailabilityRequest(eq(request)); } @Test @@ -316,7 +316,7 @@ public void handleRequest_aChangeAvailabilityRequest_callsHandleChangeAvailabili core.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleRemoteStartTransactionRequest(eq(request)); + verify(handler, times(1)).handleRemoteStartTransactionRequest(eq(request)); } @Test @@ -329,7 +329,7 @@ public void handleRequest_aChangeAvailabilityRequest_callsHandleChangeAvailabili core.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleRemoteStopTransactionRequest(eq(request)); + verify(handler, times(1)).handleRemoteStopTransactionRequest(eq(request)); } @Test @@ -341,7 +341,7 @@ public void handleRequest_aResetRequest_callsHandleResetRequest() { core.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleResetRequest(eq(request)); + verify(handler, times(1)).handleResetRequest(eq(request)); } @Test @@ -353,7 +353,7 @@ public void handleRequest_anUnlockConnectorRequest_callsHandleUnlockConnectorReq core.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleUnlockConnectorRequest(eq(request)); + verify(handler, times(1)).handleUnlockConnectorRequest(eq(request)); } @Test @@ -380,7 +380,7 @@ public void handleRequest_aGetConfigurationRequest_callsHandleGetConfigurationRe core.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleGetConfigurationRequest(eq(request)); + verify(handler, times(1)).handleGetConfigurationRequest(eq(request)); } @Test @@ -406,7 +406,7 @@ public void handleRequest_aDataTransferRequest_callsHandleDataTransferRequest() core.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleDataTransferRequest(eq(request)); + verify(handler, times(1)).handleDataTransferRequest(eq(request)); } @Test @@ -431,7 +431,7 @@ public void handleRequest_aChangeConfigurationRequest_callsHandleChangeConfigura core.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleChangeConfigurationRequest(eq(request)); + verify(handler, times(1)).handleChangeConfigurationRequest(eq(request)); } @Test @@ -457,7 +457,7 @@ public void handleRequest_aClearCacheRequest_callsHandleClearCacheRequest() { core.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleClearCacheRequest(request); + verify(handler, times(1)).handleClearCacheRequest(request); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientFirmwareManagementProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientFirmwareManagementProfileTest.java index 9f2cc15b0..dc18611e1 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientFirmwareManagementProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientFirmwareManagementProfileTest.java @@ -86,7 +86,7 @@ public void handleRequest_aGetDiagnosticsRequest_callsHandleGetDiagnosticsReques profile.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleGetDiagnosticsRequest(eq(request)); + verify(handler, times(1)).handleGetDiagnosticsRequest(eq(request)); } @Test @@ -98,7 +98,7 @@ public void handleRequest_aUpdateFirmwareRequest_callsHandleUpdateFirmwareReques profile.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleUpdateFirmwareRequest(eq(request)); + verify(handler, times(1)).handleUpdateFirmwareRequest(eq(request)); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientLocalAuthListProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientLocalAuthListProfileTest.java index 6e9ab6eb3..2c6837a40 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientLocalAuthListProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientLocalAuthListProfileTest.java @@ -89,7 +89,7 @@ public void handleRequest_GetLocalListVersion_callsHandleGetLocalListVersionRequ profile.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleGetLocalListVersionRequest(eq(request)); + verify(handler, times(1)).handleGetLocalListVersionRequest(eq(request)); } public void handleRequest_SendLocalList_callsHandleSendLocalListRequest() { @@ -100,6 +100,6 @@ public void handleRequest_SendLocalList_callsHandleSendLocalListRequest() { profile.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleSendLocalListRequest(eq(request)); + verify(handler, times(1)).handleSendLocalListRequest(eq(request)); } } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientRemoteTriggerProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientRemoteTriggerProfileTest.java index d5ff48edd..b5055d5fd 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientRemoteTriggerProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientRemoteTriggerProfileTest.java @@ -68,7 +68,7 @@ public void handleRequest_TriggerMessageReqest_callsHandleTriggerMessageReqestRe profile.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleTriggerMessageRequest(request); + verify(handler, times(1)).handleTriggerMessageRequest(request); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientReservationProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientReservationProfileTest.java index 554765e1b..dcc33dd97 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientReservationProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientReservationProfileTest.java @@ -89,7 +89,7 @@ public void handleRequest_aReserveNowRequest_callsHandleReserveNowRequest() { profile.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleReserveNowRequest(eq(request)); + verify(handler, times(1)).handleReserveNowRequest(eq(request)); } @Test @@ -101,6 +101,6 @@ public void handleRequest_aCancelReservationRequest_callsHandleCancelReservation profile.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleCancelReservationRequest(eq(request)); + verify(handler, times(1)).handleCancelReservationRequest(eq(request)); } } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientSmartChargingProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientSmartChargingProfileTest.java index 038f6c4a7..31378f1f8 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientSmartChargingProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientSmartChargingProfileTest.java @@ -65,7 +65,7 @@ public void handleRequest_SetChargingProfileRequest_callsHandleSetChargingProfil smartCharging.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleSetChargingProfileRequest(request); + verify(handler, times(1)).handleSetChargingProfileRequest(request); } @Test @@ -91,7 +91,7 @@ public void handleRequest_GetCompositeSchedule_callsHandleGetCompositeScheduleRe smartCharging.handleRequest(SESSION_NULL, request); // Then - verify(handler).handleGetCompositeScheduleRequest(request); + verify(handler, times(1)).handleGetCompositeScheduleRequest(request); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerCoreProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerCoreProfileTest.java index e3d224fb7..576847456 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerCoreProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerCoreProfileTest.java @@ -77,7 +77,7 @@ public void handleRequest_anAuthorizeRequest_callsHandleAuthorizeRequest() { core.handleRequest(sessionId, request); // Then - verify(handler).handleAuthorizeRequest(eq(sessionId), eq(request)); + verify(handler, times(1)).handleAuthorizeRequest(eq(sessionId), eq(request)); } @Test @@ -100,7 +100,7 @@ public void handleRequest_aBootNotificationRequest_callsHandleBootNotificationRe core.handleRequest(sessionId, request); // Then - verify(handler).handleBootNotificationRequest(eq(sessionId), eq(request)); + verify(handler, times(1)).handleBootNotificationRequest(eq(sessionId), eq(request)); } @Test @@ -202,7 +202,7 @@ public void handleRequest_aDataTransferRequest_callsHandleDataTransferRequest() core.handleRequest(sessionId, request); // Then - verify(handler).handleDataTransferRequest(eq(sessionId), eq(request)); + verify(handler, times(1)).handleDataTransferRequest(eq(sessionId), eq(request)); } @Test @@ -244,7 +244,7 @@ public void handleRequest_aHeartbeatRequest_callsHandleHeartbeatRequest() { core.handleRequest(sessionId, request); // Then - verify(handler).handleHeartbeatRequest(eq(sessionId), eq(request)); + verify(handler, times(1)).handleHeartbeatRequest(eq(sessionId), eq(request)); } @Test @@ -266,7 +266,7 @@ public void handleRequest_aMeterValuesRequest_callsHandleMeterValuesRequest() { core.handleRequest(sessionId, request); // Then - verify(handler).handleMeterValuesRequest(eq(sessionId), eq(request)); + verify(handler, times(1)).handleMeterValuesRequest(eq(sessionId), eq(request)); } @Test @@ -359,7 +359,7 @@ public void handleRequest_aStartTransactionRequest_callsHandleStartTransactionRe core.handleRequest(sessionId, request); // Then - verify(handler).handleStartTransactionRequest(eq(sessionId), eq(request)); + verify(handler, times(1)).handleStartTransactionRequest(eq(sessionId), eq(request)); } @Test @@ -385,7 +385,7 @@ public void handleRequest_aStatusNotificationRequest_callsHandleStatusNotificati core.handleRequest(sessionId, request); // Then - verify(handler).handleStatusNotificationRequest(eq(sessionId), eq(request)); + verify(handler, times(1)).handleStatusNotificationRequest(eq(sessionId), eq(request)); } @Test @@ -408,7 +408,7 @@ public void handleRequest_aStopTransactionRequest_callsHandleStopTransactionRequ core.handleRequest(sessionId, request); // Then - verify(handler).handleStopTransactionRequest(eq(sessionId), eq(request)); + verify(handler, times(1)).handleStopTransactionRequest(eq(sessionId), eq(request)); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerFirmwareManagementProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerFirmwareManagementProfileTest.java index 06a9608df..7ce1e3b73 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerFirmwareManagementProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerFirmwareManagementProfileTest.java @@ -92,7 +92,8 @@ public void getFeatureList_containsFirmwareStatusNotificationFeature() { profile.handleRequest(sessionId, request); // Then - verify(handler).handleDiagnosticsStatusNotificationRequest(eq(sessionId), eq(request)); + verify(handler, times(1)) + .handleDiagnosticsStatusNotificationRequest(eq(sessionId), eq(request)); } @Test @@ -107,6 +108,6 @@ public void getFeatureList_containsFirmwareStatusNotificationFeature() { profile.handleRequest(sessionId, request); // Then - verify(handler).handleFirmwareStatusNotificationRequest(eq(sessionId), eq(request)); + verify(handler, times(1)).handleFirmwareStatusNotificationRequest(eq(sessionId), eq(request)); } } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListRequestTest.java index aaa95c648..371a961ab 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListRequestTest.java @@ -120,8 +120,8 @@ public void validate_updateTypeFullWithTagInfo_isValid() { // Then assertThat(request.validate(), equalTo(true)); - verify(data).getIdTagInfo(); - verify(data).validate(); + verify(data, times(1)).getIdTagInfo(); + verify(data, times(1)).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/AuthorizeConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/AuthorizeConfirmationTest.java index e082d32e3..9f3e63967 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/AuthorizeConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/AuthorizeConfirmationTest.java @@ -69,6 +69,6 @@ public void validate_idTagInfoSet_callsValidateOnIdTagInfo() { confirmation.validate(); // Then - verify(infoTag).validate(); + verify(infoTag, times(1)).validate(); } } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/ChargingScheduleTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/ChargingScheduleTest.java index 16f3075cc..2088c6b8a 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/ChargingScheduleTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/ChargingScheduleTest.java @@ -120,7 +120,7 @@ public void validate_chargingSchedulePeriodIsSet_chargingSchedulePeriodIsValidat chargingSchedule.validate(); // Then - verify(chargingSchedulePeriod).validate(); + verify(chargingSchedulePeriod, times(1)).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetConfigurationConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetConfigurationConfirmationTest.java index dd63c627d..6e31752d2 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetConfigurationConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetConfigurationConfirmationTest.java @@ -135,7 +135,7 @@ public void validate_configurationKeyIsSet_configurationKeyIsValidated() { confirmation.validate(); // Then - verify(keyValueType).validate(); + verify(keyValueType, times(1)).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValueTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValueTest.java index 93e4e0848..d45c19fa1 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValueTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValueTest.java @@ -84,7 +84,7 @@ public void validate_sampledValueIsSet_validatesSampledValue() { meterValue.validate(); // Then - verify(sampledValueMock).validate(); + verify(sampledValueMock, times(1)).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValuesRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValuesRequestTest.java index b4ef707ea..35578a927 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValuesRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValuesRequestTest.java @@ -123,7 +123,7 @@ public void validate_meterValueIsSet_validatesMeterValue() { request.validate(); // Then - verify(meterValueMock).validate(); + verify(meterValueMock, times(1)).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/RemoteStartTransactionRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/RemoteStartTransactionRequestTest.java index e19cf6bce..fbbd3c7f1 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/RemoteStartTransactionRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/RemoteStartTransactionRequestTest.java @@ -137,7 +137,7 @@ public void validate_chargingProfileIsSet_chargingsProfileIsValidated() { request.validate(); // Then - verify(chargingProfile).validate(); + verify(chargingProfile, times(1)).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StartTransactionConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StartTransactionConfirmationTest.java index d1d9fc1e4..69142d461 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StartTransactionConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StartTransactionConfirmationTest.java @@ -113,7 +113,7 @@ public void validate_idTagInfoAndTransactionIdIsSet_idTagInfoIsValidated() { confirmation.validate(); // Then - verify(idTagInfo).validate(); + verify(idTagInfo, times(1)).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionConfirmationTest.java index a5189eec8..040e7c1d2 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionConfirmationTest.java @@ -74,7 +74,7 @@ public void validate_idTagInfoIsSet_idTagInfoIsValidated() { confirmation.validate(); // Then - verify(idTagInfo).validate(); + verify(idTagInfo, times(1)).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionRequestTest.java index 6d36e7e6d..559ff95fb 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionRequestTest.java @@ -182,7 +182,7 @@ public void validate_transactionDataIsSet_transactionDataIsValidated() { request.validate(); // Then - verify(meterValue).validate(); + verify(meterValue, times(1)).validate(); } @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/JSONCommunicatorTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/JSONCommunicatorTest.java index 07b8d1b88..0436cf22a 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/JSONCommunicatorTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/JSONCommunicatorTest.java @@ -300,7 +300,7 @@ public void disconnect_disconnects() { communicator.disconnect(); // Then - verify(transmitter).disconnect(); + verify(transmitter, times(1)).disconnect(); } @Test @@ -313,7 +313,7 @@ public void sendError_transmitsError() throws Exception { communicator.sendCallError(null, null, errorCode, errorDescription); // Then - verify(transmitter).send(anyString()); + verify(transmitter, times(1)).send(anyString()); } private ZonedDateTime createDateTimeInMillis(long dateInMillis) { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/TimeoutSessionTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/TimeoutSessionTest.java index a715d06c1..e1d1f2d22 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/TimeoutSessionTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/TimeoutSessionTest.java @@ -67,7 +67,7 @@ public void handleConnectionOpened_opened_beginTimeout() throws Exception { sessionEvents.handleConnectionOpened(); // Then - verify(timeoutTimer).begin(); + verify(timeoutTimer, times(1)).begin(); } @Test @@ -79,7 +79,7 @@ public void handleConnectionClosed_opened_endTimeout() throws Exception { sessionEvents.handleConnectionClosed(); // Then - verify(timeoutTimer).end(); + verify(timeoutTimer, times(1)).end(); } @Test @@ -91,7 +91,7 @@ public void handleConnectionOpened_accepted_beginTimeout() throws Exception { sessionEvents.handleConnectionOpened(); // Then - verify(timeoutTimer).begin(); + verify(timeoutTimer, times(1)).begin(); } @Test @@ -103,7 +103,7 @@ public void handleConnectionClosed_accepted_endTimeout() throws Exception { sessionEvents.handleConnectionClosed(); // Then - verify(timeoutTimer).end(); + verify(timeoutTimer, times(1)).end(); } @Test @@ -115,7 +115,7 @@ public void handleRequest_any_resetTimeout() throws Exception { sessionEvents.handleRequest(null); // Then - verify(timeoutTimer).reset(); + verify(timeoutTimer, times(1)).reset(); } @Test @@ -127,6 +127,6 @@ public void handleConfirmation_any_resetTimeout() throws Exception { sessionEvents.handleConfirmation(null, null); // Then - verify(timeoutTimer).reset(); + verify(timeoutTimer, times(1)).reset(); } }