Search in sources :

Example 6 with AuthorizeResponse

use of com.amazonaws.mobile.client.internal.oauth2.AuthorizeResponse in project steve by RWTH-i5-IDSG.

the class ApplicationTest method testOcpp12.

@Test
public void testOcpp12() {
    ocpp.cs._2010._08.CentralSystemService client = getForOcpp12(path);
    BootNotificationResponse boot = client.bootNotification(new BootNotificationRequest().withChargePointVendor(getRandomString()).withChargePointModel(getRandomString()), REGISTERED_CHARGE_BOX_ID);
    Assertions.assertNotNull(boot);
    Assertions.assertEquals(RegistrationStatus.ACCEPTED, boot.getStatus());
    AuthorizeResponse auth = client.authorize(new AuthorizeRequest().withIdTag(REGISTERED_OCPP_TAG), REGISTERED_CHARGE_BOX_ID);
    Assertions.assertNotNull(auth);
    Assertions.assertEquals(AuthorizationStatus.ACCEPTED, auth.getIdTagInfo().getStatus());
}
Also used : BootNotificationResponse(ocpp.cs._2010._08.BootNotificationResponse) AuthorizeResponse(ocpp.cs._2010._08.AuthorizeResponse) AuthorizeRequest(ocpp.cs._2010._08.AuthorizeRequest) BootNotificationRequest(ocpp.cs._2010._08.BootNotificationRequest) Test(org.junit.jupiter.api.Test)

Example 7 with AuthorizeResponse

use of com.amazonaws.mobile.client.internal.oauth2.AuthorizeResponse in project steve by RWTH-i5-IDSG.

the class OperationalTestSoapOCPP16 method testUnregisteredIdTag.

@Test
public void testUnregisteredIdTag() {
    CentralSystemService client = getForOcpp16(path);
    AuthorizeResponse auth = client.authorize(new AuthorizeRequest().withIdTag(getRandomString()), REGISTERED_CHARGE_BOX_ID);
    Assertions.assertNotNull(auth);
    Assertions.assertEquals(AuthorizationStatus.INVALID, auth.getIdTagInfo().getStatus());
}
Also used : AuthorizeResponse(ocpp.cs._2015._10.AuthorizeResponse) AuthorizeRequest(ocpp.cs._2015._10.AuthorizeRequest) CentralSystemService(ocpp.cs._2015._10.CentralSystemService) Test(org.junit.jupiter.api.Test)

Example 8 with AuthorizeResponse

use of com.amazonaws.mobile.client.internal.oauth2.AuthorizeResponse in project steve by RWTH-i5-IDSG.

the class CentralSystemService16_Service method authorize.

public AuthorizeResponse authorize(AuthorizeRequest parameters, String chargeBoxIdentity) {
    // Get the authorization info of the user
    String idTag = parameters.getIdTag();
    IdTagInfo idTagInfo = ocppTagService.getIdTagInfo(idTag);
    return new AuthorizeResponse().withIdTagInfo(idTagInfo);
}
Also used : AuthorizeResponse(ocpp.cs._2015._10.AuthorizeResponse) IdTagInfo(ocpp.cs._2015._10.IdTagInfo)

Example 9 with AuthorizeResponse

use of com.amazonaws.mobile.client.internal.oauth2.AuthorizeResponse in project steve by RWTH-i5-IDSG.

the class OperationalTestSoapOCPP16 method testBody.

private void testBody(List<MeterValue> meterValues, List<MeterValue> transactionData) {
    final int usedConnectorID = 1;
    CentralSystemService client = getForOcpp16(path);
    initStationWithBootNotification(client);
    initConnectorsWithStatusNotification(client);
    // heartbeat
    HeartbeatResponse heartbeat = client.heartbeat(new HeartbeatRequest(), REGISTERED_CHARGE_BOX_ID);
    Assertions.assertNotNull(heartbeat);
    // Auth
    AuthorizeResponse auth = client.authorize(new AuthorizeRequest().withIdTag(REGISTERED_OCPP_TAG), REGISTERED_CHARGE_BOX_ID);
    // Simple request, not much done here
    Assertions.assertNotNull(auth);
    Assertions.assertEquals(AuthorizationStatus.ACCEPTED, auth.getIdTagInfo().getStatus());
    // startTransaction
    DateTime startTimeStamp = DateTime.now();
    StartTransactionResponse start = client.startTransaction(new StartTransactionRequest().withConnectorId(usedConnectorID).withIdTag(REGISTERED_OCPP_TAG).withTimestamp(startTimeStamp).withMeterStart(0), REGISTERED_CHARGE_BOX_ID);
    Assertions.assertNotNull(start);
    int transactionID = start.getTransactionId();
    List<TransactionRecord> allTransactions = __DatabasePreparer__.getTransactionRecords();
    Assertions.assertEquals(1, allTransactions.size());
    {
        TransactionRecord t = allTransactions.get(0);
        Assertions.assertEquals(startTimeStamp, t.getStartTimestamp());
        Assertions.assertEquals(0, Integer.parseInt(t.getStartValue()));
        Assertions.assertNull(t.getStopTimestamp());
        Assertions.assertNull(t.getStopReason());
        Assertions.assertNull(t.getStopValue());
    }
    // status
    StatusNotificationResponse statusStart = client.statusNotification(new StatusNotificationRequest().withStatus(ChargePointStatus.CHARGING).withErrorCode(ChargePointErrorCode.NO_ERROR).withConnectorId(0).withTimestamp(DateTime.now()), REGISTERED_CHARGE_BOX_ID);
    Assertions.assertNotNull(statusStart);
    // send meterValues
    if (meterValues != null) {
        MeterValuesResponse meter = client.meterValues(new MeterValuesRequest().withConnectorId(usedConnectorID).withTransactionId(transactionID).withMeterValue(meterValues), REGISTERED_CHARGE_BOX_ID);
        Assertions.assertNotNull(meter);
        checkMeterValues(meterValues, transactionID);
    }
    // stopTransaction
    DateTime stopTimeStamp = DateTime.now();
    int stopValue = 30;
    StopTransactionResponse stop = client.stopTransaction(new StopTransactionRequest().withTransactionId(transactionID).withTransactionData(transactionData).withTimestamp(stopTimeStamp).withIdTag(REGISTERED_OCPP_TAG).withMeterStop(stopValue), REGISTERED_CHARGE_BOX_ID);
    {
        Assertions.assertNotNull(stop);
        List<TransactionRecord> transactionsStop = __DatabasePreparer__.getTransactionRecords();
        Assertions.assertEquals(1, transactionsStop.size());
        TransactionRecord t = transactionsStop.get(0);
        Assertions.assertEquals(stopTimeStamp, t.getStopTimestamp());
        Assertions.assertEquals(stopValue, Integer.parseInt(t.getStopValue()));
        if (transactionData != null) {
            checkMeterValues(transactionData, transactionID);
        }
    }
    // status
    StatusNotificationResponse statusStop = client.statusNotification(new StatusNotificationRequest().withStatus(ChargePointStatus.AVAILABLE).withErrorCode(ChargePointErrorCode.NO_ERROR).withConnectorId(usedConnectorID).withTimestamp(DateTime.now()), REGISTERED_CHARGE_BOX_ID);
    Assertions.assertNotNull(statusStop);
}
Also used : HeartbeatResponse(ocpp.cs._2015._10.HeartbeatResponse) MeterValuesResponse(ocpp.cs._2015._10.MeterValuesResponse) StopTransactionResponse(ocpp.cs._2015._10.StopTransactionResponse) AuthorizeRequest(ocpp.cs._2015._10.AuthorizeRequest) MeterValuesRequest(ocpp.cs._2015._10.MeterValuesRequest) CentralSystemService(ocpp.cs._2015._10.CentralSystemService) StatusNotificationResponse(ocpp.cs._2015._10.StatusNotificationResponse) ChargePoint(de.rwth.idsg.steve.repository.dto.ChargePoint) DateTime(org.joda.time.DateTime) HeartbeatRequest(ocpp.cs._2015._10.HeartbeatRequest) AuthorizeResponse(ocpp.cs._2015._10.AuthorizeResponse) StopTransactionRequest(ocpp.cs._2015._10.StopTransactionRequest) StartTransactionRequest(ocpp.cs._2015._10.StartTransactionRequest) StartTransactionResponse(ocpp.cs._2015._10.StartTransactionResponse) StatusNotificationRequest(ocpp.cs._2015._10.StatusNotificationRequest) List(java.util.List) TransactionRecord(jooq.steve.db.tables.records.TransactionRecord)

Example 10 with AuthorizeResponse

use of com.amazonaws.mobile.client.internal.oauth2.AuthorizeResponse in project steve by RWTH-i5-IDSG.

the class OperationalTestSoapOCPP16 method testRegisteredIdTag.

@Test
public void testRegisteredIdTag() {
    CentralSystemService client = getForOcpp16(path);
    AuthorizeResponse auth = client.authorize(new AuthorizeRequest().withIdTag(REGISTERED_OCPP_TAG), REGISTERED_CHARGE_BOX_ID);
    Assertions.assertNotNull(auth);
    Assertions.assertEquals(AuthorizationStatus.ACCEPTED, auth.getIdTagInfo().getStatus());
}
Also used : AuthorizeResponse(ocpp.cs._2015._10.AuthorizeResponse) AuthorizeRequest(ocpp.cs._2015._10.AuthorizeRequest) CentralSystemService(ocpp.cs._2015._10.CentralSystemService) Test(org.junit.jupiter.api.Test)

Aggregations

AuthorizeResponse (ocpp.cs._2015._10.AuthorizeResponse)11 AuthorizeRequest (ocpp.cs._2015._10.AuthorizeRequest)10 CentralSystemService (ocpp.cs._2015._10.CentralSystemService)8 Test (org.junit.jupiter.api.Test)6 HeartbeatRequest (ocpp.cs._2015._10.HeartbeatRequest)4 HeartbeatResponse (ocpp.cs._2015._10.HeartbeatResponse)4 MeterValuesRequest (ocpp.cs._2015._10.MeterValuesRequest)4 MeterValuesResponse (ocpp.cs._2015._10.MeterValuesResponse)4 StartTransactionRequest (ocpp.cs._2015._10.StartTransactionRequest)4 StartTransactionResponse (ocpp.cs._2015._10.StartTransactionResponse)4 StatusNotificationRequest (ocpp.cs._2015._10.StatusNotificationRequest)4 StatusNotificationResponse (ocpp.cs._2015._10.StatusNotificationResponse)4 StopTransactionRequest (ocpp.cs._2015._10.StopTransactionRequest)4 StopTransactionResponse (ocpp.cs._2015._10.StopTransactionResponse)4 ChargePoint (de.rwth.idsg.steve.repository.dto.ChargePoint)2 Helpers.getRandomString (de.rwth.idsg.steve.utils.Helpers.getRandomString)2 StressTester (de.rwth.idsg.steve.utils.StressTester)2 List (java.util.List)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)2 TransactionRecord (jooq.steve.db.tables.records.TransactionRecord)2