diff --git a/OCPP-J/src/main/java/eu/chargetime/ocpp/Draft_HttpHealthCheck.java b/OCPP-J/src/main/java/eu/chargetime/ocpp/Draft_HttpHealthCheck.java index 7d199ab35..4adfbd641 100644 --- a/OCPP-J/src/main/java/eu/chargetime/ocpp/Draft_HttpHealthCheck.java +++ b/OCPP-J/src/main/java/eu/chargetime/ocpp/Draft_HttpHealthCheck.java @@ -2,6 +2,9 @@ /* * Based ON https://github.com/TooTallNate/Java-WebSocket/issues/1077 */ +import java.nio.ByteBuffer; +import java.util.Collections; +import java.util.List; import org.java_websocket.WebSocketImpl; import org.java_websocket.drafts.Draft; import org.java_websocket.enums.CloseHandshakeType; @@ -12,105 +15,98 @@ import org.java_websocket.handshake.*; import org.java_websocket.util.Charsetfunctions; -import java.nio.ByteBuffer; -import java.util.Collections; -import java.util.List; - class Draft_HttpHealthCheck extends Draft { - static final int HTTP_HEALTH_CHECK_CLOSE_CODE = 10200; - - static Boolean isHttp(ClientHandshake handshakedata) { - String upgradeField = handshakedata.getFieldValue("Upgrade"); - return upgradeField == null || upgradeField.isEmpty(); - } - - @Override - public List createHandshake(Handshakedata handshakedata, boolean withcontent) { - byte[] content = Charsetfunctions.asciiBytes("

OCPP-J Websocket OK

"); - byte[] header = Charsetfunctions.asciiBytes( - "HTTP/1.0 200 OK\r\n" + - "Mime-Version: 1.0\r\n" + - "Content-Type: text/html\r\n" + - "Content-Length: " + content.length + " \r\n" + - "Connection: close\r\n" + - "\r\n" - ); - - ByteBuffer bytebuffer = ByteBuffer.allocate(content.length + header.length); - bytebuffer.put(header); - bytebuffer.put(content); - bytebuffer.flip(); - return Collections.singletonList(bytebuffer); - } - - @Override - public HandshakeState acceptHandshakeAsClient( - ClientHandshake request, ServerHandshake response - ) throws InvalidHandshakeException { - throw new InvalidHandshakeException("This draft can't be used on a client"); - } - - @Override - public HandshakeState acceptHandshakeAsServer( - ClientHandshake handshakedata - ) throws InvalidHandshakeException { - return (isHttp(handshakedata)) ? HandshakeState.MATCHED : HandshakeState.NOT_MATCHED; - } - - @Override - public ByteBuffer createBinaryFrame(Framedata framedata) { - return null; - } - - @Override - public List createFrames(ByteBuffer binary, boolean mask) { - return null; - } - - @Override - public List createFrames(String text, boolean mask) { - return null; - } - - @Override - public void processFrame( - WebSocketImpl webSocketImpl, Framedata frame - ) throws InvalidDataException { - throw new InvalidDataException(0, "This draft can't be used on a client"); - } - - @Override - public void reset() { - // Nothing to Do - } - - @Override - public ClientHandshakeBuilder postProcessHandshakeRequestAsClient( - ClientHandshakeBuilder request - ) throws InvalidHandshakeException { - throw new InvalidHandshakeException("This draft can't be used on a client"); - } - - @Override - public HandshakeBuilder postProcessHandshakeResponseAsServer( - ClientHandshake request, ServerHandshakeBuilder response - ) throws InvalidHandshakeException { - return response; - } - - @Override - public List translateFrame(ByteBuffer buffer) throws InvalidDataException { - throw new InvalidHandshakeException("This draft doesn't work with frames"); - } - - @Override - public CloseHandshakeType getCloseHandshakeType() { - return CloseHandshakeType.NONE; - } - - @Override - public Draft copyInstance() { - return this; - } + static final int HTTP_HEALTH_CHECK_CLOSE_CODE = 10200; + + static Boolean isHttp(ClientHandshake handshakedata) { + String upgradeField = handshakedata.getFieldValue("Upgrade"); + return upgradeField == null || upgradeField.isEmpty(); + } + + @Override + public List createHandshake(Handshakedata handshakedata, boolean withcontent) { + byte[] content = Charsetfunctions.asciiBytes("

OCPP-J Websocket OK

"); + byte[] header = + Charsetfunctions.asciiBytes( + "HTTP/1.0 200 OK\r\n" + + "Mime-Version: 1.0\r\n" + + "Content-Type: text/html\r\n" + + "Content-Length: " + + content.length + + " \r\n" + + "Connection: close\r\n" + + "\r\n"); + + ByteBuffer bytebuffer = ByteBuffer.allocate(content.length + header.length); + bytebuffer.put(header); + bytebuffer.put(content); + bytebuffer.flip(); + return Collections.singletonList(bytebuffer); + } + + @Override + public HandshakeState acceptHandshakeAsClient(ClientHandshake request, ServerHandshake response) + throws InvalidHandshakeException { + throw new InvalidHandshakeException("This draft can't be used on a client"); + } + + @Override + public HandshakeState acceptHandshakeAsServer(ClientHandshake handshakedata) + throws InvalidHandshakeException { + return (isHttp(handshakedata)) ? HandshakeState.MATCHED : HandshakeState.NOT_MATCHED; + } + + @Override + public ByteBuffer createBinaryFrame(Framedata framedata) { + return null; + } + + @Override + public List createFrames(ByteBuffer binary, boolean mask) { + return null; + } + + @Override + public List createFrames(String text, boolean mask) { + return null; + } + + @Override + public void processFrame(WebSocketImpl webSocketImpl, Framedata frame) + throws InvalidDataException { + throw new InvalidDataException(0, "This draft can't be used on a client"); + } + + @Override + public void reset() { + // Nothing to Do + } + + @Override + public ClientHandshakeBuilder postProcessHandshakeRequestAsClient(ClientHandshakeBuilder request) + throws InvalidHandshakeException { + throw new InvalidHandshakeException("This draft can't be used on a client"); + } + + @Override + public HandshakeBuilder postProcessHandshakeResponseAsServer( + ClientHandshake request, ServerHandshakeBuilder response) throws InvalidHandshakeException { + return response; + } + + @Override + public List translateFrame(ByteBuffer buffer) throws InvalidDataException { + throw new InvalidHandshakeException("This draft doesn't work with frames"); + } + + @Override + public CloseHandshakeType getCloseHandshakeType() { + return CloseHandshakeType.NONE; + } + + @Override + public Draft copyInstance() { + return this; + } } diff --git a/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONCommunicator.java b/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONCommunicator.java index 01f3147f0..da2f5a614 100644 --- a/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONCommunicator.java +++ b/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONCommunicator.java @@ -182,7 +182,8 @@ protected Message parse(Object json) { message.setPayload(array.get(INDEX_CALLRESULT_PAYLOAD).toString()); } else if (array.get(INDEX_MESSAGEID).getAsInt() == TYPENUMBER_CALLERROR) { message = new CallErrorMessage(); - ((CallErrorMessage) message).setErrorCode(array.get(INDEX_CALLERROR_ERRORCODE).getAsString()); + ((CallErrorMessage) message) + .setErrorCode(array.get(INDEX_CALLERROR_ERRORCODE).getAsString()); ((CallErrorMessage) message) .setErrorDescription(array.get(INDEX_CALLERROR_DESCRIPTION).getAsString()); ((CallErrorMessage) message).setRawPayload(array.get(INDEX_CALLERROR_PAYLOAD).toString()); diff --git a/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketListener.java b/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketListener.java index 763015161..23ef5df6c 100644 --- a/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketListener.java +++ b/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketListener.java @@ -87,7 +87,7 @@ public void open(String hostname, int port, ListenerEvents handler) { drafts) { @Override public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) { - if(Draft_HttpHealthCheck.isHttp(clientHandshake)){ + if (Draft_HttpHealthCheck.isHttp(clientHandshake)) { logger.debug("On HTTP Request, for heathcheck"); webSocket.close(Draft_HttpHealthCheck.HTTP_HEALTH_CHECK_CLOSE_CODE); return; @@ -166,8 +166,14 @@ public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer( } } if (password == null - || password.length < configuration.getParameter(JSONConfiguration.OCPPJ_CP_MIN_PASSWORD_LENGTH, OCPPJ_CP_MIN_PASSWORD_LENGTH) - || password.length > configuration.getParameter(JSONConfiguration.OCPPJ_CP_MAX_PASSWORD_LENGTH, OCPPJ_CP_MAX_PASSWORD_LENGTH)) + || password.length + < configuration.getParameter( + JSONConfiguration.OCPPJ_CP_MIN_PASSWORD_LENGTH, + OCPPJ_CP_MIN_PASSWORD_LENGTH) + || password.length + > configuration.getParameter( + JSONConfiguration.OCPPJ_CP_MAX_PASSWORD_LENGTH, + OCPPJ_CP_MAX_PASSWORD_LENGTH)) throw new InvalidDataException(401, "Invalid password length"); } @@ -190,8 +196,7 @@ public void onClose(WebSocket webSocket, int code, String reason, boolean remote reason, remote); - if(code == Draft_HttpHealthCheck.HTTP_HEALTH_CHECK_CLOSE_CODE) - return; + if (code == Draft_HttpHealthCheck.HTTP_HEALTH_CHECK_CLOSE_CODE) return; WebSocketReceiver receiver = sockets.get(webSocket); if (receiver != null) { diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/CallErrorException.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/CallErrorException.java index 9b5400ce3..db59e16bb 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/CallErrorException.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/CallErrorException.java @@ -25,9 +25,7 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ -/** - * Exception returned to an outgoing request if an error is reported from the other end. - */ +/** Exception returned to an outgoing request if an error is reported from the other end. */ public class CallErrorException extends Exception { private String errorCode; @@ -37,9 +35,9 @@ public class CallErrorException extends Exception { /** * Constructor. * - * @param errorCode send from the other end. + * @param errorCode send from the other end. * @param errorDescription describing the error. - * @param payload raw payload send from the other end. + * @param payload raw payload send from the other end. */ public CallErrorException(String errorCode, String errorDescription, Object payload) { super( diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java index 238ab19d8..1dec69f64 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java @@ -54,9 +54,7 @@ public class Client { * @param promiseRepository Inject promise repository * @see Session */ - public Client( - ISession session, - IPromiseRepository promiseRepository) { + public Client(ISession session, IPromiseRepository promiseRepository) { this.session = session; this.promiseRepository = promiseRepository; } @@ -94,7 +92,8 @@ public Confirmation handleRequest(Request request) throws UnsupportedFeatureExce } @Override - public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException { + public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException { return session.completePendingPromise(uniqueId, confirmation); } @@ -104,7 +103,8 @@ public void handleError( Optional> promiseOptional = promiseRepository.getPromise(uniqueId); if (promiseOptional.isPresent()) { - promiseOptional.get() + promiseOptional + .get() .completeExceptionally( new CallErrorException(errorCode, errorDescription, payload)); } else { @@ -158,11 +158,13 @@ public CompletableFuture send(Request request) String requestUuid = session.storeRequest(request); CompletableFuture promise = promiseRepository.createPromise(requestUuid); - // Clean up after the promise has completed, no matter if it was successful or had an error or a timeout. - promise.whenComplete((confirmation, throwable) -> { - session.removeRequest(requestUuid); - promiseRepository.removePromise(requestUuid); - }); + // Clean up after the promise has completed, no matter if it was successful or had an error or a + // timeout. + promise.whenComplete( + (confirmation, throwable) -> { + session.removeRequest(requestUuid); + promiseRepository.removePromise(requestUuid); + }); session.sendRequest(featureOptional.get().getAction(), request, requestUuid); return promise; @@ -172,7 +174,8 @@ public UUID getSessionId() { return this.session.getSessionId(); } - public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException { + public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException { return session.completePendingPromise(uniqueId, confirmation); } } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/ISession.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/ISession.java index a2c89d883..5f71357a2 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/ISession.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/ISession.java @@ -44,7 +44,8 @@ public interface ISession { void sendRequest(String action, Request payload, String uuid); - boolean completePendingPromise(String id, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException; + boolean completePendingPromise(String id, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException; void close(); } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/Queue.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/Queue.java index 9267efe9f..27252938d 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/Queue.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/Queue.java @@ -90,8 +90,8 @@ public Optional restoreRequest(String ticket) { } /** - * Remove a stored {@link Request} using a unique identifier. - * If no request is found for the identifier this method has no effect. + * Remove a stored {@link Request} using a unique identifier. If no request is found for the + * identifier this method has no effect. * * @param ticket unique identifier returned when {@link Request} was initially stored. */ diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java index 49d89e8a1..4db673201 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java @@ -57,9 +57,7 @@ public class Server { * @param listener injected listener. * @param promiseRepository injected promise repository. */ - public Server( - Listener listener, - IPromiseRepository promiseRepository) { + public Server(Listener listener, IPromiseRepository promiseRepository) { this.listener = listener; this.promiseRepository = promiseRepository; this.sessions = new ConcurrentHashMap<>(INITIAL_SESSIONS_NUMBER); @@ -105,7 +103,8 @@ public void handleConfirmation(String uniqueId, Confirmation confirmation) { @Override public Confirmation handleRequest(Request request) throws UnsupportedFeatureException { - Optional featureOptional = session.getFeatureRepository().findFeature(request); + Optional featureOptional = + session.getFeatureRepository().findFeature(request); if (featureOptional.isPresent()) { Optional sessionIdOptional = getSessionID(session); if (sessionIdOptional.isPresent()) { @@ -115,7 +114,8 @@ public Confirmation handleRequest(Request request) } else { logger.error( "Unable to handle request ({}), the active session was not found for {}.", - request, session.getSessionId()); + request, + session.getSessionId()); throw new IllegalStateException("Active session not found"); } } else { @@ -124,7 +124,8 @@ public Confirmation handleRequest(Request request) } @Override - public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException { + public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException { return session.completePendingPromise(uniqueId, confirmation); } @@ -134,7 +135,8 @@ public void handleError( Optional> promiseOptional = promiseRepository.getPromise(uniqueId); if (promiseOptional.isPresent()) { - promiseOptional.get() + promiseOptional + .get() .completeExceptionally( new CallErrorException(errorCode, errorDescription, payload)); } else { @@ -216,11 +218,13 @@ public CompletableFuture send(UUID sessionIndex, Request request) String requestUuid = session.storeRequest(request); CompletableFuture promise = promiseRepository.createPromise(requestUuid); - // Clean up after the promise has completed, no matter if it was successful or had an error or a timeout. - promise.whenComplete((confirmation, throwable) -> { - session.removeRequest(requestUuid); - promiseRepository.removePromise(requestUuid); - }); + // Clean up after the promise has completed, no matter if it was successful or had an error or a + // timeout. + promise.whenComplete( + (confirmation, throwable) -> { + session.removeRequest(requestUuid); + promiseRepository.removePromise(requestUuid); + }); session.sendRequest(featureOptional.get().getAction(), request, requestUuid); return promise; @@ -235,7 +239,8 @@ public CompletableFuture send(UUID sessionIndex, Request request) * @return a boolean indicating if pending request was found. * @throws NotConnectedException Thrown if session with passed sessionIndex is not found */ - public boolean asyncCompleteRequest(UUID sessionIndex, String uniqueId, Confirmation confirmation) throws NotConnectedException, UnsupportedFeatureException, OccurenceConstraintException { + public boolean asyncCompleteRequest(UUID sessionIndex, String uniqueId, Confirmation confirmation) + throws NotConnectedException, UnsupportedFeatureException, OccurenceConstraintException { ISession session = sessions.get(sessionIndex); if (session == null) { @@ -248,7 +253,6 @@ public boolean asyncCompleteRequest(UUID sessionIndex, String uniqueId, Confirma return session.completePendingPromise(uniqueId, confirmation); } - public boolean isSessionOpen(UUID sessionIndex) { return sessions.containsKey(sessionIndex); } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/ServerEvents.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/ServerEvents.java index 2e66f0f30..83eda55e3 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/ServerEvents.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/ServerEvents.java @@ -29,7 +29,8 @@ of this software and associated documentation files (the "Software"), to deal import java.util.UUID; public interface ServerEvents { - void authenticateSession(SessionInformation information, String username, byte[] password) throws AuthenticationException; + void authenticateSession(SessionInformation information, String username, byte[] password) + throws AuthenticationException; void newSession(UUID sessionIndex, SessionInformation information); diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java index 2c7c0ccba..aa4f4c2b1 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java @@ -32,11 +32,11 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.Request; import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.AbstractMap; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; import java.util.UUID; -import java.util.Map; -import java.util.HashMap; -import java.util.AbstractMap; import java.util.concurrent.CompletableFuture; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,7 +55,9 @@ public class Session implements ISession { private final RequestDispatcher dispatcher; private final IFeatureRepository featureRepository; private SessionEvents events; - private final Map>> pendingPromises = new HashMap<>(); + private final Map< + String, AbstractMap.SimpleImmutableEntry>> + pendingPromises = new HashMap<>(); /** * Handles required injections. @@ -115,8 +117,8 @@ public String storeRequest(Request payload) { } /** - * Remove a stored {@link Request} using a unique identifier. - * If no request is found for the identifier this method has no effect. + * Remove a stored {@link Request} using a unique identifier. If no request is found for the + * identifier this method has no effect. * * @param ticket unique identifier returned when {@link Request} was initially stored. */ @@ -195,8 +197,11 @@ public void onCallResult(String id, String action, Object payload) { if (confirmation.validate()) { events.handleConfirmation(id, confirmation); } else { - communicator.sendCallError(id, action, isLegacyRPC() ? "OccurenceConstraintViolation" : - "OccurrenceConstraintViolation", OCCURRENCE_CONSTRAINT_VIOLATION); + communicator.sendCallError( + id, + action, + isLegacyRPC() ? "OccurenceConstraintViolation" : "OccurrenceConstraintViolation", + OCCURRENCE_CONSTRAINT_VIOLATION); } } else { logger.warn(INTERNAL_ERROR); @@ -210,8 +215,11 @@ public void onCallResult(String id, String action, Object payload) { communicator.sendCallError(id, action, "InternalError", INTERNAL_ERROR); } catch (Exception ex) { logger.warn(UNABLE_TO_PROCESS, ex); - communicator.sendCallError(id, action, isLegacyRPC() ? "FormationViolation" : - "FormatViolation", UNABLE_TO_PROCESS); + communicator.sendCallError( + id, + action, + isLegacyRPC() ? "FormationViolation" : "FormatViolation", + UNABLE_TO_PROCESS); } } @@ -232,8 +240,11 @@ public synchronized void onCall(String id, String action, Object payload) { addPendingPromise(id, action, promise); dispatcher.handleRequest(promise, request); } else { - communicator.sendCallError(id, action, isLegacyRPC() ? "OccurenceConstraintViolation" : - "OccurrenceConstraintViolation", OCCURRENCE_CONSTRAINT_VIOLATION); + communicator.sendCallError( + id, + action, + isLegacyRPC() ? "OccurenceConstraintViolation" : "OccurrenceConstraintViolation", + OCCURRENCE_CONSTRAINT_VIOLATION); } } catch (PropertyConstraintException ex) { logger.warn(ex.getMessage(), ex); @@ -243,8 +254,11 @@ public synchronized void onCall(String id, String action, Object payload) { communicator.sendCallError(id, action, "SecurityError", ex.getMessage()); } catch (Exception ex) { logger.warn(UNABLE_TO_PROCESS, ex); - communicator.sendCallError(id, action, isLegacyRPC() ? "FormationViolation" : - "FormatViolation", UNABLE_TO_PROCESS); + communicator.sendCallError( + id, + action, + isLegacyRPC() ? "FormationViolation" : "FormatViolation", + UNABLE_TO_PROCESS); } } } @@ -270,16 +284,19 @@ private boolean isLegacyRPC() { } } - private void addPendingPromise(String id, String action, CompletableFuture promise) { + private void addPendingPromise( + String id, String action, CompletableFuture promise) { synchronized (pendingPromises) { pendingPromises.put(id, new AbstractMap.SimpleImmutableEntry<>(action, promise)); } } @Override - public boolean completePendingPromise(String id, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException { + public boolean completePendingPromise(String id, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException { AbstractMap.SimpleImmutableEntry> promiseAction = null; - // synchronization prevents from confirming one promise more than once, as we remove found promise + // synchronization prevents from confirming one promise more than once, as we remove found + // promise synchronized (pendingPromises) { promiseAction = pendingPromises.get(id); if (promiseAction == null) return false; @@ -294,7 +311,8 @@ public boolean completePendingPromise(String id, Confirmation confirmation) thro } } else { logger.debug("Feature for confirmation with id: {} not found in session: {}", id, this); - throw new UnsupportedFeatureException("Error with getting confirmation type by request id = " + id); + throw new UnsupportedFeatureException( + "Error with getting confirmation type by request id = " + id); } promiseAction.getValue().complete(confirmation); return true; diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/SessionEvents.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/SessionEvents.java index 6867ad826..dd9b9eb90 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/SessionEvents.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/SessionEvents.java @@ -56,7 +56,8 @@ public interface SessionEvents { * @param confirmation the {@link Confirmation} to the {@link Request}. * @return a boolean indicating if pending request was found. */ - boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException; + boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException; /** * Handle a error to a {@link Request}. diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/Confirmation.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/Confirmation.java index f78dbf898..6e15e8c82 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/Confirmation.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/Confirmation.java @@ -28,20 +28,18 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ - import javax.xml.bind.annotation.XmlTransient; /** Interface used to flag a Model as a Confirmation payload. */ - public abstract class Confirmation implements Validatable { - private transient ConfirmationCompletedHandler completedHandler; - - @XmlTransient - public ConfirmationCompletedHandler getCompletedHandler() { - return completedHandler; - } - public void setCompletedHandler(ConfirmationCompletedHandler completedHandler) { - this.completedHandler = completedHandler; - } -} + private transient ConfirmationCompletedHandler completedHandler; + @XmlTransient + public ConfirmationCompletedHandler getCompletedHandler() { + return completedHandler; + } + + public void setCompletedHandler(ConfirmationCompletedHandler completedHandler) { + this.completedHandler = completedHandler; + } +} diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/ConfirmationCompletedHandler.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/ConfirmationCompletedHandler.java index 8793dfbfa..d6f0ef387 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/ConfirmationCompletedHandler.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/ConfirmationCompletedHandler.java @@ -26,10 +26,7 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ - -/** - * Callback that can perform actions after the confirmation is sent back to the Charge Point - */ +/** Callback that can perform actions after the confirmation is sent back to the Charge Point */ public interface ConfirmationCompletedHandler { - void onConfirmationCompleted(); + void onConfirmationCompleted(); } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/Exclude.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/Exclude.java index 662a9a6f4..639da10cc 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/Exclude.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/Exclude.java @@ -7,4 +7,4 @@ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) -public @interface Exclude {} \ No newline at end of file +public @interface Exclude {} diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/Request.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/Request.java index 4eba5882b..4c6fbf869 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/Request.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/Request.java @@ -30,6 +30,8 @@ of this software and associated documentation files (the "Software"), to deal /** Interface used to flag a model as Request payload. */ public interface Request extends Validatable { boolean transactionRelated(); + String getOcppMessageId(); + void setOcppMessageId(String id); } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/RequestWithId.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/RequestWithId.java index 5400e43ec..a99729d7d 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/RequestWithId.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/RequestWithId.java @@ -11,6 +11,5 @@ public void setOcppMessageId(String requestId) { this.ocppMessageId = requestId; } - @Exclude - private String ocppMessageId; + @Exclude private String ocppMessageId; } 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 cdb609592..7c7defc6d 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 @@ -26,28 +26,27 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertThrows; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.any; + import eu.chargetime.ocpp.*; import eu.chargetime.ocpp.feature.Feature; import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.Request; import eu.chargetime.ocpp.model.TestConfirmation; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - import java.util.Optional; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; - -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertThrows; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.*; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ClientTest { @@ -69,7 +68,8 @@ public void setup() { .when(session) .open(any(), any()); - when(promiseRepository.createPromise(any())).then(invocation -> new CompletableFuture()); + when(promiseRepository.createPromise(any())) + .then(invocation -> new CompletableFuture()); when(featureRepository.findFeature(any())).thenReturn(Optional.of(feature)); when(session.getFeatureRepository()).thenReturn(featureRepository); when(session.storeRequest(any())).then(invocation -> UUID.randomUUID().toString()); @@ -121,7 +121,8 @@ public void send_aMessage_isCommunicated() throws Exception { // Then // TODO action and uuid should not be nullable - verify(session, times(1)).sendRequest(nullable(String.class), eq(request), nullable(String.class)); + verify(session, times(1)) + .sendRequest(nullable(String.class), eq(request), nullable(String.class)); } @Test @@ -206,7 +207,8 @@ public void send_aMessage_promiseCompletesExceptionally() throws Exception { assertThat(returnedFuture, is(internalFuture)); assertThat(returnedFuture.isDone(), is(true)); assertThat(returnedFuture.isCompletedExceptionally(), is(true)); - ExecutionException executionException = assertThrows(ExecutionException.class, returnedFuture::get); + ExecutionException executionException = + assertThrows(ExecutionException.class, returnedFuture::get); assertThat(executionException.getCause().getClass(), is(equalTo(IllegalStateException.class))); verify(session, times(1)).removeRequest(any()); verify(promiseRepository, times(1)).removePromise(any()); @@ -221,7 +223,7 @@ public void send_aMessage_promiseCompletesWithTimeout() throws Exception { // When CompletableFuture returnedFuture = client.send(request); // If the client uses at least Java 9, it could use CompletableFuture::orTimeout(..) .. -// returnedFuture.orTimeout(50, TimeUnit.MILLISECONDS); + // returnedFuture.orTimeout(50, TimeUnit.MILLISECONDS); assertThat(returnedFuture.isDone(), is(false)); Thread.sleep(100); // .. alternatively, it can be implemented manually @@ -231,7 +233,8 @@ public void send_aMessage_promiseCompletesWithTimeout() throws Exception { assertThat(returnedFuture, is(internalFuture)); assertThat(returnedFuture.isDone(), is(true)); assertThat(returnedFuture.isCompletedExceptionally(), is(true)); - ExecutionException executionException = assertThrows(ExecutionException.class, returnedFuture::get); + ExecutionException executionException = + assertThrows(ExecutionException.class, returnedFuture::get); assertThat(executionException.getCause().getClass(), is(equalTo(TimeoutException.class))); verify(session, times(1)).removeRequest(any()); verify(promiseRepository, times(1)).removePromise(any()); 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 a20c0d26a..01cda8034 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 @@ -1,28 +1,27 @@ package eu.chargetime.ocpp.test; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertThrows; +import static org.mockito.Mockito.*; + import eu.chargetime.ocpp.*; import eu.chargetime.ocpp.feature.Feature; import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.Request; import eu.chargetime.ocpp.model.SessionInformation; import eu.chargetime.ocpp.model.TestConfirmation; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - import java.util.Optional; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertThrows; -import static org.mockito.Mockito.*; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP @@ -85,7 +84,8 @@ public void setup() { .when(serverEvents) .newSession(any(), any()); - when(promiseRepository.createPromise(any())).then(invocation -> new CompletableFuture()); + when(promiseRepository.createPromise(any())) + .then(invocation -> new CompletableFuture()); when(featureRepository.findFeature(any())).thenReturn(Optional.of(feature)); when(session.getFeatureRepository()).thenReturn(featureRepository); when(session.storeRequest(any())).thenAnswer(invocation -> UUID.randomUUID().toString()); @@ -127,7 +127,8 @@ public void send_aMessage_isCommunicated() throws Exception { // Then // TODO action and uuid should not be nullable - verify(session, times(1)).sendRequest(nullable(String.class), eq(request), nullable(String.class)); + verify(session, times(1)) + .sendRequest(nullable(String.class), eq(request), nullable(String.class)); } @Test @@ -193,7 +194,8 @@ public void send_aMessage_promiseCompletesExceptionally() throws Exception { assertThat(returnedFuture, is(internalFuture)); assertThat(returnedFuture.isDone(), is(true)); assertThat(returnedFuture.isCompletedExceptionally(), is(true)); - ExecutionException executionException = assertThrows(ExecutionException.class, returnedFuture::get); + ExecutionException executionException = + assertThrows(ExecutionException.class, returnedFuture::get); assertThat(executionException.getCause().getClass(), is(equalTo(IllegalStateException.class))); verify(session, times(1)).removeRequest(any()); verify(promiseRepository, times(1)).removePromise(any()); @@ -210,7 +212,7 @@ public void send_aMessage_promiseCompletesWithTimeout() throws Exception { // When CompletableFuture returnedFuture = server.send(sessionIndex, request); // If the client uses at least Java 9, it could use CompletableFuture::orTimeout(..). -// returnedFuture.orTimeout(50, TimeUnit.MILLISECONDS); + // returnedFuture.orTimeout(50, TimeUnit.MILLISECONDS); assertThat(returnedFuture.isDone(), is(false)); Thread.sleep(100); // .. alternatively, it can be implemented manually @@ -220,7 +222,8 @@ public void send_aMessage_promiseCompletesWithTimeout() throws Exception { assertThat(returnedFuture, is(internalFuture)); assertThat(returnedFuture.isDone(), is(true)); assertThat(returnedFuture.isCompletedExceptionally(), is(true)); - ExecutionException executionException = assertThrows(ExecutionException.class, returnedFuture::get); + ExecutionException executionException = + assertThrows(ExecutionException.class, returnedFuture::get); assertThat(executionException.getCause().getClass(), is(equalTo(TimeoutException.class))); verify(session, times(1)).removeRequest(any()); verify(promiseRepository, times(1)).removePromise(any()); 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 24e92ec7d..10069f222 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,8 @@ public boolean validate() { // Then // TODO uniqueid should not be nullable - verify(communicator, times(1)).sendCall(nullable(String.class), eq(someAction), eq(someRequest)); + verify(communicator, times(1)) + .sendCall(nullable(String.class), eq(someAction), eq(someRequest)); } @Test @@ -117,18 +118,20 @@ public void sendRequest_someUniqueId_sendsUniqueIdToCommunicator() { // Then // TODO uuid and request should not be nullable - verify(communicator, times(1)).sendCall(eq(someUniqueId), nullable(String.class), nullable(Request.class)); + verify(communicator, times(1)) + .sendCall(eq(someUniqueId), nullable(String.class), nullable(Request.class)); } @Test public void sendConfirmation_sendsConfirmationToCommunicator() { // Given - Confirmation conf = new Confirmation() { - @Override - public boolean validate() { - return false; - } - }; + Confirmation conf = + new Confirmation() { + @Override + public boolean validate() { + return false; + } + }; String someUniqueId = "Some id"; String action = "Some action"; @@ -165,19 +168,21 @@ public void onCall_unhandledCallback_callSendCallError() throws Exception { // then // TODO action should not be nullable - verify(communicator, times(1)).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); + verify(communicator, times(1)) + .sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); } @Test public void onCall_handledCallback_callSendCallResult() throws Exception { // Given String someId = "Some id"; - Confirmation aConfirmation = new Confirmation() { - @Override - public boolean validate() { - return false; - } - }; + Confirmation aConfirmation = + new Confirmation() { + @Override + public boolean validate() { + return false; + } + }; doAnswer( invocation -> @@ -191,7 +196,8 @@ public boolean validate() { // then // TODO action should not be nullable - verify(communicator, times(1)).sendCallResult(anyString(), nullable(String.class), eq(aConfirmation)); + verify(communicator, times(1)) + .sendCallResult(anyString(), nullable(String.class), eq(aConfirmation)); } @Test @@ -212,7 +218,8 @@ public void onCall_callbackThrowsException_callSendCallResult() throws Exception // then // TODO uniqueid should not be nullable - verify(communicator, times(1)).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); + verify(communicator, times(1)) + .sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); } @Test @@ -235,6 +242,7 @@ public void onCall_unknownAction_callSendCallError() { // Then // TODO uniqueid should not be nullable - verify(communicator, times(1)).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); + verify(communicator, times(1)) + .sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); } } diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/DummyHandlers.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/DummyHandlers.java index 0ec7e8509..6654d9cd4 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/DummyHandlers.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/DummyHandlers.java @@ -42,7 +42,6 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.firmware.FirmwareStatusNotificationRequest; import eu.chargetime.ocpp.model.securityext.*; import eu.chargetime.ocpp.model.securityext.types.GenericStatusEnumType; - import java.lang.reflect.Type; import java.time.ZonedDateTime; import java.util.UUID; @@ -170,30 +169,38 @@ public ServerSecurityExtEventHandler createServerSecurityExtEventHandler() { return new ServerSecurityExtEventHandler() { @Override - public LogStatusNotificationConfirmation handleLogStatusNotificationRequest(UUID sessionIndex, LogStatusNotificationRequest request) { + public LogStatusNotificationConfirmation handleLogStatusNotificationRequest( + UUID sessionIndex, LogStatusNotificationRequest request) { receivedRequest = request; LogStatusNotificationConfirmation confirmation = new LogStatusNotificationConfirmation(); return failurePoint(confirmation); } @Override - public SecurityEventNotificationConfirmation handleSecurityEventNotificationRequest(UUID sessionIndex, SecurityEventNotificationRequest request) { + public SecurityEventNotificationConfirmation handleSecurityEventNotificationRequest( + UUID sessionIndex, SecurityEventNotificationRequest request) { receivedRequest = request; - SecurityEventNotificationConfirmation confirmation = new SecurityEventNotificationConfirmation(); + SecurityEventNotificationConfirmation confirmation = + new SecurityEventNotificationConfirmation(); return failurePoint(confirmation); } @Override - public SignCertificateConfirmation handleSignCertificateRequest(UUID sessionIndex, SignCertificateRequest request) { + public SignCertificateConfirmation handleSignCertificateRequest( + UUID sessionIndex, SignCertificateRequest request) { receivedRequest = request; - SignCertificateConfirmation confirmation = new SignCertificateConfirmation(GenericStatusEnumType.Accepted); + SignCertificateConfirmation confirmation = + new SignCertificateConfirmation(GenericStatusEnumType.Accepted); return failurePoint(confirmation); } @Override - public SignedFirmwareStatusNotificationConfirmation handleSignedFirmwareStatusNotificationRequest(UUID sessionIndex, SignedFirmwareStatusNotificationRequest request) { + public SignedFirmwareStatusNotificationConfirmation + handleSignedFirmwareStatusNotificationRequest( + UUID sessionIndex, SignedFirmwareStatusNotificationRequest request) { receivedRequest = request; - SignedFirmwareStatusNotificationConfirmation confirmation = new SignedFirmwareStatusNotificationConfirmation(); + SignedFirmwareStatusNotificationConfirmation confirmation = + new SignedFirmwareStatusNotificationConfirmation(); return failurePoint(confirmation); } }; @@ -203,7 +210,8 @@ public ServerEvents generateServerEventsHandler() { return new ServerEvents() { @Override public void authenticateSession( - SessionInformation information, String username, byte[] password) throws AuthenticationException {} + SessionInformation information, String username, byte[] password) + throws AuthenticationException {} @Override public void newSession(UUID sessionIndex, SessionInformation information) { diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeCentralSystem.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeCentralSystem.java index 6db5b0183..7ba22ef82 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeCentralSystem.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeCentralSystem.java @@ -96,9 +96,8 @@ private void initializeServer() { ServerReservationProfile serverReservationProfile = new ServerReservationProfile(); server.addFeatureProfile(serverReservationProfile); - ServerSecurityExtProfile serverSecurityExtProfile = new ServerSecurityExtProfile( - dummyHandlers.createServerSecurityExtEventHandler() - ); + ServerSecurityExtProfile serverSecurityExtProfile = + new ServerSecurityExtProfile(dummyHandlers.createServerSecurityExtEventHandler()); server.addFeatureProfile(serverSecurityExtProfile); } @@ -395,62 +394,67 @@ public void sendCertificateSignedRequest(String certificateChain) throws Excepti public boolean hasReceivedCertificateSignedConfirmation(String status) { CertificateSignedConfirmation confirmation = - dummyHandlers.getReceivedConfirmation(CertificateSignedConfirmation.class); + dummyHandlers.getReceivedConfirmation(CertificateSignedConfirmation.class); return confirmation != null && confirmation.getStatus().toString().equals(status); } - public void sendDeleteCertificateRequest(CertificateHashDataType certificateHashDataType) throws Exception { + public void sendDeleteCertificateRequest(CertificateHashDataType certificateHashDataType) + throws Exception { Request request = new DeleteCertificateRequest(certificateHashDataType); send(request); } public boolean hasReceivedDeleteCertificateConfirmation(String status) { DeleteCertificateConfirmation confirmation = - dummyHandlers.getReceivedConfirmation(DeleteCertificateConfirmation.class); + dummyHandlers.getReceivedConfirmation(DeleteCertificateConfirmation.class); return confirmation != null && confirmation.getStatus().toString().equals(status); } - public void sendExtendedTriggerMessageRequest(MessageTriggerEnumType requestedMessage) throws Exception { + public void sendExtendedTriggerMessageRequest(MessageTriggerEnumType requestedMessage) + throws Exception { Request request = new ExtendedTriggerMessageRequest(requestedMessage); send(request); } public boolean hasReceivedExtendedTriggerMessageConfirmation(String status) { ExtendedTriggerMessageConfirmation confirmation = - dummyHandlers.getReceivedConfirmation(ExtendedTriggerMessageConfirmation.class); + dummyHandlers.getReceivedConfirmation(ExtendedTriggerMessageConfirmation.class); return confirmation != null && confirmation.getStatus().toString().equals(status); } - public void sendGetInstalledCertificateIdsRequest(CertificateUseEnumType certificateType) throws Exception { + public void sendGetInstalledCertificateIdsRequest(CertificateUseEnumType certificateType) + throws Exception { Request request = new GetInstalledCertificateIdsRequest(certificateType); send(request); } public boolean hasReceivedGetInstalledCertificateIdsConfirmation(String status) { GetInstalledCertificateIdsConfirmation confirmation = - dummyHandlers.getReceivedConfirmation(GetInstalledCertificateIdsConfirmation.class); + dummyHandlers.getReceivedConfirmation(GetInstalledCertificateIdsConfirmation.class); return confirmation != null && confirmation.getStatus().toString().equals(status); } - public void sendGetLogRequest(LogEnumType logType, Integer requestId, LogParametersType log) throws Exception { + public void sendGetLogRequest(LogEnumType logType, Integer requestId, LogParametersType log) + throws Exception { Request request = new GetLogRequest(logType, requestId, log); send(request); } public boolean hasReceivedGetLogConfirmation(String status) { GetLogConfirmation confirmation = - dummyHandlers.getReceivedConfirmation(GetLogConfirmation.class); + dummyHandlers.getReceivedConfirmation(GetLogConfirmation.class); return confirmation != null && confirmation.getStatus().toString().equals(status); } - public void sendInstallCertificateRequest(CertificateUseEnumType certificateType, String certificate) throws Exception { + public void sendInstallCertificateRequest( + CertificateUseEnumType certificateType, String certificate) throws Exception { Request request = new InstallCertificateRequest(certificateType, certificate); send(request); } public boolean hasReceivedInstallCertificateConfirmation(String status) { InstallCertificateConfirmation confirmation = - dummyHandlers.getReceivedConfirmation(InstallCertificateConfirmation.class); + dummyHandlers.getReceivedConfirmation(InstallCertificateConfirmation.class); return confirmation != null && confirmation.getStatus().toString().equals(status); } @@ -470,14 +474,15 @@ public boolean hasHandledSignedFirmwareStatusNotificationRequest() { return dummyHandlers.wasLatestRequest(SignedFirmwareStatusNotificationRequest.class); } - public void sendSignedUpdateFirmwareRequest(Integer requestId, FirmwareType firmware) throws Exception { + public void sendSignedUpdateFirmwareRequest(Integer requestId, FirmwareType firmware) + throws Exception { Request request = new SignedUpdateFirmwareRequest(requestId, firmware); send(request); } public boolean hasReceivedSignedUpdateFirmwareConfirmation(String status) { SignedUpdateFirmwareConfirmation confirmation = - dummyHandlers.getReceivedConfirmation(SignedUpdateFirmwareConfirmation.class); + dummyHandlers.getReceivedConfirmation(SignedUpdateFirmwareConfirmation.class); return confirmation != null && confirmation.getStatus().toString().equals(status); } diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeChargePoint.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeChargePoint.java index 54be7033e..f84f29637 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeChargePoint.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeChargePoint.java @@ -230,49 +230,58 @@ public CancelReservationConfirmation handleCancelReservationRequest( }); securityExt = - new ClientSecurityExtProfile(new ClientSecurityExtEventHandler() { - @Override - public CertificateSignedConfirmation handleCertificateSignedRequest(CertificateSignedRequest request) { - receivedRequest = request; - return new CertificateSignedConfirmation(CertificateSignedStatusEnumType.Accepted); - } - - @Override - public DeleteCertificateConfirmation handleDeleteCertificateRequest(DeleteCertificateRequest request) { - receivedRequest = request; - return new DeleteCertificateConfirmation(DeleteCertificateStatusEnumType.Accepted); - } - - @Override - public ExtendedTriggerMessageConfirmation handleExtendedTriggerMessageRequest(ExtendedTriggerMessageRequest request) { - receivedRequest = request; - return new ExtendedTriggerMessageConfirmation(TriggerMessageStatusEnumType.Accepted); - } - - @Override - public GetInstalledCertificateIdsConfirmation handleGetInstalledCertificateIdsRequest(GetInstalledCertificateIdsRequest request) { - receivedRequest = request; - return new GetInstalledCertificateIdsConfirmation(GetInstalledCertificateStatusEnumType.Accepted); - } - - @Override - public GetLogConfirmation handleGetLogRequest(GetLogRequest request) { - receivedRequest = request; - return new GetLogConfirmation(LogStatusEnumType.Accepted); - } - - @Override - public InstallCertificateConfirmation handleInstallCertificateRequest(InstallCertificateRequest request) { - receivedRequest = request; - return new InstallCertificateConfirmation(CertificateStatusEnumType.Accepted); - } - - @Override - public SignedUpdateFirmwareConfirmation handleSignedUpdateFirmwareRequest(SignedUpdateFirmwareRequest request) { - receivedRequest = request; - return new SignedUpdateFirmwareConfirmation(UpdateFirmwareStatusEnumType.Accepted); - } - }); + new ClientSecurityExtProfile( + new ClientSecurityExtEventHandler() { + @Override + public CertificateSignedConfirmation handleCertificateSignedRequest( + CertificateSignedRequest request) { + receivedRequest = request; + return new CertificateSignedConfirmation(CertificateSignedStatusEnumType.Accepted); + } + + @Override + public DeleteCertificateConfirmation handleDeleteCertificateRequest( + DeleteCertificateRequest request) { + receivedRequest = request; + return new DeleteCertificateConfirmation(DeleteCertificateStatusEnumType.Accepted); + } + + @Override + public ExtendedTriggerMessageConfirmation handleExtendedTriggerMessageRequest( + ExtendedTriggerMessageRequest request) { + receivedRequest = request; + return new ExtendedTriggerMessageConfirmation( + TriggerMessageStatusEnumType.Accepted); + } + + @Override + public GetInstalledCertificateIdsConfirmation handleGetInstalledCertificateIdsRequest( + GetInstalledCertificateIdsRequest request) { + receivedRequest = request; + return new GetInstalledCertificateIdsConfirmation( + GetInstalledCertificateStatusEnumType.Accepted); + } + + @Override + public GetLogConfirmation handleGetLogRequest(GetLogRequest request) { + receivedRequest = request; + return new GetLogConfirmation(LogStatusEnumType.Accepted); + } + + @Override + public InstallCertificateConfirmation handleInstallCertificateRequest( + InstallCertificateRequest request) { + receivedRequest = request; + return new InstallCertificateConfirmation(CertificateStatusEnumType.Accepted); + } + + @Override + public SignedUpdateFirmwareConfirmation handleSignedUpdateFirmwareRequest( + SignedUpdateFirmwareRequest request) { + receivedRequest = request; + return new SignedUpdateFirmwareConfirmation(UpdateFirmwareStatusEnumType.Accepted); + } + }); switch (type) { case JSON: @@ -390,13 +399,17 @@ public void sendFirmwareStatusNotificationRequest(FirmwareStatus status) throws send(request); } - public void sendLogStatusNotificationRequest(UploadLogStatusEnumType uploadLogStatusEnumType) throws Exception { - LogStatusNotificationRequest request = securityExt.createLogStatusNotificationRequest(uploadLogStatusEnumType); + public void sendLogStatusNotificationRequest(UploadLogStatusEnumType uploadLogStatusEnumType) + throws Exception { + LogStatusNotificationRequest request = + securityExt.createLogStatusNotificationRequest(uploadLogStatusEnumType); send(request); } - public void sendSecurityEventNotificationRequest(String type, ZonedDateTime timestamp) throws Exception { - SecurityEventNotificationRequest request = securityExt.createSecurityEventNotificationRequest(type, timestamp); + public void sendSecurityEventNotificationRequest(String type, ZonedDateTime timestamp) + throws Exception { + SecurityEventNotificationRequest request = + securityExt.createSecurityEventNotificationRequest(type, timestamp); send(request); } @@ -405,8 +418,10 @@ public void sendSignCertificateRequest(String csr) throws Exception { send(request); } - public void sendSignedFirmwareStatusNotificationRequest(FirmwareStatusEnumType status) throws Exception { - SignedFirmwareStatusNotificationRequest request = securityExt.createSignedFirmwareStatusNotificationRequest(status); + public void sendSignedFirmwareStatusNotificationRequest(FirmwareStatusEnumType status) + throws Exception { + SignedFirmwareStatusNotificationRequest request = + securityExt.createSignedFirmwareStatusNotificationRequest(status); send(request); } diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestClient.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestClient.java index 0c9716faa..25daee132 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestClient.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestClient.java @@ -81,7 +81,8 @@ public CompletionStage send(Request request) } @Override - public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException { + public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException { return client.asyncCompleteRequest(uniqueId, confirmation); } diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestServer.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestServer.java index 615bc11cd..cbd86436b 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestServer.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestServer.java @@ -102,7 +102,8 @@ public CompletionStage send(UUID session, Request request) } @Override - public boolean asyncCompleteRequest(UUID sessionIndex, String uniqueId, Confirmation confirmation) throws NotConnectedException, UnsupportedFeatureException, OccurenceConstraintException { + public boolean asyncCompleteRequest(UUID sessionIndex, String uniqueId, Confirmation confirmation) + throws NotConnectedException, UnsupportedFeatureException, OccurenceConstraintException { return server.asyncCompleteRequest(sessionIndex, uniqueId, confirmation); } } diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestClient.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestClient.java index a4a7ce4af..8104f3bce 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestClient.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestClient.java @@ -99,7 +99,8 @@ public CompletionStage send(Request request) } @Override - public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException { + public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException { return client.asyncCompleteRequest(uniqueId, confirmation); } diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestServer.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestServer.java index bdf27e210..06a943a71 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestServer.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestServer.java @@ -89,7 +89,8 @@ public CompletionStage send(UUID session, Request request) } @Override - public boolean asyncCompleteRequest(UUID sessionIndex, String uniqueId, Confirmation confirmation) throws NotConnectedException, UnsupportedFeatureException, OccurenceConstraintException { + public boolean asyncCompleteRequest(UUID sessionIndex, String uniqueId, Confirmation confirmation) + throws NotConnectedException, UnsupportedFeatureException, OccurenceConstraintException { return server.asyncCompleteRequest(sessionIndex, uniqueId, confirmation); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/IClientAPI.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/IClientAPI.java index 301895ae2..2415dd3c8 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/IClientAPI.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/IClientAPI.java @@ -39,7 +39,8 @@ public interface IClientAPI { CompletionStage send(Request request) throws OccurenceConstraintException, UnsupportedFeatureException; - boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException; + boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException; void disconnect(); diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONClient.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONClient.java index 8615954ba..a2aa0a927 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONClient.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONClient.java @@ -172,7 +172,8 @@ public CompletionStage send(Request request) } @Override - public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException { + public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException { return client.asyncCompleteRequest(uniqueId, confirmation); } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONServer.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONServer.java index b0cc81e42..6f29c01a1 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONServer.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONServer.java @@ -69,9 +69,11 @@ public JSONServer(ServerCoreProfile coreProfile, JSONConfiguration configuration protocols.add(new Protocol("")); draftOcppOnly = new Draft_6455(Collections.emptyList(), protocols); - if(configuration.getParameter(JSONConfiguration.HTTP_HEALTH_CHECK_ENABLED, true)) { + if (configuration.getParameter(JSONConfiguration.HTTP_HEALTH_CHECK_ENABLED, true)) { logger.info("JSONServer 1.6 with HttpHealthCheckDraft"); - this.listener = new WebSocketListener(sessionFactory, configuration, draftOcppOnly, new Draft_HttpHealthCheck()); + this.listener = + new WebSocketListener( + sessionFactory, configuration, draftOcppOnly, new Draft_HttpHealthCheck()); } else { this.listener = new WebSocketListener(sessionFactory, configuration, draftOcppOnly); } @@ -175,7 +177,8 @@ public CompletionStage send(UUID session, Request request) } @Override - public boolean asyncCompleteRequest(UUID sessionIndex, String uniqueId, Confirmation confirmation) throws NotConnectedException, UnsupportedFeatureException, OccurenceConstraintException { + public boolean asyncCompleteRequest(UUID sessionIndex, String uniqueId, Confirmation confirmation) + throws NotConnectedException, UnsupportedFeatureException, OccurenceConstraintException { return server.asyncCompleteRequest(sessionIndex, uniqueId, confirmation); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPClient.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPClient.java index b373590fd..e17604e2f 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPClient.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPClient.java @@ -106,7 +106,8 @@ public CompletionStage send(Request request) } @Override - public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException { + public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException { return client.asyncCompleteRequest(uniqueId, confirmation); } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPServer.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPServer.java index a9c0ab966..a87b04846 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPServer.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPServer.java @@ -89,7 +89,8 @@ public CompletionStage send(UUID session, Request request) } @Override - public boolean asyncCompleteRequest(UUID sessionIndex, String uniqueId, Confirmation confirmation) throws NotConnectedException, UnsupportedFeatureException, OccurenceConstraintException { + public boolean asyncCompleteRequest(UUID sessionIndex, String uniqueId, Confirmation confirmation) + throws NotConnectedException, UnsupportedFeatureException, OccurenceConstraintException { return server.asyncCompleteRequest(sessionIndex, uniqueId, confirmation); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/TimeoutSessionDecorator.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/TimeoutSessionDecorator.java index 474d270c5..4c78300b0 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/TimeoutSessionDecorator.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/TimeoutSessionDecorator.java @@ -98,7 +98,8 @@ public void removeRequest(String ticket) { } @Override - public boolean completePendingPromise(String id, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException { + public boolean completePendingPromise(String id, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException { return this.session.completePendingPromise(id, confirmation); } @@ -132,7 +133,8 @@ public synchronized Confirmation handleRequest(Request request) } @Override - public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) throws UnsupportedFeatureException, OccurenceConstraintException { + public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException { return eventHandler.asyncCompleteRequest(uniqueId, confirmation); } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ClientSecurityExtEventHandler.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ClientSecurityExtEventHandler.java index 540badd8f..e3f9bd4f7 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ClientSecurityExtEventHandler.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ClientSecurityExtEventHandler.java @@ -59,20 +59,24 @@ public interface ClientSecurityExtEventHandler { DeleteCertificateConfirmation handleDeleteCertificateRequest(DeleteCertificateRequest request); /** - * Handle a {@link ExtendedTriggerMessageRequest} and return a {@link ExtendedTriggerMessageConfirmation}. + * Handle a {@link ExtendedTriggerMessageRequest} and return a {@link + * ExtendedTriggerMessageConfirmation}. * * @param request incoming {@link ExtendedTriggerMessageRequest} to handle. * @return outgoing {@link ExtendedTriggerMessageConfirmation} to reply with. */ - ExtendedTriggerMessageConfirmation handleExtendedTriggerMessageRequest(ExtendedTriggerMessageRequest request); + ExtendedTriggerMessageConfirmation handleExtendedTriggerMessageRequest( + ExtendedTriggerMessageRequest request); /** - * Handle a {@link GetInstalledCertificateIdsRequest} and return a {@link GetInstalledCertificateIdsConfirmation}. + * Handle a {@link GetInstalledCertificateIdsRequest} and return a {@link + * GetInstalledCertificateIdsConfirmation}. * * @param request incoming {@link GetInstalledCertificateIdsRequest} to handle. * @return outgoing {@link GetInstalledCertificateIdsConfirmation} to reply with. */ - GetInstalledCertificateIdsConfirmation handleGetInstalledCertificateIdsRequest(GetInstalledCertificateIdsRequest request); + GetInstalledCertificateIdsConfirmation handleGetInstalledCertificateIdsRequest( + GetInstalledCertificateIdsRequest request); /** * Handle a {@link GetLogRequest} and return a {@link GetLogConfirmation}. @@ -91,10 +95,12 @@ public interface ClientSecurityExtEventHandler { InstallCertificateConfirmation handleInstallCertificateRequest(InstallCertificateRequest request); /** - * Handle a {@link SignedUpdateFirmwareRequest} and return a {@link SignedUpdateFirmwareConfirmation}. + * Handle a {@link SignedUpdateFirmwareRequest} and return a {@link + * SignedUpdateFirmwareConfirmation}. * * @param request incoming {@link SignedUpdateFirmwareRequest} to handle. * @return outgoing {@link SignedUpdateFirmwareConfirmation} to reply with. */ - SignedUpdateFirmwareConfirmation handleSignedUpdateFirmwareRequest(SignedUpdateFirmwareRequest request); + SignedUpdateFirmwareConfirmation handleSignedUpdateFirmwareRequest( + SignedUpdateFirmwareRequest request); } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ClientSecurityExtProfile.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ClientSecurityExtProfile.java index 09bbddeeb..2aec013bc 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ClientSecurityExtProfile.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ClientSecurityExtProfile.java @@ -55,7 +55,6 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.SignedUpdateFirmwareRequest; import eu.chargetime.ocpp.model.securityext.types.FirmwareStatusEnumType; import eu.chargetime.ocpp.model.securityext.types.UploadLogStatusEnumType; - import java.time.ZonedDateTime; import java.util.HashSet; import java.util.Set; @@ -97,15 +96,19 @@ public Confirmation handleRequest(UUID sessionIndex, Request request) { } else if (request instanceof DeleteCertificateRequest) { result = eventHandler.handleDeleteCertificateRequest((DeleteCertificateRequest) request); } else if (request instanceof ExtendedTriggerMessageRequest) { - result = eventHandler.handleExtendedTriggerMessageRequest((ExtendedTriggerMessageRequest) request); + result = + eventHandler.handleExtendedTriggerMessageRequest((ExtendedTriggerMessageRequest) request); } else if (request instanceof GetInstalledCertificateIdsRequest) { - result = eventHandler.handleGetInstalledCertificateIdsRequest((GetInstalledCertificateIdsRequest) request); + result = + eventHandler.handleGetInstalledCertificateIdsRequest( + (GetInstalledCertificateIdsRequest) request); } else if (request instanceof GetLogRequest) { result = eventHandler.handleGetLogRequest((GetLogRequest) request); } else if (request instanceof InstallCertificateRequest) { result = eventHandler.handleInstallCertificateRequest((InstallCertificateRequest) request); - }else if (request instanceof SignedUpdateFirmwareRequest) { - result = eventHandler.handleSignedUpdateFirmwareRequest((SignedUpdateFirmwareRequest) request); + } else if (request instanceof SignedUpdateFirmwareRequest) { + result = + eventHandler.handleSignedUpdateFirmwareRequest((SignedUpdateFirmwareRequest) request); } return result; @@ -118,7 +121,8 @@ public Confirmation handleRequest(UUID sessionIndex, Request request) { * @see LogStatusNotificationRequest * @see LogStatusNotificationFeature */ - public LogStatusNotificationRequest createLogStatusNotificationRequest(UploadLogStatusEnumType status) { + public LogStatusNotificationRequest createLogStatusNotificationRequest( + UploadLogStatusEnumType status) { return new LogStatusNotificationRequest(status); } @@ -129,7 +133,8 @@ public LogStatusNotificationRequest createLogStatusNotificationRequest(UploadLog * @see SecurityEventNotificationRequest * @see SecurityEventNotificationFeature */ - public SecurityEventNotificationRequest createSecurityEventNotificationRequest(String type, ZonedDateTime timestamp) { + public SecurityEventNotificationRequest createSecurityEventNotificationRequest( + String type, ZonedDateTime timestamp) { return new SecurityEventNotificationRequest(type, timestamp); } @@ -151,7 +156,8 @@ public SignCertificateRequest createSignCertificateRequest(String csr) { * @see SignedFirmwareStatusNotificationRequest * @see SignedFirmwareStatusNotificationFeature */ - public SignedFirmwareStatusNotificationRequest createSignedFirmwareStatusNotificationRequest(FirmwareStatusEnumType status) { + public SignedFirmwareStatusNotificationRequest createSignedFirmwareStatusNotificationRequest( + FirmwareStatusEnumType status) { return new SignedFirmwareStatusNotificationRequest(status); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ServerSecurityExtEventHandler.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ServerSecurityExtEventHandler.java index ef9574493..444b0f3aa 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ServerSecurityExtEventHandler.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ServerSecurityExtEventHandler.java @@ -34,43 +34,49 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.SignCertificateRequest; import eu.chargetime.ocpp.model.securityext.SignedFirmwareStatusNotificationConfirmation; import eu.chargetime.ocpp.model.securityext.SignedFirmwareStatusNotificationRequest; - import java.util.UUID; public interface ServerSecurityExtEventHandler { /** - * Handle a {@link LogStatusNotificationRequest} and return a {@link LogStatusNotificationConfirmation}. + * Handle a {@link LogStatusNotificationRequest} and return a {@link + * LogStatusNotificationConfirmation}. * * @param sessionIndex source of the request. - * @param request incoming {@link LogStatusNotificationRequest} to handle. + * @param request incoming {@link LogStatusNotificationRequest} to handle. * @return outgoing {@link LogStatusNotificationConfirmation} to reply with. */ - LogStatusNotificationConfirmation handleLogStatusNotificationRequest(UUID sessionIndex, LogStatusNotificationRequest request); + LogStatusNotificationConfirmation handleLogStatusNotificationRequest( + UUID sessionIndex, LogStatusNotificationRequest request); /** - * Handle a {@link SecurityEventNotificationRequest} and return a {@link SecurityEventNotificationConfirmation}. + * Handle a {@link SecurityEventNotificationRequest} and return a {@link + * SecurityEventNotificationConfirmation}. * * @param sessionIndex source of the request. - * @param request incoming {@link SecurityEventNotificationRequest} to handle. + * @param request incoming {@link SecurityEventNotificationRequest} to handle. * @return outgoing {@link SecurityEventNotificationConfirmation} to reply with. */ - SecurityEventNotificationConfirmation handleSecurityEventNotificationRequest(UUID sessionIndex, SecurityEventNotificationRequest request); + SecurityEventNotificationConfirmation handleSecurityEventNotificationRequest( + UUID sessionIndex, SecurityEventNotificationRequest request); /** * Handle a {@link SignCertificateRequest} and return a {@link SignCertificateConfirmation}. * * @param sessionIndex source of the request. - * @param request incoming {@link SignCertificateRequest} to handle. + * @param request incoming {@link SignCertificateRequest} to handle. * @return outgoing {@link SignCertificateConfirmation} to reply with. */ - SignCertificateConfirmation handleSignCertificateRequest(UUID sessionIndex, SignCertificateRequest request); + SignCertificateConfirmation handleSignCertificateRequest( + UUID sessionIndex, SignCertificateRequest request); /** - * Handle a {@link SignedFirmwareStatusNotificationRequest} and return a {@link SignedFirmwareStatusNotificationConfirmation}. + * Handle a {@link SignedFirmwareStatusNotificationRequest} and return a {@link + * SignedFirmwareStatusNotificationConfirmation}. * * @param sessionIndex source of the request. - * @param request incoming {@link SignedFirmwareStatusNotificationRequest} to handle. + * @param request incoming {@link SignedFirmwareStatusNotificationRequest} to handle. * @return outgoing {@link SignedFirmwareStatusNotificationConfirmation} to reply with. */ - SignedFirmwareStatusNotificationConfirmation handleSignedFirmwareStatusNotificationRequest(UUID sessionIndex, SignedFirmwareStatusNotificationRequest request); + SignedFirmwareStatusNotificationConfirmation handleSignedFirmwareStatusNotificationRequest( + UUID sessionIndex, SignedFirmwareStatusNotificationRequest request); } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ServerSecurityExtProfile.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ServerSecurityExtProfile.java index 2e305f0d4..0ab3b30c6 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ServerSecurityExtProfile.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/profile/securityext/ServerSecurityExtProfile.java @@ -59,7 +59,6 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.types.LogEnumType; import eu.chargetime.ocpp.model.securityext.types.LogParametersType; import eu.chargetime.ocpp.model.securityext.types.MessageTriggerEnumType; - import java.util.HashSet; import java.util.Set; import java.util.UUID; @@ -96,13 +95,19 @@ public Confirmation handleRequest(UUID sessionIndex, Request request) { Confirmation result = null; if (request instanceof LogStatusNotificationRequest) { - result = handler.handleLogStatusNotificationRequest(sessionIndex, (LogStatusNotificationRequest) request); + result = + handler.handleLogStatusNotificationRequest( + sessionIndex, (LogStatusNotificationRequest) request); } else if (request instanceof SecurityEventNotificationRequest) { - result = handler.handleSecurityEventNotificationRequest(sessionIndex, (SecurityEventNotificationRequest) request); + result = + handler.handleSecurityEventNotificationRequest( + sessionIndex, (SecurityEventNotificationRequest) request); } else if (request instanceof SignCertificateRequest) { result = handler.handleSignCertificateRequest(sessionIndex, (SignCertificateRequest) request); } else if (request instanceof SignedFirmwareStatusNotificationRequest) { - result = handler.handleSignedFirmwareStatusNotificationRequest(sessionIndex, (SignedFirmwareStatusNotificationRequest) request); + result = + handler.handleSignedFirmwareStatusNotificationRequest( + sessionIndex, (SignedFirmwareStatusNotificationRequest) request); } return result; @@ -126,7 +131,8 @@ public CertificateSignedRequest createCertificateSignedRequest(String certificat * @see DeleteCertificateRequest * @see DeleteCertificateFeature */ - public DeleteCertificateRequest createDeleteCertificateRequest(CertificateHashDataType certificateHashData) { + public DeleteCertificateRequest createDeleteCertificateRequest( + CertificateHashDataType certificateHashData) { return new DeleteCertificateRequest(certificateHashData); } @@ -137,7 +143,8 @@ public DeleteCertificateRequest createDeleteCertificateRequest(CertificateHashDa * @see ExtendedTriggerMessageRequest * @see ExtendedTriggerMessageFeature */ - public ExtendedTriggerMessageRequest createExtendedTriggerMessageRequest(MessageTriggerEnumType requestedMessage) { + public ExtendedTriggerMessageRequest createExtendedTriggerMessageRequest( + MessageTriggerEnumType requestedMessage) { return new ExtendedTriggerMessageRequest(requestedMessage); } @@ -148,7 +155,8 @@ public ExtendedTriggerMessageRequest createExtendedTriggerMessageRequest(Message * @see GetInstalledCertificateIdsRequest * @see GetInstalledCertificateIdsFeature */ - public GetInstalledCertificateIdsRequest createGetInstalledCertificateIdsRequest(CertificateUseEnumType certificateType) { + public GetInstalledCertificateIdsRequest createGetInstalledCertificateIdsRequest( + CertificateUseEnumType certificateType) { return new GetInstalledCertificateIdsRequest(certificateType); } @@ -159,7 +167,8 @@ public GetInstalledCertificateIdsRequest createGetInstalledCertificateIdsRequest * @see GetLogRequest * @see GetLogFeature */ - public GetLogRequest createGetLogRequest(LogEnumType logType, Integer requestId, LogParametersType log) { + public GetLogRequest createGetLogRequest( + LogEnumType logType, Integer requestId, LogParametersType log) { return new GetLogRequest(logType, requestId, log); } @@ -170,7 +179,8 @@ public GetLogRequest createGetLogRequest(LogEnumType logType, Integer requestId, * @see InstallCertificateRequest * @see InstallCertificateFeature */ - public InstallCertificateRequest createInstallCertificateRequest(CertificateUseEnumType certificateType, String certificate) { + public InstallCertificateRequest createInstallCertificateRequest( + CertificateUseEnumType certificateType, String certificate) { return new InstallCertificateRequest(certificateType, certificate); } @@ -181,7 +191,8 @@ public InstallCertificateRequest createInstallCertificateRequest(CertificateUseE * @see SignedUpdateFirmwareRequest * @see SignedUpdateFirmwareFeature */ - public SignedUpdateFirmwareRequest createSignedUpdateFirmwareRequest(Integer requestId, FirmwareType firmware) { + public SignedUpdateFirmwareRequest createSignedUpdateFirmwareRequest( + Integer requestId, FirmwareType firmware) { return new SignedUpdateFirmwareRequest(requestId, firmware); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/BootNotificationRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/BootNotificationRequest.java index 662d8d594..93220abd5 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/BootNotificationRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/BootNotificationRequest.java @@ -160,7 +160,8 @@ public String getChargeBoxSerialNumber() { */ @Deprecated() public void setChargeBoxSerialNumber(String chargeBoxSerialNumber) { - if (chargeBoxSerialNumber != null && !ModelUtil.validate(chargeBoxSerialNumber, STRING_25_CHAR_MAX_LENGTH)) { + if (chargeBoxSerialNumber != null + && !ModelUtil.validate(chargeBoxSerialNumber, STRING_25_CHAR_MAX_LENGTH)) { throw new PropertyConstraintException( chargeBoxSerialNumber.length(), validationErrorMessage(STRING_25_CHAR_MAX_LENGTH)); } @@ -184,7 +185,8 @@ public String getChargePointSerialNumber() { */ @XmlElement public void setChargePointSerialNumber(String chargePointSerialNumber) { - if (chargePointSerialNumber != null && !ModelUtil.validate(chargePointSerialNumber, STRING_25_CHAR_MAX_LENGTH)) { + if (chargePointSerialNumber != null + && !ModelUtil.validate(chargePointSerialNumber, STRING_25_CHAR_MAX_LENGTH)) { throw new PropertyConstraintException( chargePointSerialNumber.length(), validationErrorMessage(STRING_25_CHAR_MAX_LENGTH)); } @@ -208,7 +210,8 @@ public String getFirmwareVersion() { */ @XmlElement public void setFirmwareVersion(String firmwareVersion) { - if (firmwareVersion != null && !ModelUtil.validate(firmwareVersion, STRING_50_CHAR_MAX_LENGTH)) { + if (firmwareVersion != null + && !ModelUtil.validate(firmwareVersion, STRING_50_CHAR_MAX_LENGTH)) { throw new PropertyConstraintException( firmwareVersion.length(), validationErrorMessage(STRING_50_CHAR_MAX_LENGTH)); } @@ -280,7 +283,8 @@ public String getMeterSerialNumber() { */ @XmlElement public void setMeterSerialNumber(String meterSerialNumber) { - if (meterSerialNumber != null && !ModelUtil.validate(meterSerialNumber, STRING_25_CHAR_MAX_LENGTH)) { + if (meterSerialNumber != null + && !ModelUtil.validate(meterSerialNumber, STRING_25_CHAR_MAX_LENGTH)) { throw new PropertyConstraintException( meterSerialNumber.length(), validationErrorMessage(STRING_25_CHAR_MAX_LENGTH)); } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/MeterValuesRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/MeterValuesRequest.java index fd4a35d4f..172ca9d4d 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/MeterValuesRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/MeterValuesRequest.java @@ -64,7 +64,11 @@ public MeterValuesRequest(Integer connectorId) { @Override public boolean validate() { - boolean valid = this.connectorId != null && this.connectorId >= 0 && this.meterValue != null && meterValue.length > 0; + boolean valid = + this.connectorId != null + && this.connectorId >= 0 + && this.meterValue != null + && meterValue.length > 0; if (valid) { for (MeterValue current : this.meterValue) { diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/CertificateSignedConfirmation.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/CertificateSignedConfirmation.java index 346dc1a08..2dfd0050f 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/CertificateSignedConfirmation.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/CertificateSignedConfirmation.java @@ -30,23 +30,20 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.securityext.types.CertificateSignedStatusEnumType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class CertificateSignedConfirmation extends Confirmation { private CertificateSignedStatusEnumType status; - /** - * Private default constructor for serialization purposes. - */ - private CertificateSignedConfirmation() { - } + /** Private default constructor for serialization purposes. */ + private CertificateSignedConfirmation() {} /** * Handle required fields. * - * @param status CertificateSignedStatusEnumType. See {@link #setStatus(CertificateSignedStatusEnumType)} + * @param status CertificateSignedStatusEnumType. See {@link + * #setStatus(CertificateSignedStatusEnumType)} */ public CertificateSignedConfirmation(CertificateSignedStatusEnumType status) { setStatus(status); @@ -91,7 +88,8 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("status", status) - .add("isValid", validate()).toString(); + .add("status", status) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/CertificateSignedRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/CertificateSignedRequest.java index 3c52cb242..31602ae8d 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/CertificateSignedRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/CertificateSignedRequest.java @@ -31,24 +31,20 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.validation.Validator; import eu.chargetime.ocpp.model.validation.ValidatorBuilder; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class CertificateSignedRequest extends RequestWithId { private static final transient Validator certificateChainValidator = - new ValidatorBuilder() - .addRule(new StringMaxLengthValidationRule(10000)) - .setRequired(true) - .build(); + new ValidatorBuilder() + .addRule(new StringMaxLengthValidationRule(10000)) + .setRequired(true) + .build(); private String certificateChain; - /** - * Private default constructor for serialization purposes. - */ - private CertificateSignedRequest() { - } + /** Private default constructor for serialization purposes. */ + private CertificateSignedRequest() {} /** * Handle required fields. @@ -60,9 +56,9 @@ public CertificateSignedRequest(String certificateChain) { } /** - * The signed PEM encoded X.509 certificates. This can also contain the - * necessary sub CA certificates. The maximum size of this field is limited by the - * configuration key: CertificateSignedMaxSize. + * The signed PEM encoded X.509 certificates. This can also contain the necessary sub CA + * certificates. The maximum size of this field is limited by the configuration key: + * CertificateSignedMaxSize. * * @return string[0..10000] */ @@ -71,9 +67,9 @@ public String getCertificateChain() { } /** - * Required. The signed PEM encoded X.509 certificates. This can also contain the - * necessary sub CA certificates. The maximum size of this field is limited by the - * configuration key: CertificateSignedMaxSize. + * Required. The signed PEM encoded X.509 certificates. This can also contain the necessary sub CA + * certificates. The maximum size of this field is limited by the configuration key: + * CertificateSignedMaxSize. * * @param certificateChain string[0..10000] */ @@ -108,7 +104,8 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("certificateChain", certificateChain) - .add("isValid", validate()).toString(); + .add("certificateChain", certificateChain) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/DeleteCertificateConfirmation.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/DeleteCertificateConfirmation.java index 3c6d1aedf..286dd41cf 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/DeleteCertificateConfirmation.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/DeleteCertificateConfirmation.java @@ -30,23 +30,20 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.securityext.types.DeleteCertificateStatusEnumType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class DeleteCertificateConfirmation extends Confirmation { private DeleteCertificateStatusEnumType status; - /** - * Private default constructor for serialization purposes. - */ - private DeleteCertificateConfirmation() { - } + /** Private default constructor for serialization purposes. */ + private DeleteCertificateConfirmation() {} /** * Handle required fields. * - * @param status DeleteCertificateStatusEnumType. See {@link #setStatus(DeleteCertificateStatusEnumType)} + * @param status DeleteCertificateStatusEnumType. See {@link + * #setStatus(DeleteCertificateStatusEnumType)} */ public DeleteCertificateConfirmation(DeleteCertificateStatusEnumType status) { setStatus(status); @@ -91,7 +88,8 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("status", status) - .add("isValid", validate()).toString(); + .add("status", status) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/DeleteCertificateRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/DeleteCertificateRequest.java index 29e10898f..d2de169be 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/DeleteCertificateRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/DeleteCertificateRequest.java @@ -29,18 +29,14 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.RequestWithId; import eu.chargetime.ocpp.model.securityext.types.CertificateHashDataType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class DeleteCertificateRequest extends RequestWithId { private CertificateHashDataType certificateHashData; - /** - * Private default constructor for serialization purposes. - */ - private DeleteCertificateRequest() { - } + /** Private default constructor for serialization purposes. */ + private DeleteCertificateRequest() {} /** * Handle required fields. @@ -95,7 +91,8 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("certificateHashData", certificateHashData) - .add("isValid", validate()).toString(); + .add("certificateHashData", certificateHashData) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/ExtendedTriggerMessageConfirmation.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/ExtendedTriggerMessageConfirmation.java index 91decd7de..2ca86bbce 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/ExtendedTriggerMessageConfirmation.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/ExtendedTriggerMessageConfirmation.java @@ -30,23 +30,20 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.securityext.types.TriggerMessageStatusEnumType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class ExtendedTriggerMessageConfirmation extends Confirmation { private TriggerMessageStatusEnumType status; - /** - * Private default constructor for serialization purposes. - */ - private ExtendedTriggerMessageConfirmation() { - } + /** Private default constructor for serialization purposes. */ + private ExtendedTriggerMessageConfirmation() {} /** * Handle required fields. * - * @param status TriggerMessageStatusEnumType. See {@link #setStatus(TriggerMessageStatusEnumType)} + * @param status TriggerMessageStatusEnumType. See {@link + * #setStatus(TriggerMessageStatusEnumType)} */ public ExtendedTriggerMessageConfirmation(TriggerMessageStatusEnumType status) { setStatus(status); @@ -91,7 +88,8 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("status", status) - .add("isValid", validate()).toString(); + .add("status", status) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/ExtendedTriggerMessageRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/ExtendedTriggerMessageRequest.java index 6490298b8..52ec62e67 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/ExtendedTriggerMessageRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/ExtendedTriggerMessageRequest.java @@ -30,7 +30,6 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.RequestWithId; import eu.chargetime.ocpp.model.securityext.types.MessageTriggerEnumType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class ExtendedTriggerMessageRequest extends RequestWithId { @@ -38,16 +37,14 @@ public class ExtendedTriggerMessageRequest extends RequestWithId { private MessageTriggerEnumType requestedMessage; private Integer connectorId; - /** - * Private default constructor for serialization purposes. - */ - private ExtendedTriggerMessageRequest() { - } + /** Private default constructor for serialization purposes. */ + private ExtendedTriggerMessageRequest() {} /** * Handle required fields. * - * @param requestedMessage MessageTriggerEnumType. See {@link #setRequestedMessage(MessageTriggerEnumType)} + * @param requestedMessage MessageTriggerEnumType. See {@link + * #setRequestedMessage(MessageTriggerEnumType)} */ public ExtendedTriggerMessageRequest(MessageTriggerEnumType requestedMessage) { setRequestedMessage(requestedMessage); @@ -99,8 +96,7 @@ public boolean transactionRelated() { @Override public boolean validate() { - return requestedMessage != null - && (connectorId == null || connectorId > 0); + return requestedMessage != null && (connectorId == null || connectorId > 0); } @Override @@ -109,7 +105,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; ExtendedTriggerMessageRequest that = (ExtendedTriggerMessageRequest) o; return Objects.equals(requestedMessage, that.requestedMessage) - && Objects.equals(connectorId, that.connectorId); + && Objects.equals(connectorId, that.connectorId); } @Override @@ -120,8 +116,9 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("requestedMessage", requestedMessage) - .add("connectorId", connectorId) - .add("isValid", validate()).toString(); + .add("requestedMessage", requestedMessage) + .add("connectorId", connectorId) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetInstalledCertificateIdsConfirmation.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetInstalledCertificateIdsConfirmation.java index 35a6465ab..928013c9d 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetInstalledCertificateIdsConfirmation.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetInstalledCertificateIdsConfirmation.java @@ -31,7 +31,6 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.types.CertificateHashDataType; import eu.chargetime.ocpp.model.securityext.types.GetInstalledCertificateStatusEnumType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Arrays; import java.util.Objects; @@ -40,16 +39,14 @@ public class GetInstalledCertificateIdsConfirmation extends Confirmation { private GetInstalledCertificateStatusEnumType status; private CertificateHashDataType[] certificateHashData; - /** - * Private default constructor for serialization purposes. - */ - private GetInstalledCertificateIdsConfirmation() { - } + /** Private default constructor for serialization purposes. */ + private GetInstalledCertificateIdsConfirmation() {} /** * Handle required fields. * - * @param status GetInstalledCertificateStatusEnumType. See {@link #setStatus(GetInstalledCertificateStatusEnumType)} + * @param status GetInstalledCertificateStatusEnumType. See {@link + * #setStatus(GetInstalledCertificateStatusEnumType)} */ public GetInstalledCertificateIdsConfirmation(GetInstalledCertificateStatusEnumType status) { setStatus(status); @@ -114,7 +111,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; GetInstalledCertificateIdsConfirmation that = (GetInstalledCertificateIdsConfirmation) o; return Objects.equals(status, that.status) - && Arrays.equals(certificateHashData, that.certificateHashData); + && Arrays.equals(certificateHashData, that.certificateHashData); } @Override @@ -125,8 +122,9 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("status", status) - .add("certificateHashData", certificateHashData) - .add("isValid", validate()).toString(); + .add("status", status) + .add("certificateHashData", certificateHashData) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetInstalledCertificateIdsRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetInstalledCertificateIdsRequest.java index 6dbf04a26..efbe4bbbd 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetInstalledCertificateIdsRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetInstalledCertificateIdsRequest.java @@ -29,23 +29,20 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.RequestWithId; import eu.chargetime.ocpp.model.securityext.types.CertificateUseEnumType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class GetInstalledCertificateIdsRequest extends RequestWithId { private CertificateUseEnumType certificateType; - /** - * Private default constructor for serialization purposes. - */ - private GetInstalledCertificateIdsRequest() { - } + /** Private default constructor for serialization purposes. */ + private GetInstalledCertificateIdsRequest() {} /** * Handle required fields. * - * @param certificateType CertificateUseEnumType. See {@link #setCertificateType(CertificateUseEnumType)} + * @param certificateType CertificateUseEnumType. See {@link + * #setCertificateType(CertificateUseEnumType)} */ public GetInstalledCertificateIdsRequest(CertificateUseEnumType certificateType) { setCertificateType(certificateType); @@ -95,7 +92,8 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("certificateType", certificateType) - .add("isValid", validate()).toString(); + .add("certificateType", certificateType) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetLogConfirmation.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetLogConfirmation.java index 6ac8674c0..93e89180c 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetLogConfirmation.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetLogConfirmation.java @@ -33,24 +33,18 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.validation.Validator; import eu.chargetime.ocpp.model.validation.ValidatorBuilder; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class GetLogConfirmation extends Confirmation { private static final transient Validator filenameValidator = - new ValidatorBuilder() - .addRule(new StringMaxLengthValidationRule(255)) - .build(); + new ValidatorBuilder().addRule(new StringMaxLengthValidationRule(255)).build(); private LogStatusEnumType status; private String filename; - /** - * Private default constructor for serialization purposes. - */ - private GetLogConfirmation() { - } + /** Private default constructor for serialization purposes. */ + private GetLogConfirmation() {} /** * Handle required fields. @@ -62,8 +56,7 @@ public GetLogConfirmation(LogStatusEnumType status) { } /** - * This field indicates whether the Charge Point was able to accept the - * request. + * This field indicates whether the Charge Point was able to accept the request. * * @return {@link LogStatusEnumType} */ @@ -72,8 +65,7 @@ public LogStatusEnumType getStatus() { } /** - * Required. This field indicates whether the Charge Point was able to accept the - * request. + * Required. This field indicates whether the Charge Point was able to accept the request. * * @param status {@link LogStatusEnumType} */ @@ -82,8 +74,8 @@ public void setStatus(LogStatusEnumType status) { } /** - * This contains the name of the log file that will be uploaded. This field is - * not present when no logging information is available. + * This contains the name of the log file that will be uploaded. This field is not present when no + * logging information is available. * * @return string[0..255] */ @@ -92,8 +84,8 @@ public String getFilename() { } /** - * Optional. This contains the name of the log file that will be uploaded. This field is - * not present when no logging information is available. + * Optional. This contains the name of the log file that will be uploaded. This field is not + * present when no logging information is available. * * @param filename string[0..255] */ @@ -112,8 +104,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GetLogConfirmation that = (GetLogConfirmation) o; - return Objects.equals(status, that.status) - && Objects.equals(filename, that.filename); + return Objects.equals(status, that.status) && Objects.equals(filename, that.filename); } @Override @@ -124,8 +115,9 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("status", status) - .add("filename", filename) - .add("isValid", validate()).toString(); + .add("status", status) + .add("filename", filename) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetLogRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetLogRequest.java index 232db0c5b..6edfa32cc 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetLogRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/GetLogRequest.java @@ -30,7 +30,6 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.types.LogEnumType; import eu.chargetime.ocpp.model.securityext.types.LogParametersType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class GetLogRequest extends RequestWithId { @@ -41,18 +40,15 @@ public class GetLogRequest extends RequestWithId { private Integer retryInterval; private LogParametersType log; - /** - * Private default constructor for serialization purposes. - */ - private GetLogRequest() { - } + /** Private default constructor for serialization purposes. */ + private GetLogRequest() {} /** * Handle required fields. * - * @param logType LogEnumType. See {@link #setLogType(LogEnumType)} + * @param logType LogEnumType. See {@link #setLogType(LogEnumType)} * @param requestId Integer. See {@link #setRequestId(Integer)} - * @param log LogParametersType. See {@link #setLog(LogParametersType)} + * @param log LogParametersType. See {@link #setLog(LogParametersType)} */ public GetLogRequest(LogEnumType logType, Integer requestId, LogParametersType log) { setLogType(logType); @@ -97,9 +93,9 @@ public void setRequestId(Integer requestId) { } /** - * This specifies how many times the Charge Point must try to upload the log - * before giving up. If this field is not present, it is left to Charge Point - * to decide how many times it wants to retry. + * This specifies how many times the Charge Point must try to upload the log before giving up. If + * this field is not present, it is left to Charge Point to decide how many times it wants to + * retry. * * @return Integer */ @@ -108,9 +104,9 @@ public Integer getRetries() { } /** - * Optional. This specifies how many times the Charge Point must try to upload the log - * before giving up. If this field is not present, it is left to Charge Point - * to decide how many times it wants to retry. + * Optional. This specifies how many times the Charge Point must try to upload the log before + * giving up. If this field is not present, it is left to Charge Point to decide how many times it + * wants to retry. * * @param retries Integer */ @@ -119,9 +115,8 @@ public void setRetries(Integer retries) { } /** - * The interval in seconds after which a retry may be attempted. If this - * field is not present, it is left to Charge Point to decide how long to wait between - * attempts + * The interval in seconds after which a retry may be attempted. If this field is not present, it + * is left to Charge Point to decide how long to wait between attempts * * @return Integer */ @@ -130,9 +125,8 @@ public Integer getRetryInterval() { } /** - * Optional. The interval in seconds after which a retry may be attempted. If this - * field is not present, it is left to Charge Point to decide how long to wait between - * attempts + * Optional. The interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charge Point to decide how long to wait between attempts * * @param retryInterval Integer */ @@ -141,8 +135,7 @@ public void setRetryInterval(Integer retryInterval) { } /** - * This field specifies the requested log and the location to which the log - * should be sent. + * This field specifies the requested log and the location to which the log should be sent. * * @return {@link LogParametersType} */ @@ -151,8 +144,8 @@ public LogParametersType getLog() { } /** - * Required. This field specifies the requested log and the location to which the log - * should be sent. + * Required. This field specifies the requested log and the location to which the log should be + * sent. * * @param log {@link LogParametersType} */ @@ -176,10 +169,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; GetLogRequest that = (GetLogRequest) o; return Objects.equals(logType, that.logType) - && Objects.equals(requestId, that.requestId) - && Objects.equals(retries, that.retries) - && Objects.equals(retryInterval, that.retryInterval) - && Objects.equals(log, that.log); + && Objects.equals(requestId, that.requestId) + && Objects.equals(retries, that.retries) + && Objects.equals(retryInterval, that.retryInterval) + && Objects.equals(log, that.log); } @Override @@ -190,11 +183,12 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("logType", logType) - .add("requestId", requestId) - .add("retries", retries) - .add("retryInterval", retryInterval) - .add("log", log) - .add("isValid", validate()).toString(); + .add("logType", logType) + .add("requestId", requestId) + .add("retries", retries) + .add("retryInterval", retryInterval) + .add("log", log) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/InstallCertificateConfirmation.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/InstallCertificateConfirmation.java index 2ef4fc69d..592abf4dd 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/InstallCertificateConfirmation.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/InstallCertificateConfirmation.java @@ -30,18 +30,14 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.securityext.types.CertificateStatusEnumType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class InstallCertificateConfirmation extends Confirmation { private CertificateStatusEnumType status; - /** - * Private default constructor for serialization purposes. - */ - private InstallCertificateConfirmation() { - } + /** Private default constructor for serialization purposes. */ + private InstallCertificateConfirmation() {} /** * Handle required fields. @@ -91,7 +87,8 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("status", status) - .add("isValid", validate()).toString(); + .add("status", status) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/InstallCertificateRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/InstallCertificateRequest.java index ccda2cc25..1dadd6500 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/InstallCertificateRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/InstallCertificateRequest.java @@ -32,31 +32,28 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.validation.Validator; import eu.chargetime.ocpp.model.validation.ValidatorBuilder; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class InstallCertificateRequest extends RequestWithId { private static final transient Validator certificateValidator = - new ValidatorBuilder() - .addRule(new StringMaxLengthValidationRule(5500)) - .setRequired(true) - .build(); + new ValidatorBuilder() + .addRule(new StringMaxLengthValidationRule(5500)) + .setRequired(true) + .build(); private CertificateUseEnumType certificateType; private String certificate; - /** - * Private default constructor for serialization purposes. - */ - private InstallCertificateRequest() { - } + /** Private default constructor for serialization purposes. */ + private InstallCertificateRequest() {} /** * Handle required fields. * - * @param certificateType CertificateUseEnumType. See {@link #setCertificateType(CertificateUseEnumType)} - * @param certificate String. See {@link #setCertificate(String)} + * @param certificateType CertificateUseEnumType. See {@link + * #setCertificateType(CertificateUseEnumType)} + * @param certificate String. See {@link #setCertificate(String)} */ public InstallCertificateRequest(CertificateUseEnumType certificateType, String certificate) { setCertificateType(certificateType); @@ -116,7 +113,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; InstallCertificateRequest that = (InstallCertificateRequest) o; return Objects.equals(certificateType, that.certificateType) - && Objects.equals(certificate, that.certificate); + && Objects.equals(certificate, that.certificate); } @Override @@ -127,8 +124,9 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("certificateType", certificateType) - .add("certificate", certificate) - .add("isValid", validate()).toString(); + .add("certificateType", certificateType) + .add("certificate", certificate) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/LogStatusNotificationConfirmation.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/LogStatusNotificationConfirmation.java index 93f819bf5..7c28f2fe2 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/LogStatusNotificationConfirmation.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/LogStatusNotificationConfirmation.java @@ -29,7 +29,6 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class LogStatusNotificationConfirmation extends Confirmation { @@ -51,7 +50,6 @@ public int hashCode() { @Override public String toString() { - return MoreObjects.toStringHelper(this) - .add("isValid", validate()).toString(); + return MoreObjects.toStringHelper(this).add("isValid", validate()).toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/LogStatusNotificationRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/LogStatusNotificationRequest.java index bc41ef170..cf720c537 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/LogStatusNotificationRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/LogStatusNotificationRequest.java @@ -29,7 +29,6 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.RequestWithId; import eu.chargetime.ocpp.model.securityext.types.UploadLogStatusEnumType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class LogStatusNotificationRequest extends RequestWithId { @@ -37,11 +36,8 @@ public class LogStatusNotificationRequest extends RequestWithId { private UploadLogStatusEnumType status; private Integer requestId; - /** - * Private default constructor for serialization purposes. - */ - private LogStatusNotificationRequest() { - } + /** Private default constructor for serialization purposes. */ + private LogStatusNotificationRequest() {} /** * Handle required fields. @@ -71,8 +67,7 @@ public void setStatus(UploadLogStatusEnumType status) { } /** - * The request id that was provided in the {@link GetLogRequest} - * that started this log upload. + * The request id that was provided in the {@link GetLogRequest} that started this log upload. * * @return Integer */ @@ -81,8 +76,8 @@ public Integer getRequestId() { } /** - * Optional. The request id that was provided in the {@link GetLogRequest} - * that started this log upload. + * Optional. The request id that was provided in the {@link GetLogRequest} that started this log + * upload. * * @param requestId Integer */ @@ -105,8 +100,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; LogStatusNotificationRequest that = (LogStatusNotificationRequest) o; - return Objects.equals(status, that.status) - && Objects.equals(requestId, that.requestId); + return Objects.equals(status, that.status) && Objects.equals(requestId, that.requestId); } @Override @@ -117,8 +111,9 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("status", status) - .add("requestId", requestId) - .add("isValid", validate()).toString(); + .add("status", status) + .add("requestId", requestId) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SecurityEventNotificationConfirmation.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SecurityEventNotificationConfirmation.java index 51cf90286..7407fcadd 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SecurityEventNotificationConfirmation.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SecurityEventNotificationConfirmation.java @@ -29,7 +29,6 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class SecurityEventNotificationConfirmation extends Confirmation { @@ -51,7 +50,6 @@ public int hashCode() { @Override public String toString() { - return MoreObjects.toStringHelper(this) - .add("isValid", validate()).toString(); + return MoreObjects.toStringHelper(this).add("isValid", validate()).toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SecurityEventNotificationRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SecurityEventNotificationRequest.java index e4f3cbfad..44fd2318e 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SecurityEventNotificationRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SecurityEventNotificationRequest.java @@ -31,37 +31,31 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.validation.Validator; import eu.chargetime.ocpp.model.validation.ValidatorBuilder; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.time.ZonedDateTime; import java.util.Objects; public class SecurityEventNotificationRequest extends RequestWithId { private static final transient Validator typeValidator = - new ValidatorBuilder() - .addRule(new StringMaxLengthValidationRule(50)) - .setRequired(true) - .build(); + new ValidatorBuilder() + .addRule(new StringMaxLengthValidationRule(50)) + .setRequired(true) + .build(); private static final transient Validator techInfoValidator = - new ValidatorBuilder() - .addRule(new StringMaxLengthValidationRule(255)) - .build(); + new ValidatorBuilder().addRule(new StringMaxLengthValidationRule(255)).build(); private String type; private ZonedDateTime timestamp; private String techInfo; - /** - * Private default constructor for serialization purposes. - */ - private SecurityEventNotificationRequest() { - } + /** Private default constructor for serialization purposes. */ + private SecurityEventNotificationRequest() {} /** * Handle required fields. * - * @param type String. See {@link #setType(String)} + * @param type String. See {@link #setType(String)} * @param timestamp dateTime. See {@link #setTimestamp(ZonedDateTime)} */ public SecurityEventNotificationRequest(String type, ZonedDateTime timestamp) { @@ -133,8 +127,8 @@ public boolean transactionRelated() { @Override public boolean validate() { return typeValidator.safeValidate(type) - && timestamp != null - && techInfoValidator.safeValidate(techInfo); + && timestamp != null + && techInfoValidator.safeValidate(techInfo); } @Override @@ -143,8 +137,8 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; SecurityEventNotificationRequest that = (SecurityEventNotificationRequest) o; return Objects.equals(type, that.type) - && Objects.equals(timestamp, that.timestamp) - && Objects.equals(techInfo, that.techInfo); + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(techInfo, that.techInfo); } @Override @@ -155,9 +149,10 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("type", type) - .add("timestamp", timestamp) - .add("techInfo", techInfo) - .add("isValid", validate()).toString(); + .add("type", type) + .add("timestamp", timestamp) + .add("techInfo", techInfo) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignCertificateConfirmation.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignCertificateConfirmation.java index f76a0c2ac..488023208 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignCertificateConfirmation.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignCertificateConfirmation.java @@ -30,18 +30,14 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.securityext.types.GenericStatusEnumType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class SignCertificateConfirmation extends Confirmation { private GenericStatusEnumType status; - /** - * Private default constructor for serialization purposes. - */ - private SignCertificateConfirmation() { - } + /** Private default constructor for serialization purposes. */ + private SignCertificateConfirmation() {} /** * Handle required fields. @@ -91,7 +87,8 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("status", status) - .add("isValid", validate()).toString(); + .add("status", status) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignCertificateRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignCertificateRequest.java index 97c00bcbe..ee5eb9406 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignCertificateRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignCertificateRequest.java @@ -31,24 +31,20 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.validation.Validator; import eu.chargetime.ocpp.model.validation.ValidatorBuilder; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class SignCertificateRequest extends RequestWithId { private static final transient Validator csrValidator = - new ValidatorBuilder() - .addRule(new StringMaxLengthValidationRule(5500)) - .setRequired(true) - .build(); + new ValidatorBuilder() + .addRule(new StringMaxLengthValidationRule(5500)) + .setRequired(true) + .build(); private String csr; - /** - * Private default constructor for serialization purposes. - */ - private SignCertificateRequest() { - } + /** Private default constructor for serialization purposes. */ + private SignCertificateRequest() {} /** * Handle required fields. @@ -60,9 +56,8 @@ public SignCertificateRequest(String csr) { } /** - * The Charge Point SHALL send the public key in form of a Certificate - * Signing Request (CSR) as described in RFC 2986 and then PEM encoded, - * using the {@link SignCertificateRequest} message. + * The Charge Point SHALL send the public key in form of a Certificate Signing Request (CSR) as + * described in RFC 2986 and then PEM encoded, using the {@link SignCertificateRequest} message. * * @return string[0..5500] */ @@ -71,9 +66,9 @@ public String getCsr() { } /** - * Required. The Charge Point SHALL send the public key in form of a Certificate - * Signing Request (CSR) as described in RFC 2986 and then PEM encoded, - * using the {@link SignCertificateRequest} message. + * Required. The Charge Point SHALL send the public key in form of a Certificate Signing Request + * (CSR) as described in RFC 2986 and then PEM encoded, using the {@link SignCertificateRequest} + * message. * * @param csr string[0..5500] */ @@ -107,8 +102,6 @@ public int hashCode() { @Override public String toString() { - return MoreObjects.toStringHelper(this) - .add("csr", csr) - .add("isValid", validate()).toString(); + return MoreObjects.toStringHelper(this).add("csr", csr).add("isValid", validate()).toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedFirmwareStatusNotificationConfirmation.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedFirmwareStatusNotificationConfirmation.java index e7aa98411..8325fba2e 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedFirmwareStatusNotificationConfirmation.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedFirmwareStatusNotificationConfirmation.java @@ -29,7 +29,6 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class SignedFirmwareStatusNotificationConfirmation extends Confirmation { @@ -51,7 +50,6 @@ public int hashCode() { @Override public String toString() { - return MoreObjects.toStringHelper(this) - .add("isValid", validate()).toString(); + return MoreObjects.toStringHelper(this).add("isValid", validate()).toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedFirmwareStatusNotificationRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedFirmwareStatusNotificationRequest.java index 47e14f399..327a2fb89 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedFirmwareStatusNotificationRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedFirmwareStatusNotificationRequest.java @@ -30,7 +30,6 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.remotetrigger.TriggerMessageRequest; import eu.chargetime.ocpp.model.securityext.types.FirmwareStatusEnumType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class SignedFirmwareStatusNotificationRequest extends RequestWithId { @@ -38,11 +37,8 @@ public class SignedFirmwareStatusNotificationRequest extends RequestWithId { private FirmwareStatusEnumType status; private Integer requestId; - /** - * Private default constructor for serialization purposes. - */ - private SignedFirmwareStatusNotificationRequest() { - } + /** Private default constructor for serialization purposes. */ + private SignedFirmwareStatusNotificationRequest() {} /** * Handle required fields. @@ -72,10 +68,10 @@ public void setStatus(FirmwareStatusEnumType status) { } /** - * The request id that was provided in the {@link SignedUpdateFirmwareRequest} - * that started this firmware update. This field is mandatory, unless the message - * was triggered by a {@link TriggerMessageRequest} or the {@link ExtendedTriggerMessageRequest} AND - * there is no firmware update ongoing. + * The request id that was provided in the {@link SignedUpdateFirmwareRequest} that started this + * firmware update. This field is mandatory, unless the message was triggered by a {@link + * TriggerMessageRequest} or the {@link ExtendedTriggerMessageRequest} AND there is no firmware + * update ongoing. * * @return Integer */ @@ -84,10 +80,10 @@ public Integer getRequestId() { } /** - * Optional. The request id that was provided in the {@link SignedUpdateFirmwareRequest} - * that started this firmware update. This field is mandatory, unless the message - * was triggered by a {@link TriggerMessageRequest} or the {@link ExtendedTriggerMessageRequest} AND - * there is no firmware update ongoing. + * Optional. The request id that was provided in the {@link SignedUpdateFirmwareRequest} that + * started this firmware update. This field is mandatory, unless the message was triggered by a + * {@link TriggerMessageRequest} or the {@link ExtendedTriggerMessageRequest} AND there is no + * firmware update ongoing. * * @param requestId Integer */ @@ -110,8 +106,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SignedFirmwareStatusNotificationRequest that = (SignedFirmwareStatusNotificationRequest) o; - return Objects.equals(status, that.status) - && Objects.equals(requestId, that.requestId); + return Objects.equals(status, that.status) && Objects.equals(requestId, that.requestId); } @Override @@ -122,8 +117,9 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("status", status) - .add("requestId", requestId) - .add("isValid", validate()).toString(); + .add("status", status) + .add("requestId", requestId) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedUpdateFirmwareConfirmation.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedUpdateFirmwareConfirmation.java index 3a41aa351..cb0966734 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedUpdateFirmwareConfirmation.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedUpdateFirmwareConfirmation.java @@ -30,18 +30,14 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.securityext.types.UpdateFirmwareStatusEnumType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class SignedUpdateFirmwareConfirmation extends Confirmation { private UpdateFirmwareStatusEnumType status; - /** - * Private default constructor for serialization purposes. - */ - private SignedUpdateFirmwareConfirmation() { - } + /** Private default constructor for serialization purposes. */ + private SignedUpdateFirmwareConfirmation() {} /** * Handle required fields. @@ -91,7 +87,8 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("retries", status) - .add("isValid", validate()).toString(); + .add("retries", status) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedUpdateFirmwareRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedUpdateFirmwareRequest.java index 8b42b98dc..0f437ed8e 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedUpdateFirmwareRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/SignedUpdateFirmwareRequest.java @@ -29,7 +29,6 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.RequestWithId; import eu.chargetime.ocpp.model.securityext.types.FirmwareType; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class SignedUpdateFirmwareRequest extends RequestWithId { @@ -39,17 +38,14 @@ public class SignedUpdateFirmwareRequest extends RequestWithId { private Integer requestId; private FirmwareType firmware; - /** - * Private default constructor for serialization purposes. - */ - private SignedUpdateFirmwareRequest() { - } + /** Private default constructor for serialization purposes. */ + private SignedUpdateFirmwareRequest() {} /** * Handle required fields. * * @param requestId Integer. See {@link #setRequestId(Integer)} - * @param firmware FirmwareType. See {@link #setFirmware(FirmwareType)} + * @param firmware FirmwareType. See {@link #setFirmware(FirmwareType)} */ public SignedUpdateFirmwareRequest(Integer requestId, FirmwareType firmware) { setRequestId(requestId); @@ -57,9 +53,9 @@ public SignedUpdateFirmwareRequest(Integer requestId, FirmwareType firmware) { } /** - * This specifies how many times Charge Point must try to download the - * firmware before giving up. If this field is not present, it is left to Charge Point to - * decide how many times it wants to retry. + * This specifies how many times Charge Point must try to download the firmware before giving up. + * If this field is not present, it is left to Charge Point to decide how many times it wants to + * retry. * * @return Integer */ @@ -68,9 +64,9 @@ public Integer getRetries() { } /** - * Optional. This specifies how many times Charge Point must try to download the - * firmware before giving up. If this field is not present, it is left to Charge Point to - * decide how many times it wants to retry. + * Optional. This specifies how many times Charge Point must try to download the firmware before + * giving up. If this field is not present, it is left to Charge Point to decide how many times it + * wants to retry. * * @param retries Integer */ @@ -79,9 +75,8 @@ public void setRetries(Integer retries) { } /** - * The interval in seconds after which a retry may be attempted. If this - * field is not present, it is left to Charge Point to decide how long to wait between - * attempts. + * The interval in seconds after which a retry may be attempted. If this field is not present, it + * is left to Charge Point to decide how long to wait between attempts. * * @return Integer */ @@ -90,9 +85,8 @@ public Integer getRetryInterval() { } /** - * Optional. The interval in seconds after which a retry may be attempted. If this - * field is not present, it is left to Charge Point to decide how long to wait between - * attempts. + * Optional. The interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charge Point to decide how long to wait between attempts. * * @param retryInterval Integer */ @@ -152,9 +146,9 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; SignedUpdateFirmwareRequest that = (SignedUpdateFirmwareRequest) o; return Objects.equals(retries, that.retries) - && Objects.equals(retryInterval, that.retryInterval) - && Objects.equals(requestId, that.requestId) - && Objects.equals(firmware, that.firmware); + && Objects.equals(retryInterval, that.retryInterval) + && Objects.equals(requestId, that.requestId) + && Objects.equals(firmware, that.firmware); } @Override @@ -165,10 +159,11 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("retries", retries) - .add("retryInterval", retryInterval) - .add("requestId", requestId) - .add("firmware", firmware) - .add("isValid", validate()).toString(); + .add("retries", retries) + .add("retryInterval", retryInterval) + .add("requestId", requestId) + .add("firmware", firmware) + .add("isValid", validate()) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateHashDataType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateHashDataType.java index 4df302bca..bb7a6c532 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateHashDataType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateHashDataType.java @@ -32,22 +32,18 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.validation.Validator; import eu.chargetime.ocpp.model.validation.ValidatorBuilder; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.util.Objects; public class CertificateHashDataType implements Validatable { private static final transient Validator identifierString128Validator = - new ValidatorBuilder() - .addRule(OCPPSecurityExtDatatypes.identifierString()) - .addRule(new StringMaxLengthValidationRule(128)) - .setRequired(true) - .build(); + new ValidatorBuilder() + .addRule(OCPPSecurityExtDatatypes.identifierString()) + .addRule(new StringMaxLengthValidationRule(128)) + .setRequired(true) + .build(); private static final transient Validator serialNumberValidator = - new ValidatorBuilder() - .addRule(OCPPSecurityExtDatatypes.string40()) - .setRequired(true) - .build(); + new ValidatorBuilder().addRule(OCPPSecurityExtDatatypes.string40()).setRequired(true).build(); private HashAlgorithmEnumType hashAlgorithm; private String issuerNameHash; @@ -132,9 +128,9 @@ public void setSerialNumber(String serialNumber) { @Override public boolean validate() { return hashAlgorithm != null - && identifierString128Validator.safeValidate(issuerNameHash) - && identifierString128Validator.safeValidate(issuerKeyHash) - && serialNumberValidator.safeValidate(serialNumber); + && identifierString128Validator.safeValidate(issuerNameHash) + && identifierString128Validator.safeValidate(issuerKeyHash) + && serialNumberValidator.safeValidate(serialNumber); } @Override @@ -143,9 +139,9 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; CertificateHashDataType that = (CertificateHashDataType) o; return Objects.equals(hashAlgorithm, that.hashAlgorithm) - && Objects.equals(issuerNameHash, that.issuerNameHash) - && Objects.equals(issuerKeyHash, that.issuerKeyHash) - && Objects.equals(serialNumber, that.serialNumber); + && Objects.equals(issuerNameHash, that.issuerNameHash) + && Objects.equals(issuerKeyHash, that.issuerKeyHash) + && Objects.equals(serialNumber, that.serialNumber); } @Override @@ -156,10 +152,10 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("hashAlgorithm", hashAlgorithm) - .add("issuerNameHash", issuerNameHash) - .add("issuerKeyHash", issuerKeyHash) - .add("serialNumber", serialNumber) - .toString(); + .add("hashAlgorithm", hashAlgorithm) + .add("issuerNameHash", issuerNameHash) + .add("issuerKeyHash", issuerKeyHash) + .add("serialNumber", serialNumber) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateSignedStatusEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateSignedStatusEnumType.java index 517225263..d71a34b19 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateSignedStatusEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateSignedStatusEnumType.java @@ -28,17 +28,11 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.CertificateSignedConfirmation; -/** - * CertificateSignedStatusEnumType is used by {@link CertificateSignedConfirmation} - */ +/** CertificateSignedStatusEnumType is used by {@link CertificateSignedConfirmation} */ public enum CertificateSignedStatusEnumType { - /** - * Signed certificate is valid. - */ + /** Signed certificate is valid. */ Accepted, - /** - * Signed certificate is invalid. - */ + /** Signed certificate is invalid. */ Rejected } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateStatusEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateStatusEnumType.java index c7d5dcccc..93b982086 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateStatusEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateStatusEnumType.java @@ -28,22 +28,20 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.InstallCertificateConfirmation; -/** - * CertificateStatusEnumType is used by {@link InstallCertificateConfirmation} - */ +/** CertificateStatusEnumType is used by {@link InstallCertificateConfirmation} */ public enum CertificateStatusEnumType { - /** - * The installation of the certificate succeeded. - */ + /** The installation of the certificate succeeded. */ Accepted, /** - * The certificate is valid and correct, but there is another reason the installation did not succeed. + * The certificate is valid and correct, but there is another reason the installation did not + * succeed. */ Failed, /** - * The certificate is invalid and/or incorrect OR the CPO tries to install more certificates than allowed. + * The certificate is invalid and/or incorrect OR the CPO tries to install more certificates than + * allowed. */ Rejected } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateUseEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateUseEnumType.java index 284991e8e..3262ba0fc 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateUseEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/CertificateUseEnumType.java @@ -30,16 +30,13 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.InstallCertificateRequest; /** - * CertificateUseEnumType is used by {@link GetInstalledCertificateIdsRequest}, {@link InstallCertificateRequest} + * CertificateUseEnumType is used by {@link GetInstalledCertificateIdsRequest}, {@link + * InstallCertificateRequest} */ public enum CertificateUseEnumType { - /** - * Root certificate, used by the CA to sign the Central System and Charge Point certificate. - */ + /** Root certificate, used by the CA to sign the Central System and Charge Point certificate. */ CentralSystemRootCertificate, - /** - * Root certificate for verification of the Manufacturer certificate. - */ + /** Root certificate for verification of the Manufacturer certificate. */ ManufacturerRootCertificate } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/DeleteCertificateStatusEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/DeleteCertificateStatusEnumType.java index 752ed2a7a..5983c793d 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/DeleteCertificateStatusEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/DeleteCertificateStatusEnumType.java @@ -28,22 +28,14 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.DeleteCertificateConfirmation; -/** - * DeleteCertificateStatusEnumType is used by {@link DeleteCertificateConfirmation} - */ +/** DeleteCertificateStatusEnumType is used by {@link DeleteCertificateConfirmation} */ public enum DeleteCertificateStatusEnumType { - /** - * Normal successful completion (no errors). - */ + /** Normal successful completion (no errors). */ Accepted, - /** - * Processing failure. - */ + /** Processing failure. */ Failed, - /** - * Requested resource not found. - */ + /** Requested resource not found. */ NotFound } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/FirmwareStatusEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/FirmwareStatusEnumType.java index 6b0abd96f..f573831c7 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/FirmwareStatusEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/FirmwareStatusEnumType.java @@ -31,84 +31,66 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.SignedUpdateFirmwareRequest; /** - * Status of a firmware download. - * A value with "Intermediate state" in the description, is an intermediate state, update process is not finished. - * A value with "Failure end state" in the description, is an end state, update process has stopped, update failed. - * A value with "Successful end state" in the description, is an end state, update process has stopped, update successful. + * Status of a firmware download. A value with "Intermediate state" in the description, is an + * intermediate state, update process is not finished. A value with "Failure end state" in the + * description, is an end state, update process has stopped, update failed. A value with "Successful + * end state" in the description, is an end state, update process has stopped, update successful. * FirmwareStatusEnumType is used by {@link SignedFirmwareStatusNotificationRequest} */ public enum FirmwareStatusEnumType { - /** - * Intermediate state. New firmware has been downloaded by Charge Point. - */ + /** Intermediate state. New firmware has been downloaded by Charge Point. */ Downloaded, - /** - * Failure end state. Charge Point failed to download firmware. - */ + /** Failure end state. Charge Point failed to download firmware. */ DownloadFailed, - /** - * Intermediate state. Firmware is being downloaded. - */ + /** Intermediate state. Firmware is being downloaded. */ Downloading, - /** - * Intermediate state. Downloading of new firmware has been scheduled. - */ + /** Intermediate state. Downloading of new firmware has been scheduled. */ DownloadScheduled, - /** - * Intermediate state. Downloading has been paused. - */ + /** Intermediate state. Downloading has been paused. */ DownloadPaused, /** - * Charge Point is not performing firmware update related tasks. Status Idle SHALL only be used as in a - * {@link SignedFirmwareStatusNotificationRequest} that was triggered by {@link ExtendedTriggerMessageRequest}. + * Charge Point is not performing firmware update related tasks. Status Idle SHALL only be used as + * in a {@link SignedFirmwareStatusNotificationRequest} that was triggered by {@link + * ExtendedTriggerMessageRequest}. */ Idle, - /** - * Failure end state. Installation of new firmware has failed. - */ + /** Failure end state. Installation of new firmware has failed. */ InstallationFailed, - /** - * Intermediate state. Firmware is being installed. - */ + /** Intermediate state. Firmware is being installed. */ Installing, - /** - * Successful end state. New firmware has successfully been installed in Charge Point. - */ + /** Successful end state. New firmware has successfully been installed in Charge Point. */ Installed, /** - * Intermediate state. Charge Point is about to reboot to activate new firmware. This status MAY be omitted if a - * reboot is an integral part of the installation and cannot be reported separately + * Intermediate state. Charge Point is about to reboot to activate new firmware. This status MAY + * be omitted if a reboot is an integral part of the installation and cannot be reported + * separately */ InstallRebooting, /** - * Intermediate state. Installation of the downloaded firmware is scheduled to take place on installDateTime given - * in {@link SignedUpdateFirmwareRequest}. + * Intermediate state. Installation of the downloaded firmware is scheduled to take place on + * installDateTime given in {@link SignedUpdateFirmwareRequest}. */ InstallScheduled, /** - * Failure end state. Verification of the new firmware (e.g. using a checksum or some other means) has failed and - * installation will not proceed. (Final failure state) + * Failure end state. Verification of the new firmware (e.g. using a checksum or some other means) + * has failed and installation will not proceed. (Final failure state) */ InstallVerificationFailed, - /** - * Failure end state. The firmware signature is not valid. - */ + /** Failure end state. The firmware signature is not valid. */ InvalidSignature, - /** - * Intermediate state. Provide signature successfully verified. - */ + /** Intermediate state. Provide signature successfully verified. */ SignatureVerified } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/FirmwareType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/FirmwareType.java index 129e1d2e1..5c9f81036 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/FirmwareType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/FirmwareType.java @@ -33,32 +33,31 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.validation.Validator; import eu.chargetime.ocpp.model.validation.ValidatorBuilder; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.time.ZonedDateTime; import java.util.Objects; /** - * Represents a copy of the firmware that can be loaded/updated on the Charge Point. - * FirmwareType is used by {@link SignedUpdateFirmwareRequest} + * Represents a copy of the firmware that can be loaded/updated on the Charge Point. FirmwareType is + * used by {@link SignedUpdateFirmwareRequest} */ public class FirmwareType implements Validatable { private static final transient Validator locationValidator = - new ValidatorBuilder() - .addRule(OCPPSecurityExtDatatypes.string512()) - .setRequired(true) - .build(); + new ValidatorBuilder() + .addRule(OCPPSecurityExtDatatypes.string512()) + .setRequired(true) + .build(); private static final transient Validator signingCertificateValidator = - new ValidatorBuilder() - .addRule(new StringMaxLengthValidationRule(5500)) - .setRequired(true) - .build(); + new ValidatorBuilder() + .addRule(new StringMaxLengthValidationRule(5500)) + .setRequired(true) + .build(); private static final transient Validator signatureValidator = - new ValidatorBuilder() - .addRule(new StringMaxLengthValidationRule(800)) - .setRequired(true) - .build(); + new ValidatorBuilder() + .addRule(new StringMaxLengthValidationRule(800)) + .setRequired(true) + .build(); private String location; private ZonedDateTime retrieveDateTime; @@ -162,9 +161,9 @@ public void setSignature(String signature) { @Override public boolean validate() { return locationValidator.safeValidate(location) - && retrieveDateTime != null - && signingCertificateValidator.safeValidate(signingCertificate) - && signatureValidator.safeValidate(signature); + && retrieveDateTime != null + && signingCertificateValidator.safeValidate(signingCertificate) + && signatureValidator.safeValidate(signature); } @Override @@ -173,10 +172,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; FirmwareType that = (FirmwareType) o; return Objects.equals(location, that.location) - && Objects.equals(retrieveDateTime, that.retrieveDateTime) - && Objects.equals(installDateTime, that.installDateTime) - && Objects.equals(signingCertificate, that.signingCertificate) - && Objects.equals(signature, that.signature); + && Objects.equals(retrieveDateTime, that.retrieveDateTime) + && Objects.equals(installDateTime, that.installDateTime) + && Objects.equals(signingCertificate, that.signingCertificate) + && Objects.equals(signature, that.signature); } @Override @@ -187,11 +186,11 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("location", location) - .add("retrieveDateTime", retrieveDateTime) - .add("installDateTime", installDateTime) - .add("signingCertificate", signingCertificate) - .add("signature", signature) - .toString(); + .add("location", location) + .add("retrieveDateTime", retrieveDateTime) + .add("installDateTime", installDateTime) + .add("signingCertificate", signingCertificate) + .add("signature", signature) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/GenericStatusEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/GenericStatusEnumType.java index 449ddec52..1ab8dea0f 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/GenericStatusEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/GenericStatusEnumType.java @@ -26,17 +26,11 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ -/** - * Generic message response status. - */ +/** Generic message response status. */ public enum GenericStatusEnumType { - /** - * Request has been accepted and will be executed. - */ + /** Request has been accepted and will be executed. */ Accepted, - /** - * Request has not been accepted and will not be executed. - */ + /** Request has not been accepted and will not be executed. */ Rejected } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/GetInstalledCertificateStatusEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/GetInstalledCertificateStatusEnumType.java index d8e9b4560..1df1f0c0a 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/GetInstalledCertificateStatusEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/GetInstalledCertificateStatusEnumType.java @@ -32,13 +32,9 @@ of this software and associated documentation files (the "Software"), to deal * GetInstalledCertificateStatusEnumType is used by {@link GetInstalledCertificateIdsConfirmation} */ public enum GetInstalledCertificateStatusEnumType { - /** - * Normal successful completion (no errors). - */ + /** Normal successful completion (no errors). */ Accepted, - /** - * Requested certificate not found. - */ + /** Requested certificate not found. */ NotFound } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/HashAlgorithmEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/HashAlgorithmEnumType.java index 0af47e850..df2a9a671 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/HashAlgorithmEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/HashAlgorithmEnumType.java @@ -26,22 +26,14 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ -/** - * HashAlgorithmEnumType is used by {@link CertificateHashDataType} - */ +/** HashAlgorithmEnumType is used by {@link CertificateHashDataType} */ public enum HashAlgorithmEnumType { - /** - * SHA-256 hash algorithm. - */ + /** SHA-256 hash algorithm. */ SHA256, - /** - * SHA-384 hash algorithm. - */ + /** SHA-384 hash algorithm. */ SHA384, - /** - * SHA-512 hash algorithm. - */ + /** SHA-512 hash algorithm. */ SHA512 } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/LogEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/LogEnumType.java index 790fd993d..00f345d5e 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/LogEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/LogEnumType.java @@ -28,17 +28,14 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.GetLogRequest; -/** - * LogEnumType is used by {@link GetLogRequest} - */ +/** LogEnumType is used by {@link GetLogRequest} */ public enum LogEnumType { - /** - * This contains the field definition of a diagnostics log file. - */ + /** This contains the field definition of a diagnostics log file. */ DiagnosticsLog, /** - * Sent by the Central System to the Charge Point to request that the Charge Point uploads the security log. + * Sent by the Central System to the Charge Point to request that the Charge Point uploads the + * security log. */ SecurityLog } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/LogParametersType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/LogParametersType.java index 179e3fdd3..3c51ccc57 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/LogParametersType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/LogParametersType.java @@ -31,16 +31,15 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.validation.Validator; import eu.chargetime.ocpp.model.validation.ValidatorBuilder; import eu.chargetime.ocpp.utilities.MoreObjects; - import java.time.ZonedDateTime; import java.util.Objects; public class LogParametersType implements Validatable { private static final transient Validator remoteLocationValidator = - new ValidatorBuilder() - .addRule(OCPPSecurityExtDatatypes.string512()) - .setRequired(true) - .build(); + new ValidatorBuilder() + .addRule(OCPPSecurityExtDatatypes.string512()) + .setRequired(true) + .build(); private String remoteLocation; private ZonedDateTime oldestTimestamp; @@ -66,8 +65,8 @@ public void setRemoteLocation(String remoteLocation) { } /** - * This contains the date and time of the oldest logging information to - * include in the diagnostics. + * This contains the date and time of the oldest logging information to include in the + * diagnostics. * * @return dateTime */ @@ -76,8 +75,8 @@ public ZonedDateTime getOldestTimestamp() { } /** - * Optional. This contains the date and time of the oldest logging information to - * include in the diagnostics. + * Optional. This contains the date and time of the oldest logging information to include in the + * diagnostics. * * @param oldestTimestamp dateTime */ @@ -86,8 +85,8 @@ public void setOldestTimestamp(ZonedDateTime oldestTimestamp) { } /** - * This contains the date and time of the latest logging information to - * include in the diagnostics. + * This contains the date and time of the latest logging information to include in the + * diagnostics. * * @return dateTime */ @@ -96,8 +95,8 @@ public ZonedDateTime getLatestTimestamp() { } /** - * Optional. This contains the date and time of the latest logging information to - * include in the diagnostics. + * Optional. This contains the date and time of the latest logging information to include in the + * diagnostics. * * @param latestTimestamp dateTime */ @@ -116,8 +115,8 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; LogParametersType that = (LogParametersType) o; return Objects.equals(remoteLocation, that.remoteLocation) - && Objects.equals(oldestTimestamp, that.oldestTimestamp) - && Objects.equals(latestTimestamp, that.latestTimestamp); + && Objects.equals(oldestTimestamp, that.oldestTimestamp) + && Objects.equals(latestTimestamp, that.latestTimestamp); } @Override @@ -128,9 +127,9 @@ public int hashCode() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("remoteLocation", remoteLocation) - .add("oldestTimestamp", oldestTimestamp) - .add("latestTimestamp", latestTimestamp) - .toString(); + .add("remoteLocation", remoteLocation) + .add("oldestTimestamp", oldestTimestamp) + .add("latestTimestamp", latestTimestamp) + .toString(); } } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/LogStatusEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/LogStatusEnumType.java index 2103b551c..80106ce05 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/LogStatusEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/LogStatusEnumType.java @@ -28,23 +28,17 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.GetLogConfirmation; -/** - * LogStatusEnumType is used by {@link GetLogConfirmation} - */ +/** LogStatusEnumType is used by {@link GetLogConfirmation} */ public enum LogStatusEnumType { /** - * Accepted this log upload. This does not mean the log file is uploaded is successfully, - * the Charge Point will now start the log file upload. + * Accepted this log upload. This does not mean the log file is uploaded is successfully, the + * Charge Point will now start the log file upload. */ Accepted, - /** - * Log update request rejected. - */ + /** Log update request rejected. */ Rejected, - /** - * Accepted this log upload, but in doing this has canceled an ongoing log file upload. - */ + /** Accepted this log upload, but in doing this has canceled an ongoing log file upload. */ AcceptedCanceled } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/MessageTriggerEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/MessageTriggerEnumType.java index da9ac8c03..bde704161 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/MessageTriggerEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/MessageTriggerEnumType.java @@ -35,42 +35,26 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.SignCertificateRequest; import eu.chargetime.ocpp.model.securityext.SignedFirmwareStatusNotificationRequest; -/** - * MessageTriggerEnumType is used by {@link ExtendedTriggerMessageRequest} - */ +/** MessageTriggerEnumType is used by {@link ExtendedTriggerMessageRequest} */ public enum MessageTriggerEnumType { - /** - * To trigger {@link BootNotificationRequest} - */ + /** To trigger {@link BootNotificationRequest} */ BootNotification, - /** - * To trigger {@link LogStatusNotificationRequest}. - */ + /** To trigger {@link LogStatusNotificationRequest}. */ LogStatusNotification, - /** - * To trigger {@link SignedFirmwareStatusNotificationRequest}. - */ + /** To trigger {@link SignedFirmwareStatusNotificationRequest}. */ FirmwareStatusNotification, - /** - * To trigger {@link HeartbeatRequest}. - */ + /** To trigger {@link HeartbeatRequest}. */ Heartbeat, - /** - * To trigger {@link MeterValuesRequest}. - */ + /** To trigger {@link MeterValuesRequest}. */ MeterValues, - /** - * To trigger {@link SignCertificateRequest} with certificateType: ChargePointCertificate. - */ + /** To trigger {@link SignCertificateRequest} with certificateType: ChargePointCertificate. */ SignChargePointCertificate, - /** - * To trigger {@link StatusNotificationRequest}. - */ + /** To trigger {@link StatusNotificationRequest}. */ StatusNotification } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/TriggerMessageStatusEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/TriggerMessageStatusEnumType.java index ada354539..d29c41959 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/TriggerMessageStatusEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/TriggerMessageStatusEnumType.java @@ -28,22 +28,14 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.ExtendedTriggerMessageConfirmation; -/** - * TriggerMessageStatusEnumType is used by {@link ExtendedTriggerMessageConfirmation} - */ +/** TriggerMessageStatusEnumType is used by {@link ExtendedTriggerMessageConfirmation} */ public enum TriggerMessageStatusEnumType { - /** - * Requested message will be sent. - */ + /** Requested message will be sent. */ Accepted, - /** - * Requested message will not be sent. - */ + /** Requested message will not be sent. */ Rejected, - /** - * Requested message cannot be sent because it is either not implemented or unknown. - */ + /** Requested message cannot be sent because it is either not implemented or unknown. */ NotImplemented } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/UpdateFirmwareStatusEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/UpdateFirmwareStatusEnumType.java index bf99f1bf0..3364cbdc6 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/UpdateFirmwareStatusEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/UpdateFirmwareStatusEnumType.java @@ -28,33 +28,26 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.SignedUpdateFirmwareConfirmation; -/** - * UpdateFirmwareStatusEnumType is used by {@link SignedUpdateFirmwareConfirmation} - */ +/** UpdateFirmwareStatusEnumType is used by {@link SignedUpdateFirmwareConfirmation} */ public enum UpdateFirmwareStatusEnumType { /** - * Accepted this firmware update request. This does not mean the firmware update is successful, the Charge Point will - * now start the firmware update process. + * Accepted this firmware update request. This does not mean the firmware update is successful, + * the Charge Point will now start the firmware update process. */ Accepted, - /** - * Firmware update request rejected. - */ + /** Firmware update request rejected. */ Rejected, /** - * Accepted this firmware update request, but in doing this has canceled an ongoing firmware update. + * Accepted this firmware update request, but in doing this has canceled an ongoing firmware + * update. */ AcceptedCanceled, - /** - * The certificate is invalid. - */ + /** The certificate is invalid. */ InvalidCertificate, - /** - * Failure end state. The Firmware Signing certificate has been revoked. - */ + /** Failure end state. The Firmware Signing certificate has been revoked. */ RevokedCertificate } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/UploadLogStatusEnumType.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/UploadLogStatusEnumType.java index d28270ad6..d88dc161c 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/UploadLogStatusEnumType.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/securityext/types/UploadLogStatusEnumType.java @@ -29,43 +29,29 @@ of this software and associated documentation files (the "Software"), to deal import eu.chargetime.ocpp.model.securityext.ExtendedTriggerMessageRequest; import eu.chargetime.ocpp.model.securityext.LogStatusNotificationRequest; -/** - * UploadLogStatusEnumType is used by {@link LogStatusNotificationRequest} - */ +/** UploadLogStatusEnumType is used by {@link LogStatusNotificationRequest} */ public enum UploadLogStatusEnumType { - /** - * A badly formatted packet or other protocol incompatibility was detected. - */ + /** A badly formatted packet or other protocol incompatibility was detected. */ BadMessage, /** - * The Charge Point is not uploading a log file. - * Idle SHALL only be used when the message was triggered by a {@link ExtendedTriggerMessageRequest}. + * The Charge Point is not uploading a log file. Idle SHALL only be used when the message was + * triggered by a {@link ExtendedTriggerMessageRequest}. */ Idle, - /** - * The server does not support the operation. - */ + /** The server does not support the operation. */ NotSupportedOperation, - /** - * Insufficient permissions to perform the operation. - */ + /** Insufficient permissions to perform the operation. */ PermissionDenied, - /** - * File has been uploaded successfully. - */ + /** File has been uploaded successfully. */ Uploaded, - /** - * Failed to upload the requested file. - */ + /** Failed to upload the requested file. */ UploadFailure, - /** - * File is being uploaded. - */ + /** File is being uploaded. */ Uploading } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/validation/IdentifierStringValidationRule.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/validation/IdentifierStringValidationRule.java index fcfbf6853..747e5d294 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/validation/IdentifierStringValidationRule.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/validation/IdentifierStringValidationRule.java @@ -26,7 +26,6 @@ of this software and associated documentation files (the "Software"), to deal */ import eu.chargetime.ocpp.PropertyConstraintException; - import java.util.regex.Pattern; public class IdentifierStringValidationRule implements IValidationRule { 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 3378c66f8..d0fd49d1f 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 @@ -1,5 +1,11 @@ package eu.chargetime.ocpp.feature.profile.test.securityext; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import eu.chargetime.ocpp.feature.Feature; import eu.chargetime.ocpp.feature.profile.securityext.ClientSecurityExtEventHandler; import eu.chargetime.ocpp.feature.profile.securityext.ClientSecurityExtProfile; @@ -36,19 +42,13 @@ import eu.chargetime.ocpp.model.securityext.SignedUpdateFirmwareRequest; import eu.chargetime.ocpp.model.securityext.types.FirmwareStatusEnumType; import eu.chargetime.ocpp.model.securityext.types.UploadLogStatusEnumType; +import java.time.ZonedDateTime; +import java.util.UUID; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import java.time.ZonedDateTime; -import java.util.UUID; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; /* ChargeTime.eu - Java-OCA-OCPP @@ -82,8 +82,7 @@ public class ClientSecurityExtProfileTest extends ProfileTest { private ClientSecurityExtProfile profile; - @Mock - private ClientSecurityExtEventHandler handler; + @Mock private ClientSecurityExtEventHandler handler; @Before public void setup() { @@ -98,15 +97,24 @@ public void getFeatureList_containsAllFeature() { // then assertTrue(findFeature(features, "CertificateSigned") instanceof CertificateSignedFeature); assertTrue(findFeature(features, "DeleteCertificate") instanceof DeleteCertificateFeature); - assertTrue(findFeature(features, "ExtendedTriggerMessage") instanceof ExtendedTriggerMessageFeature); - assertTrue(findFeature(features, "GetInstalledCertificateIds") instanceof GetInstalledCertificateIdsFeature); + assertTrue( + findFeature(features, "ExtendedTriggerMessage") instanceof ExtendedTriggerMessageFeature); + assertTrue( + findFeature(features, "GetInstalledCertificateIds") + instanceof GetInstalledCertificateIdsFeature); assertTrue(findFeature(features, "GetLog") instanceof GetLogFeature); assertTrue(findFeature(features, "InstallCertificate") instanceof InstallCertificateFeature); - assertTrue(findFeature(features, "LogStatusNotification") instanceof LogStatusNotificationFeature); - assertTrue(findFeature(features, "SecurityEventNotification") instanceof SecurityEventNotificationFeature); + assertTrue( + findFeature(features, "LogStatusNotification") instanceof LogStatusNotificationFeature); + assertTrue( + findFeature(features, "SecurityEventNotification") + instanceof SecurityEventNotificationFeature); assertTrue(findFeature(features, "SignCertificate") instanceof SignCertificateFeature); - assertTrue(findFeature(features, "SignedFirmwareStatusNotification") instanceof SignedFirmwareStatusNotificationFeature); - assertTrue(findFeature(features, "SignedUpdateFirmware") instanceof SignedUpdateFirmwareFeature); + assertTrue( + findFeature(features, "SignedFirmwareStatusNotification") + instanceof SignedFirmwareStatusNotificationFeature); + assertTrue( + findFeature(features, "SignedUpdateFirmware") instanceof SignedUpdateFirmwareFeature); } @Test @@ -129,7 +137,8 @@ public void createSecurityEventNotificationRequest_withParams_returnsCompleteReq ZonedDateTime timestamp = ZonedDateTime.now(); // When - SecurityEventNotificationRequest actual = profile.createSecurityEventNotificationRequest(type, timestamp); + SecurityEventNotificationRequest actual = + profile.createSecurityEventNotificationRequest(type, timestamp); // Then assertEquals(type, actual.getType()); @@ -155,7 +164,8 @@ public void createSignedFirmwareStatusNotificationRequest_withParams_returnsComp FirmwareStatusEnumType status = FirmwareStatusEnumType.Downloaded; // When - SignedFirmwareStatusNotificationRequest actual = profile.createSignedFirmwareStatusNotificationRequest(status); + SignedFirmwareStatusNotificationRequest actual = + profile.createSignedFirmwareStatusNotificationRequest(status); // Then assertEquals(status, actual.getStatus()); @@ -191,10 +201,12 @@ public void handleRequest_whenDeleteCertificateRequest_callsHandleDeleteCertific } @Test - public void handleRequest_whenExtendedTriggerMessageRequest_callsHandleExtendedTriggerMessageRequest() { + public void + handleRequest_whenExtendedTriggerMessageRequest_callsHandleExtendedTriggerMessageRequest() { // Given ExtendedTriggerMessageRequest request = mock(ExtendedTriggerMessageRequest.class); - ExtendedTriggerMessageConfirmation confirmation = mock(ExtendedTriggerMessageConfirmation.class); + ExtendedTriggerMessageConfirmation confirmation = + mock(ExtendedTriggerMessageConfirmation.class); when(handler.handleExtendedTriggerMessageRequest(request)).thenReturn(confirmation); // When @@ -205,10 +217,12 @@ public void handleRequest_whenExtendedTriggerMessageRequest_callsHandleExtendedT } @Test - public void handleRequest_whenGetInstalledCertificateIdsRequest_callsHandleGetInstalledCertificateIdsRequest() { + public void + handleRequest_whenGetInstalledCertificateIdsRequest_callsHandleGetInstalledCertificateIdsRequest() { // Given GetInstalledCertificateIdsRequest request = mock(GetInstalledCertificateIdsRequest.class); - GetInstalledCertificateIdsConfirmation confirmation = mock(GetInstalledCertificateIdsConfirmation.class); + GetInstalledCertificateIdsConfirmation confirmation = + mock(GetInstalledCertificateIdsConfirmation.class); when(handler.handleGetInstalledCertificateIdsRequest(request)).thenReturn(confirmation); // When @@ -247,7 +261,8 @@ public void handleRequest_whenInstallCertificateRequest_callsHandleInstallCertif } @Test - public void handleRequest_whenSignedUpdateFirmwareRequest_callsHandleSignedUpdateFirmwareRequest() { + public void + handleRequest_whenSignedUpdateFirmwareRequest_callsHandleSignedUpdateFirmwareRequest() { // Given SignedUpdateFirmwareRequest request = mock(SignedUpdateFirmwareRequest.class); SignedUpdateFirmwareConfirmation confirmation = mock(SignedUpdateFirmwareConfirmation.class); @@ -259,5 +274,4 @@ public void handleRequest_whenSignedUpdateFirmwareRequest_callsHandleSignedUpdat // Then assertEquals(confirmation, actual); } - } 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 7aa325283..7c357b465 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 @@ -1,5 +1,11 @@ package eu.chargetime.ocpp.feature.profile.test.securityext; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import eu.chargetime.ocpp.feature.Feature; import eu.chargetime.ocpp.feature.profile.securityext.ServerSecurityExtEventHandler; import eu.chargetime.ocpp.feature.profile.securityext.ServerSecurityExtProfile; @@ -37,18 +43,12 @@ import eu.chargetime.ocpp.model.securityext.types.LogEnumType; import eu.chargetime.ocpp.model.securityext.types.LogParametersType; import eu.chargetime.ocpp.model.securityext.types.MessageTriggerEnumType; +import java.util.UUID; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import java.util.UUID; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; /* ChargeTime.eu - Java-OCA-OCPP @@ -82,8 +82,7 @@ public class ServerSecurityExtProfileTest extends ProfileTest { private ServerSecurityExtProfile profile; - @Mock - private ServerSecurityExtEventHandler handler; + @Mock private ServerSecurityExtEventHandler handler; @Before public void setup() { @@ -98,15 +97,24 @@ public void getFeatureList_containsAllFeature() { // then assertTrue(findFeature(features, "CertificateSigned") instanceof CertificateSignedFeature); assertTrue(findFeature(features, "DeleteCertificate") instanceof DeleteCertificateFeature); - assertTrue(findFeature(features, "ExtendedTriggerMessage") instanceof ExtendedTriggerMessageFeature); - assertTrue(findFeature(features, "GetInstalledCertificateIds") instanceof GetInstalledCertificateIdsFeature); + assertTrue( + findFeature(features, "ExtendedTriggerMessage") instanceof ExtendedTriggerMessageFeature); + assertTrue( + findFeature(features, "GetInstalledCertificateIds") + instanceof GetInstalledCertificateIdsFeature); assertTrue(findFeature(features, "GetLog") instanceof GetLogFeature); assertTrue(findFeature(features, "InstallCertificate") instanceof InstallCertificateFeature); - assertTrue(findFeature(features, "LogStatusNotification") instanceof LogStatusNotificationFeature); - assertTrue(findFeature(features, "SecurityEventNotification") instanceof SecurityEventNotificationFeature); + assertTrue( + findFeature(features, "LogStatusNotification") instanceof LogStatusNotificationFeature); + assertTrue( + findFeature(features, "SecurityEventNotification") + instanceof SecurityEventNotificationFeature); assertTrue(findFeature(features, "SignCertificate") instanceof SignCertificateFeature); - assertTrue(findFeature(features, "SignedFirmwareStatusNotification") instanceof SignedFirmwareStatusNotificationFeature); - assertTrue(findFeature(features, "SignedUpdateFirmware") instanceof SignedUpdateFirmwareFeature); + assertTrue( + findFeature(features, "SignedFirmwareStatusNotification") + instanceof SignedFirmwareStatusNotificationFeature); + assertTrue( + findFeature(features, "SignedUpdateFirmware") instanceof SignedUpdateFirmwareFeature); } @Test @@ -139,7 +147,8 @@ public void createExtendedTriggerMessageRequest_withParams_returnsCompleteReques MessageTriggerEnumType requestedMessage = MessageTriggerEnumType.BootNotification; // When - ExtendedTriggerMessageRequest actual = profile.createExtendedTriggerMessageRequest(requestedMessage); + ExtendedTriggerMessageRequest actual = + profile.createExtendedTriggerMessageRequest(requestedMessage); // Then assertEquals(requestedMessage, actual.getRequestedMessage()); @@ -152,7 +161,8 @@ public void createGetInstalledCertificateIdsRequest_withParams_returnsCompleteRe CertificateUseEnumType certificateType = CertificateUseEnumType.CentralSystemRootCertificate; // When - GetInstalledCertificateIdsRequest actual = profile.createGetInstalledCertificateIdsRequest(certificateType); + GetInstalledCertificateIdsRequest actual = + profile.createGetInstalledCertificateIdsRequest(certificateType); // Then assertEquals(certificateType, actual.getCertificateType()); @@ -183,7 +193,8 @@ public void createInstallCertificateRequest_withParams_returnsCompleteRequest() String certificate = "certificate"; // When - InstallCertificateRequest actual = profile.createInstallCertificateRequest(certificateType, certificate); + InstallCertificateRequest actual = + profile.createInstallCertificateRequest(certificateType, certificate); // Then assertEquals(certificateType, actual.getCertificateType()); @@ -197,7 +208,8 @@ public void createSignedUpdateFirmwareRequest_withParams_returnsCompleteRequest( FirmwareType firmware = new FirmwareType(); // When - SignedUpdateFirmwareRequest actual = profile.createSignedUpdateFirmwareRequest(requestId, firmware); + SignedUpdateFirmwareRequest actual = + profile.createSignedUpdateFirmwareRequest(requestId, firmware); // Then assertNull(actual.getRetries()); @@ -207,7 +219,8 @@ public void createSignedUpdateFirmwareRequest_withParams_returnsCompleteRequest( } @Test - public void handleRequest_whenLogStatusNotificationRequest_callsHandleLogStatusNotificationRequest() { + public void + handleRequest_whenLogStatusNotificationRequest_callsHandleLogStatusNotificationRequest() { // Given LogStatusNotificationRequest request = mock(LogStatusNotificationRequest.class); LogStatusNotificationConfirmation confirmation = mock(LogStatusNotificationConfirmation.class); @@ -221,11 +234,14 @@ public void handleRequest_whenLogStatusNotificationRequest_callsHandleLogStatusN } @Test - public void handleRequest_whenSecurityEventNotificationRequest_callsHandleSecurityEventNotificationRequest() { + public void + handleRequest_whenSecurityEventNotificationRequest_callsHandleSecurityEventNotificationRequest() { // Given SecurityEventNotificationRequest request = mock(SecurityEventNotificationRequest.class); - SecurityEventNotificationConfirmation confirmation = mock(SecurityEventNotificationConfirmation.class); - when(handler.handleSecurityEventNotificationRequest(SESSION_ID, request)).thenReturn(confirmation); + SecurityEventNotificationConfirmation confirmation = + mock(SecurityEventNotificationConfirmation.class); + when(handler.handleSecurityEventNotificationRequest(SESSION_ID, request)) + .thenReturn(confirmation); // When Confirmation actual = profile.handleRequest(SESSION_ID, request); @@ -249,11 +265,15 @@ public void handleRequest_whenSignCertificateRequest_callsSignCertificateRequest } @Test - public void handleRequest_whenSignedFirmwareStatusNotificationRequest_callsHandleSignedFirmwareStatusNotificationRequest() { + public void + handleRequest_whenSignedFirmwareStatusNotificationRequest_callsHandleSignedFirmwareStatusNotificationRequest() { // Given - SignedFirmwareStatusNotificationRequest request = mock(SignedFirmwareStatusNotificationRequest.class); - SignedFirmwareStatusNotificationConfirmation confirmation = mock(SignedFirmwareStatusNotificationConfirmation.class); - when(handler.handleSignedFirmwareStatusNotificationRequest(SESSION_ID, request)).thenReturn(confirmation); + SignedFirmwareStatusNotificationRequest request = + mock(SignedFirmwareStatusNotificationRequest.class); + SignedFirmwareStatusNotificationConfirmation confirmation = + mock(SignedFirmwareStatusNotificationConfirmation.class); + when(handler.handleSignedFirmwareStatusNotificationRequest(SESSION_ID, request)) + .thenReturn(confirmation); // When Confirmation actual = profile.handleRequest(SESSION_ID, request); @@ -261,5 +281,4 @@ public void handleRequest_whenSignedFirmwareStatusNotificationRequest_callsHandl // Then assertEquals(confirmation, actual); } - } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/core/MeterValuesRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/core/MeterValuesRequestTest.java index cc3d341cb..b8a010554 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/core/MeterValuesRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/core/MeterValuesRequestTest.java @@ -1,32 +1,31 @@ package eu.chargetime.ocpp.model.core; -import junit.framework.TestCase; - import java.time.ZonedDateTime; +import junit.framework.TestCase; public class MeterValuesRequestTest extends TestCase { - public void testEmptyMeterValuesArray_FailsValidation() { - MeterValuesRequest request = new MeterValuesRequest(1); - request.setTransactionId(2); - request.setMeterValue(new MeterValue[]{}); - assertFalse(request.validate()); - } + public void testEmptyMeterValuesArray_FailsValidation() { + MeterValuesRequest request = new MeterValuesRequest(1); + request.setTransactionId(2); + request.setMeterValue(new MeterValue[] {}); + assertFalse(request.validate()); + } - public void testEmptySampledValuesArray_failsValidation() { - MeterValuesRequest request = new MeterValuesRequest(1); - MeterValue measured = new MeterValue(ZonedDateTime.now(), new SampledValue[]{}); - request.setTransactionId(2); - request.setMeterValue(new MeterValue[]{measured}); - assertFalse(request.validate()); - } + public void testEmptySampledValuesArray_failsValidation() { + MeterValuesRequest request = new MeterValuesRequest(1); + MeterValue measured = new MeterValue(ZonedDateTime.now(), new SampledValue[] {}); + request.setTransactionId(2); + request.setMeterValue(new MeterValue[] {measured}); + assertFalse(request.validate()); + } - public void testMeterValuesWithAtLeastOneMeasurementPassesValidation() { - MeterValuesRequest request = new MeterValuesRequest(1); - SampledValue sample = new SampledValue("5"); - MeterValue measured = new MeterValue(ZonedDateTime.now(), new SampledValue[]{sample}); - request.setTransactionId(2); - request.setMeterValue(new MeterValue[]{measured}); - assertTrue(request.validate()); - } -} \ No newline at end of file + public void testMeterValuesWithAtLeastOneMeasurementPassesValidation() { + MeterValuesRequest request = new MeterValuesRequest(1); + SampledValue sample = new SampledValue("5"); + MeterValue measured = new MeterValue(ZonedDateTime.now(), new SampledValue[] {sample}); + request.setTransactionId(2); + request.setMeterValue(new MeterValue[] {measured}); + assertTrue(request.validate()); + } +} diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/firmware/test/GetDiagnosticsRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/firmware/test/GetDiagnosticsRequestTest.java index 0a05cd35f..51c96a3bb 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/firmware/test/GetDiagnosticsRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/firmware/test/GetDiagnosticsRequestTest.java @@ -39,8 +39,7 @@ of this software and associated documentation files (the "Software"), to deal public class GetDiagnosticsRequestTest { - @Rule - public ExpectedException thrownException = ExpectedException.none(); + @Rule public ExpectedException thrownException = ExpectedException.none(); private GetDiagnosticsRequest request; @@ -114,9 +113,10 @@ public void setRetryInterval_asNegative_throwsPropertyConstraintException() { int retryInterval = -42; thrownException.expect(instanceOf(PropertyConstraintException.class)); thrownException.expectMessage( - equalTo("Validation failed: [retryInterval must be >= 0]. Current Value: [" - + retryInterval - + "]")); + equalTo( + "Validation failed: [retryInterval must be >= 0]. Current Value: [" + + retryInterval + + "]")); request.setRetryInterval(retryInterval); } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/firmware/test/UpdateFirmwareRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/firmware/test/UpdateFirmwareRequestTest.java index 75705c506..09e486c31 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/firmware/test/UpdateFirmwareRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/firmware/test/UpdateFirmwareRequestTest.java @@ -119,9 +119,7 @@ public void setRetries_asZero_isAccepted() { public void setRetryInterval_asNegative_throwsPropertyConstraintException() { int retryInterval = -42; defineThrownException( - "Validation failed: [retryInterval must be >= 0]. Current Value: [" - + retryInterval - + "]"); + "Validation failed: [retryInterval must be >= 0]. Current Value: [" + retryInterval + "]"); request.setRetryInterval(retryInterval); } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/CertificateSignedConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/CertificateSignedConfirmationTest.java index 35eb58d44..835bc6392 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/CertificateSignedConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/CertificateSignedConfirmationTest.java @@ -26,14 +26,13 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.model.securityext.CertificateSignedConfirmation; import eu.chargetime.ocpp.model.securityext.types.CertificateSignedStatusEnumType; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class CertificateSignedConfirmationTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/CertificateSignedRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/CertificateSignedRequestTest.java index 7991d9d12..a4ea5473e 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/CertificateSignedRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/CertificateSignedRequestTest.java @@ -26,13 +26,13 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.PropertyConstraintException; import eu.chargetime.ocpp.model.securityext.CertificateSignedRequest; import eu.chargetime.ocpp.utilities.TestUtilities; import org.junit.Test; -import static org.junit.Assert.assertTrue; - public class CertificateSignedRequestTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/DeleteCertificateConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/DeleteCertificateConfirmationTest.java index 7b4670853..af61c2e1c 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/DeleteCertificateConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/DeleteCertificateConfirmationTest.java @@ -26,13 +26,13 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.model.securityext.DeleteCertificateConfirmation; import eu.chargetime.ocpp.model.securityext.types.DeleteCertificateStatusEnumType; import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class DeleteCertificateConfirmationTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/DeleteCertificateRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/DeleteCertificateRequestTest.java index fb2c3ff5d..62fabddfb 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/DeleteCertificateRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/DeleteCertificateRequestTest.java @@ -26,15 +26,15 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ -import eu.chargetime.ocpp.model.securityext.DeleteCertificateRequest; -import eu.chargetime.ocpp.model.securityext.types.CertificateHashDataType; -import org.junit.Test; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import eu.chargetime.ocpp.model.securityext.DeleteCertificateRequest; +import eu.chargetime.ocpp.model.securityext.types.CertificateHashDataType; +import org.junit.Test; + public class DeleteCertificateRequestTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/ExtendedTriggerMessageConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/ExtendedTriggerMessageConfirmationTest.java index 1afe3078b..e2911c34b 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/ExtendedTriggerMessageConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/ExtendedTriggerMessageConfirmationTest.java @@ -26,20 +26,21 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.model.securityext.ExtendedTriggerMessageConfirmation; import eu.chargetime.ocpp.model.securityext.types.TriggerMessageStatusEnumType; import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class ExtendedTriggerMessageConfirmationTest { @Test public void validate_constructor_returnsTrue() { // Given TriggerMessageStatusEnumType status = TriggerMessageStatusEnumType.Accepted; - ExtendedTriggerMessageConfirmation confirmation = new ExtendedTriggerMessageConfirmation(status); + ExtendedTriggerMessageConfirmation confirmation = + new ExtendedTriggerMessageConfirmation(status); // When boolean actual = confirmation.validate(); diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/ExtendedTriggerMessageRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/ExtendedTriggerMessageRequestTest.java index da20f2526..18cebc3c9 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/ExtendedTriggerMessageRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/ExtendedTriggerMessageRequestTest.java @@ -26,14 +26,14 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.PropertyConstraintException; import eu.chargetime.ocpp.model.securityext.ExtendedTriggerMessageRequest; import eu.chargetime.ocpp.model.securityext.types.MessageTriggerEnumType; import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class ExtendedTriggerMessageRequestTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetInstalledCertificateIdsConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetInstalledCertificateIdsConfirmationTest.java index 854e35cfb..c8c8e4652 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetInstalledCertificateIdsConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetInstalledCertificateIdsConfirmationTest.java @@ -26,23 +26,24 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ -import eu.chargetime.ocpp.model.securityext.GetInstalledCertificateIdsConfirmation; -import eu.chargetime.ocpp.model.securityext.types.CertificateHashDataType; -import eu.chargetime.ocpp.model.securityext.types.GetInstalledCertificateStatusEnumType; -import org.junit.Test; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import eu.chargetime.ocpp.model.securityext.GetInstalledCertificateIdsConfirmation; +import eu.chargetime.ocpp.model.securityext.types.CertificateHashDataType; +import eu.chargetime.ocpp.model.securityext.types.GetInstalledCertificateStatusEnumType; +import org.junit.Test; + public class GetInstalledCertificateIdsConfirmationTest { @Test public void validate_constructor_returnsTrue() { // Given GetInstalledCertificateStatusEnumType status = GetInstalledCertificateStatusEnumType.Accepted; - GetInstalledCertificateIdsConfirmation confirmation = new GetInstalledCertificateIdsConfirmation(status); + GetInstalledCertificateIdsConfirmation confirmation = + new GetInstalledCertificateIdsConfirmation(status); // When boolean actual = confirmation.validate(); @@ -55,7 +56,8 @@ public void validate_constructor_returnsTrue() { public void validate_setRequired_returnsTrue() { // Given GetInstalledCertificateStatusEnumType status = GetInstalledCertificateStatusEnumType.Accepted; - GetInstalledCertificateIdsConfirmation confirmation = new GetInstalledCertificateIdsConfirmation(null); + GetInstalledCertificateIdsConfirmation confirmation = + new GetInstalledCertificateIdsConfirmation(null); confirmation.setStatus(status); // When @@ -68,7 +70,8 @@ public void validate_setRequired_returnsTrue() { @Test public void validate_returnFalse() { // Given - GetInstalledCertificateIdsConfirmation request = new GetInstalledCertificateIdsConfirmation(null); + GetInstalledCertificateIdsConfirmation request = + new GetInstalledCertificateIdsConfirmation(null); // When boolean actual = request.validate(); @@ -81,7 +84,8 @@ public void validate_returnFalse() { public void validate_setRequiredAndOptional_returnsTrue() { // Given GetInstalledCertificateStatusEnumType status = GetInstalledCertificateStatusEnumType.Accepted; - GetInstalledCertificateIdsConfirmation confirmation = new GetInstalledCertificateIdsConfirmation(null); + GetInstalledCertificateIdsConfirmation confirmation = + new GetInstalledCertificateIdsConfirmation(null); confirmation.setStatus(status); confirmation.setCertificateHashData(givenCertificateHashData()); @@ -95,6 +99,6 @@ public void validate_setRequiredAndOptional_returnsTrue() { private CertificateHashDataType[] givenCertificateHashData() { CertificateHashDataType certificateHashDataType = mock(CertificateHashDataType.class); when(certificateHashDataType.validate()).thenReturn(true); - return new CertificateHashDataType[]{certificateHashDataType}; + return new CertificateHashDataType[] {certificateHashDataType}; } } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetInstalledCertificateIdsRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetInstalledCertificateIdsRequestTest.java index b3c9ebe1b..6c1636342 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetInstalledCertificateIdsRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetInstalledCertificateIdsRequestTest.java @@ -26,20 +26,21 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.model.securityext.GetInstalledCertificateIdsRequest; import eu.chargetime.ocpp.model.securityext.types.CertificateUseEnumType; import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class GetInstalledCertificateIdsRequestTest { @Test public void validate_constructor_returnsTrue() { // Given CertificateUseEnumType certificateType = CertificateUseEnumType.CentralSystemRootCertificate; - GetInstalledCertificateIdsRequest request = new GetInstalledCertificateIdsRequest(certificateType); + GetInstalledCertificateIdsRequest request = + new GetInstalledCertificateIdsRequest(certificateType); // When boolean actual = request.validate(); diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetLogConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetLogConfirmationTest.java index cb41e1b4c..feda213cc 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetLogConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetLogConfirmationTest.java @@ -26,16 +26,15 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.PropertyConstraintException; import eu.chargetime.ocpp.model.securityext.GetLogConfirmation; -import eu.chargetime.ocpp.model.securityext.types.CertificateHashDataType; import eu.chargetime.ocpp.model.securityext.types.LogStatusEnumType; import eu.chargetime.ocpp.utilities.TestUtilities; import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class GetLogConfirmationTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetLogRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetLogRequestTest.java index 06db5c9d2..c20572772 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetLogRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/GetLogRequestTest.java @@ -26,16 +26,16 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ -import eu.chargetime.ocpp.model.securityext.GetLogRequest; -import eu.chargetime.ocpp.model.securityext.types.LogEnumType; -import eu.chargetime.ocpp.model.securityext.types.LogParametersType; -import org.junit.Test; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import eu.chargetime.ocpp.model.securityext.GetLogRequest; +import eu.chargetime.ocpp.model.securityext.types.LogEnumType; +import eu.chargetime.ocpp.model.securityext.types.LogParametersType; +import org.junit.Test; + public class GetLogRequestTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/InstallCertificateConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/InstallCertificateConfirmationTest.java index eff4fc053..6cadae26e 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/InstallCertificateConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/InstallCertificateConfirmationTest.java @@ -26,13 +26,13 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.model.securityext.InstallCertificateConfirmation; import eu.chargetime.ocpp.model.securityext.types.CertificateStatusEnumType; import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class InstallCertificateConfirmationTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/InstallCertificateRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/InstallCertificateRequestTest.java index 5d009e7aa..6a4679fd7 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/InstallCertificateRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/InstallCertificateRequestTest.java @@ -26,14 +26,14 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.PropertyConstraintException; import eu.chargetime.ocpp.model.securityext.InstallCertificateRequest; import eu.chargetime.ocpp.model.securityext.types.CertificateUseEnumType; import eu.chargetime.ocpp.utilities.TestUtilities; import org.junit.Test; -import static org.junit.Assert.assertTrue; - public class InstallCertificateRequestTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/LogStatusNotificationConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/LogStatusNotificationConfirmationTest.java index 2dfce93d0..3fa1469db 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/LogStatusNotificationConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/LogStatusNotificationConfirmationTest.java @@ -26,11 +26,11 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.model.securityext.LogStatusNotificationConfirmation; import org.junit.Test; -import static org.junit.Assert.assertTrue; - public class LogStatusNotificationConfirmationTest { @Test @@ -44,5 +44,4 @@ public void validate_constructor_returnsTrue() { // Then assertTrue(actual); } - } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/LogStatusNotificationRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/LogStatusNotificationRequestTest.java index 803500d1b..7dd7eb39d 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/LogStatusNotificationRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/LogStatusNotificationRequestTest.java @@ -26,13 +26,13 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.model.securityext.LogStatusNotificationRequest; import eu.chargetime.ocpp.model.securityext.types.UploadLogStatusEnumType; import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class LogStatusNotificationRequestTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SecurityEventNotificationConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SecurityEventNotificationConfirmationTest.java index 4a44c5e05..493eb4252 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SecurityEventNotificationConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SecurityEventNotificationConfirmationTest.java @@ -26,11 +26,11 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.model.securityext.SecurityEventNotificationConfirmation; import org.junit.Test; -import static org.junit.Assert.assertTrue; - public class SecurityEventNotificationConfirmationTest { @Test @@ -44,5 +44,4 @@ public void validate_constructor_returnsTrue() { // Then assertTrue(actual); } - } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SecurityEventNotificationRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SecurityEventNotificationRequestTest.java index bfbf729d4..540acd796 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SecurityEventNotificationRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SecurityEventNotificationRequestTest.java @@ -26,15 +26,14 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.PropertyConstraintException; import eu.chargetime.ocpp.model.securityext.SecurityEventNotificationRequest; import eu.chargetime.ocpp.utilities.TestUtilities; -import org.junit.Test; - import java.time.ZonedDateTime; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.Test; public class SecurityEventNotificationRequestTest { @@ -43,7 +42,8 @@ public void validate_constructor_returnsTrue() { // Given String type = givenType(); ZonedDateTime timestamp = ZonedDateTime.now(); - SecurityEventNotificationRequest request = new SecurityEventNotificationRequest(type, timestamp); + SecurityEventNotificationRequest request = + new SecurityEventNotificationRequest(type, timestamp); // When boolean actual = request.validate(); @@ -106,7 +106,8 @@ public void setTechInfo_maximumLengthString_nothingThrown() { String type = givenType(); ZonedDateTime timestamp = ZonedDateTime.now(); String techInfo = TestUtilities.aString(255); - SecurityEventNotificationRequest request = new SecurityEventNotificationRequest(type, timestamp); + SecurityEventNotificationRequest request = + new SecurityEventNotificationRequest(type, timestamp); // When request.setTechInfo(techInfo); @@ -120,7 +121,8 @@ public void setTechInfo_exceedingLengthString_throwsPropertyConstraintException( String type = givenType(); ZonedDateTime timestamp = ZonedDateTime.now(); String techInfo = TestUtilities.aString(256); - SecurityEventNotificationRequest request = new SecurityEventNotificationRequest(type, timestamp); + SecurityEventNotificationRequest request = + new SecurityEventNotificationRequest(type, timestamp); // When request.setTechInfo(techInfo); diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignCertificateConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignCertificateConfirmationTest.java index b26e13ecf..c86a89a54 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignCertificateConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignCertificateConfirmationTest.java @@ -26,13 +26,13 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.model.securityext.SignCertificateConfirmation; import eu.chargetime.ocpp.model.securityext.types.GenericStatusEnumType; import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class SignCertificateConfirmationTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignCertificateRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignCertificateRequestTest.java index 76138faf8..cb87b2ca4 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignCertificateRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignCertificateRequestTest.java @@ -26,13 +26,13 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.PropertyConstraintException; import eu.chargetime.ocpp.model.securityext.SignCertificateRequest; import eu.chargetime.ocpp.utilities.TestUtilities; import org.junit.Test; -import static org.junit.Assert.assertTrue; - public class SignCertificateRequestTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedFirmwareStatusNotificationConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedFirmwareStatusNotificationConfirmationTest.java index 6edd1ebfa..a43a73192 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedFirmwareStatusNotificationConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedFirmwareStatusNotificationConfirmationTest.java @@ -26,17 +26,18 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.model.securityext.SignedFirmwareStatusNotificationConfirmation; import org.junit.Test; -import static org.junit.Assert.assertTrue; - public class SignedFirmwareStatusNotificationConfirmationTest { @Test public void validate_constructor_returnsTrue() { // Given - SignedFirmwareStatusNotificationConfirmation request = new SignedFirmwareStatusNotificationConfirmation(); + SignedFirmwareStatusNotificationConfirmation request = + new SignedFirmwareStatusNotificationConfirmation(); // When boolean actual = request.validate(); @@ -44,5 +45,4 @@ public void validate_constructor_returnsTrue() { // Then assertTrue(actual); } - } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedFirmwareStatusNotificationRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedFirmwareStatusNotificationRequestTest.java index 271a9591d..21dd6ad40 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedFirmwareStatusNotificationRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedFirmwareStatusNotificationRequestTest.java @@ -26,20 +26,21 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.model.securityext.SignedFirmwareStatusNotificationRequest; import eu.chargetime.ocpp.model.securityext.types.FirmwareStatusEnumType; import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class SignedFirmwareStatusNotificationRequestTest { @Test public void validate_constructor_returnsTrue() { // Given FirmwareStatusEnumType status = FirmwareStatusEnumType.Downloaded; - SignedFirmwareStatusNotificationRequest request = new SignedFirmwareStatusNotificationRequest(status); + SignedFirmwareStatusNotificationRequest request = + new SignedFirmwareStatusNotificationRequest(status); // When boolean actual = request.validate(); @@ -52,7 +53,8 @@ public void validate_constructor_returnsTrue() { public void validate_setRequired_returnsTrue() { // Given FirmwareStatusEnumType status = FirmwareStatusEnumType.Downloaded; - SignedFirmwareStatusNotificationRequest request = new SignedFirmwareStatusNotificationRequest(null); + SignedFirmwareStatusNotificationRequest request = + new SignedFirmwareStatusNotificationRequest(null); request.setStatus(status); // When @@ -66,7 +68,8 @@ public void validate_setRequired_returnsTrue() { public void validate_setRequiredAndOptional_returnsTrue() { // Given FirmwareStatusEnumType status = FirmwareStatusEnumType.Downloaded; - SignedFirmwareStatusNotificationRequest request = new SignedFirmwareStatusNotificationRequest(null); + SignedFirmwareStatusNotificationRequest request = + new SignedFirmwareStatusNotificationRequest(null); request.setStatus(status); request.setRequestId(123); @@ -80,7 +83,8 @@ public void validate_setRequiredAndOptional_returnsTrue() { @Test public void validate_returnFalse() { // Given - SignedFirmwareStatusNotificationRequest request = new SignedFirmwareStatusNotificationRequest(null); + SignedFirmwareStatusNotificationRequest request = + new SignedFirmwareStatusNotificationRequest(null); // When boolean actual = request.validate(); diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedUpdateFirmwareConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedUpdateFirmwareConfirmationTest.java index 9597ef285..cdd2ba71e 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedUpdateFirmwareConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedUpdateFirmwareConfirmationTest.java @@ -26,13 +26,13 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.model.securityext.SignedUpdateFirmwareConfirmation; import eu.chargetime.ocpp.model.securityext.types.UpdateFirmwareStatusEnumType; import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class SignedUpdateFirmwareConfirmationTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedUpdateFirmwareRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedUpdateFirmwareRequestTest.java index a1e755fda..4815bba74 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedUpdateFirmwareRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/SignedUpdateFirmwareRequestTest.java @@ -26,15 +26,15 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ -import eu.chargetime.ocpp.model.securityext.SignedUpdateFirmwareRequest; -import eu.chargetime.ocpp.model.securityext.types.FirmwareType; -import org.junit.Test; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import eu.chargetime.ocpp.model.securityext.SignedUpdateFirmwareRequest; +import eu.chargetime.ocpp.model.securityext.types.FirmwareType; +import org.junit.Test; + public class SignedUpdateFirmwareRequestTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/types/CertificateHashDataTypeTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/types/CertificateHashDataTypeTest.java index 7ef89f0c9..59d6f5980 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/types/CertificateHashDataTypeTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/types/CertificateHashDataTypeTest.java @@ -26,15 +26,15 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.PropertyConstraintException; import eu.chargetime.ocpp.model.securityext.types.CertificateHashDataType; import eu.chargetime.ocpp.model.securityext.types.HashAlgorithmEnumType; import eu.chargetime.ocpp.utilities.TestUtilities; import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class CertificateHashDataTypeTest { @Test diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/types/FirmwareTypeTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/types/FirmwareTypeTest.java index 0e675c5c9..5f960eabb 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/types/FirmwareTypeTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/types/FirmwareTypeTest.java @@ -26,15 +26,14 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.PropertyConstraintException; import eu.chargetime.ocpp.model.securityext.types.FirmwareType; import eu.chargetime.ocpp.utilities.TestUtilities; -import org.junit.Test; - import java.time.ZonedDateTime; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.Test; public class FirmwareTypeTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/types/LogParametersTypeTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/types/LogParametersTypeTest.java index 90c056dfb..4b1433c62 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/types/LogParametersTypeTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/securityext/test/types/LogParametersTypeTest.java @@ -26,15 +26,14 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import eu.chargetime.ocpp.PropertyConstraintException; import eu.chargetime.ocpp.model.securityext.types.LogParametersType; import eu.chargetime.ocpp.utilities.TestUtilities; -import org.junit.Test; - import java.time.ZonedDateTime; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.Test; public class LogParametersTypeTest { 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..e70f40402 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 @@ -80,6 +80,7 @@ public void setIdTag_nullGiven_doesNotRaiseException() { request.setIdTag(null); Assert.assertNull(request.getIdTag()); } + @Test public void setIdTag_nullGiven_passesValidation() { request.setMeterStop(2); 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 da2b4b70f..35d8c0205 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 @@ -374,6 +374,7 @@ private ZonedDateTime createDateTimeInMillis(long dateInMillis) { private ZonedDateTime createDateTimeInNanos(long dateInNanos) { return Instant.ofEpochSecond(dateInNanos / 1000000000, dateInNanos % 1000000000) - .atOffset(ZoneOffset.UTC).toZonedDateTime(); + .atOffset(ZoneOffset.UTC) + .toZonedDateTime(); } } diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolWebSocketListener.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolWebSocketListener.java index 314e993a4..2effaae6b 100644 --- a/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolWebSocketListener.java +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolWebSocketListener.java @@ -186,13 +186,25 @@ public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer( } if (protocolVersion == null || protocolVersion == ProtocolVersion.OCPP1_6) { if (password == null - || password.length < configuration.getParameter(JSONConfiguration.OCPPJ_CP_MIN_PASSWORD_LENGTH, OCPPJ_CP_MIN_PASSWORD_LENGTH) - || password.length > configuration.getParameter(JSONConfiguration.OCPPJ_CP_MAX_PASSWORD_LENGTH, OCPPJ_CP_MAX_PASSWORD_LENGTH)) + || password.length + < configuration.getParameter( + JSONConfiguration.OCPPJ_CP_MIN_PASSWORD_LENGTH, + OCPPJ_CP_MIN_PASSWORD_LENGTH) + || password.length + > configuration.getParameter( + JSONConfiguration.OCPPJ_CP_MAX_PASSWORD_LENGTH, + OCPPJ_CP_MAX_PASSWORD_LENGTH)) throw new InvalidDataException(401, "Invalid password length"); } else { if (password == null - || password.length < configuration.getParameter(JSONConfiguration.OCPP2J_CP_MIN_PASSWORD_LENGTH, OCPP2J_CP_MIN_PASSWORD_LENGTH) - || password.length > configuration.getParameter(JSONConfiguration.OCPP2J_CP_MAX_PASSWORD_LENGTH, OCPP2J_CP_MAX_PASSWORD_LENGTH)) + || password.length + < configuration.getParameter( + JSONConfiguration.OCPP2J_CP_MIN_PASSWORD_LENGTH, + OCPP2J_CP_MIN_PASSWORD_LENGTH) + || password.length + > configuration.getParameter( + JSONConfiguration.OCPP2J_CP_MAX_PASSWORD_LENGTH, + OCPP2J_CP_MAX_PASSWORD_LENGTH)) throw new InvalidDataException(401, "Invalid password length"); } }