Skip to content

Commit

Permalink
Revert not necessary for Mockito code cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed Oct 16, 2023
1 parent 4f12030 commit 0d014bc
Show file tree
Hide file tree
Showing 25 changed files with 74 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -89,7 +89,7 @@ public void connect_connectionOpenedEvent() {
this.eventHandler.handleConnectionOpened();

// Then
verify(events).connectionOpened();
verify(events, times(1)).connectionOpened();
verify(events, never()).connectionClosed();
}

Expand All @@ -102,7 +102,7 @@ public void connect_connectionClosedEvent() {
this.eventHandler.handleConnectionClosed();

// Then
verify(events).connectionClosed();
verify(events, times(1)).connectionClosed();
verify(events, never()).connectionOpened();
}

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -162,6 +162,6 @@ public void send_aMessage_validatesMessage() throws Exception {
client.send(request);

// Then
verify(request).validate();
verify(request, times(1)).validate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -222,7 +222,7 @@ public boolean validate() {
communicator.sendCallResult(uniqueId, action, conf);

// Then
verify(handler).onConfirmationCompleted();
verify(handler, times(1)).onConfirmationCompleted();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -142,6 +141,6 @@ public void send_aMessage_validatesMessage() throws Exception {
server.send(sessionIndex, request);

// Then
verify(request).validate();
verify(request, times(1)).validate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -221,7 +221,7 @@ public void close_disconnects() {
session.close();

// Then
verify(communicator).disconnect();
verify(communicator, times(1)).disconnect();
}

@Test
Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 0d014bc

Please sign in to comment.