### Question:
SetNetworkProfileHandler implements OcppRequestHandler<SetNetworkProfileRequest> { @Override public void handle(String callId, SetNetworkProfileRequest request) { Optional.ofNullable(request.getConnectionData()) .filter(cd -> ConnectionData.OcppVersion.OCPP_20.equals(cd.getOcppVersion()) && ConnectionData.OcppTransport.JSON.equals(cd.getOcppTransport())) .ifPresentOrElse(connectionData -> { stationStore.addNetworkConnectionProfile(request.getConfigurationSlot(), connectionData); stationMessageSender.sendCallResult(callId, new SetNetworkProfileResponse().withStatus(SetNetworkProfileResponse.Status.ACCEPTED)); }, () -> { log.debug("Invalid request received!"); stationMessageSender.sendCallResult(callId, new SetNetworkProfileResponse().withStatus(SetNetworkProfileResponse.Status.REJECTED)); }); }  @Override void handle(String callId, SetNetworkProfileRequest request);  }### Answer:
@Test public void testSetNetworkProfileValidRequest() { handler.handle(CALL_ID, new SetNetworkProfileRequest().withConfigurationSlot(CONFIGURATION_SLOT).withConnectionData(new ConnectionData().withOcppVersion(ConnectionData.OcppVersion.OCPP_20).withOcppTransport(ConnectionData.OcppTransport.JSON))); verify(stationStore).addNetworkConnectionProfile(anyInt(), any(ConnectionData.class)); verify(stationMessageSender).sendCallResult(anyString(), responseCaptor.capture()); SetNetworkProfileResponse response = responseCaptor.getValue(); assertThat(response.getStatus()).isEqualTo(SetNetworkProfileResponse.Status.ACCEPTED); assertThat(response.getAdditionalProperties()).isEmpty(); }
@Test public void testSetNetworkProfileOcppVersionIsMissing() { handler.handle(CALL_ID, new SetNetworkProfileRequest().withConfigurationSlot(CONFIGURATION_SLOT).withConnectionData(new ConnectionData().withOcppTransport(ConnectionData.OcppTransport.JSON))); assertRejected(); }
@Test public void testSetNetworkProfileOcppVersionIsNot20() { handler.handle(CALL_ID, new SetNetworkProfileRequest().withConfigurationSlot(CONFIGURATION_SLOT).withConnectionData(new ConnectionData().withOcppVersion(ConnectionData.OcppVersion.OCPP_16).withOcppTransport(ConnectionData.OcppTransport.JSON))); assertRejected(); }
@Test public void testSetNetworkProfileOcppTransportIsSoap() { handler.handle(CALL_ID, new SetNetworkProfileRequest().withConfigurationSlot(CONFIGURATION_SLOT).withConnectionData(new ConnectionData().withOcppVersion(ConnectionData.OcppVersion.OCPP_16).withOcppTransport(ConnectionData.OcppTransport.SOAP))); assertRejected(); }