Unit Tests - differing stopTransaction
MODIFY
test/api/OCPPAllVersionsTest.ts
test/api/OCPPAllVersionsTest.ts
@@ -1087,7 +1087,7 @@ describe('OCPP tests (all versions)', function() {
});
- describe('Users should be able to perform a complete transaction cycle with SignedData', () => {
+ describe('Users should be able to perform a complete transaction cycle with SignedData(Continual Updates)', () => {
after(async () => {
await testData.chargingStationContext.cleanUpCreatedData();
@@ -1115,6 +1115,34 @@ describe('OCPP tests (all versions)', function() {
});
+ describe('Users should be able to perform a complete transaction cycle with SignedData(Only in StopTransaction)', () => {
+
+ after(async () => {
+ await testData.chargingStationContext.cleanUpCreatedData();
+ });
+
+ it('Start user should be able to start a new transaction (with SignedData)', async () => {
+ await testData.ocppCommonTests.testStartTransaction();
+ });
+
+ it('Charging station should send meter values (with SignedData)', async () => {
+ await testData.ocppCommonTests.testSendMeterValues(false, true, true);
+ });
+
+ it('Stop user should be able to stop the transaction (with SignedData)', async () => {
+ await testData.ocppCommonTests.testStopTransaction(false, true);
+ });
+
+ it('Transaction must have the right consumption metrics, pricing and inactivity (with SignedData)', async () => {
+ await testData.ocppCommonTests.testTransactionMetrics(false, true);
+ });
+
+ it('Start user should not be able to delete his transaction (with SignedData)', async () => {
+ await testData.ocppCommonTests.testDeleteTransaction(true);
+ });
+
+ });
+
});
describe('Where basic user as start user and admin user as stop user', () => {
@@ -1186,7 +1214,7 @@ describe('OCPP tests (all versions)', function() {
});
- describe('Users should be able to perform a complete transaction cycle with SignedData', () => {
+ describe('Users should be able to perform a complete transaction cycle with SignedData(Continual Updates)', () => {
after(async () => {
await testData.chargingStationContext.cleanUpCreatedData();
@@ -1214,6 +1242,34 @@ describe('OCPP tests (all versions)', function() {
});
+ describe('Users should be able to perform a complete transaction cycle with SignedData(Only in StopTransaction)', () => {
+
+ after(async () => {
+ await testData.chargingStationContext.cleanUpCreatedData();
+ });
+
+ it('Start user should be able to start a new transaction (with SignedData)', async () => {
+ await testData.ocppCommonTests.testStartTransaction();
+ });
+
+ it('Charging station should send meter values (with SignedData)', async () => {
+ await testData.ocppCommonTests.testSendMeterValues(false, true, true);
+ });
+
+ it('Stop user should be able to stop the transaction (with SignedData)', async () => {
+ await testData.ocppCommonTests.testStopTransaction(false, true);
+ });
+
+ it('Transaction must have the right consumption metrics, pricing and inactivity (with SignedData)', async () => {
+ await testData.ocppCommonTests.testTransactionMetrics(false, true);
+ });
+
+ it('Start user should not be able to delete his transaction (with SignedData)', async () => {
+ await testData.ocppCommonTests.testDeleteTransaction(true);
+ });
+
+ });
+
});
});

MODIFY
test/api/OCPPCommonTests.ts
test/api/OCPPCommonTests.ts
@@ -463,7 +463,7 @@ export default class OCPPCommonTests {
}
- public async testSendMeterValues(withSoC = false, withSignedData = false) {
+ public async testSendMeterValues(withSoC = false, withSignedData = false, withOnlyEndSignedData = false) {
// Check on Transaction
expect(this.newTransaction).to.not.be.null;
// Current Time matches Transaction one
@@ -489,7 +489,7 @@ export default class OCPPCommonTests {
amperageL1MeterValue: this.amperageL1MeterValues[0],
amperageL2MeterValue: this.amperageL2MeterValues[0],
amperageL3MeterValue: this.amperageL3MeterValues[0],
- signedDataMeterValue: withSignedData ? this.transactionStartSignedData : null,
+ signedDataStartMeterValue: (withSignedData && !withOnlyEndSignedData) ? this.transactionStartSignedData : null,
}
);
if (meterValueResponse) {
@@ -590,7 +590,8 @@ export default class OCPPCommonTests {
amperageL2MeterValue: this.amperageL2MeterValues[this.amperageL2MeterValues.length - 1],
amperageL3MeterValue: this.amperageL3MeterValues[this.amperageL3MeterValues.length - 1],
socMeterValue: withSoC ? this.socMeterValues[this.socMeterValues.length - 1] : 0,
- signedDataMeterValue: withSignedData ? this.transactionEndSignedData : null
+ signedDataStartMeterValue: withSignedData ? this.transactionStartSignedData : null,
+ signedDataStopMeterValue: withSignedData ? this.transactionEndSignedData : null,
}
);
if (meterValueResponse) {

MODIFY
test/api/context/ChargingStationContext.ts
test/api/context/ChargingStationContext.ts
@@ -26,7 +26,8 @@ interface MeterValueParams {
amperageL2MeterValue?: number;
amperageL3MeterValue?: number;
socMeterValue?: number;
- signedDataMeterValue?: string;
+ signedDataStartMeterValue?: string;
+ signedDataStopMeterValue?: string;
}
export default class ChargingStationContext {
@@ -93,7 +94,8 @@ export default class ChargingStationContext {
return response;
}
- public async stopTransaction(transactionId: number, tagId: string, meterStop: number, stopDate: Date, transactionData?: OCPPMeterValue[] | OCPP15TransactionData): Promise<OCPPStopTransactionResponse> {
+ public async stopTransaction(transactionId: number, tagId: string, meterStop: number, stopDate: Date,
+ transactionData?: OCPPMeterValue[] | OCPP15TransactionData): Promise<OCPPStopTransactionResponse> {
// Check props
const response = await this.ocppService.executeStopTransaction(this.chargingStation.id, {
transactionId: transactionId,
@@ -371,11 +373,18 @@ export default class ChargingStationContext {
});
}
// Signed Data
- if (meterValues.signedDataMeterValue) {
+ if (meterValues.signedDataStartMeterValue) {
meterValueRequest.meterValue[0].sampledValue.push({
- value: meterValues.signedDataMeterValue,
+ value: meterValues.signedDataStartMeterValue,
format: OCPPValueFormat.SIGNED_DATA,
- context,
+ context: OCPPReadingContext.TRANSACTION_BEGIN,
+ });
+ }
+ if (meterValues.signedDataStopMeterValue) {
+ meterValueRequest.meterValue[0].sampledValue.push({
+ value: meterValues.signedDataStopMeterValue,
+ format: OCPPValueFormat.SIGNED_DATA,
+ context: OCPPReadingContext.TRANSACTION_END,
});
}
// OCPP 1.5

Unit Tests - differing stopTransaction