Skip to content

Commit e653602

Browse files
committed
add operational test to check "in transaction status" of id tags
1 parent aba72d0 commit e653602

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

src/main/java/de/rwth/idsg/steve/repository/impl/OcppTagRepositoryImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@
3737
@Repository
3838
public class OcppTagRepositoryImpl implements OcppTagRepository {
3939

40-
@Autowired private DSLContext ctx;
40+
private final DSLContext ctx;
41+
42+
@Autowired
43+
public OcppTagRepositoryImpl(DSLContext ctx) {
44+
this.ctx = ctx;
45+
}
4146

4247
@Override
4348
@SuppressWarnings("unchecked")

src/test/java/de/rwth/idsg/steve/OperationalTestSoapOCPP16.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,36 @@ public void testUnregisteredIdTag() {
126126
Assert.assertEquals(AuthorizationStatus.INVALID, auth.getIdTagInfo().getStatus());
127127
}
128128

129+
@Test
130+
public void testInTransactionStatusOfIdTag() {
131+
CentralSystemService client = getForOcpp16(path);
132+
133+
StartTransactionResponse start = client.startTransaction(
134+
new StartTransactionRequest()
135+
.withConnectorId(2)
136+
.withIdTag(REGISTERED_OCPP_TAG)
137+
.withTimestamp(DateTime.now())
138+
.withMeterStart(0),
139+
REGISTERED_CHARGE_BOX_ID
140+
);
141+
142+
Assert.assertNotNull(start);
143+
Assert.assertTrue(start.getTransactionId() > 0);
144+
Assert.assertTrue(__DatabasePreparer__.getOcppTagRecord(REGISTERED_OCPP_TAG).getInTransaction());
145+
146+
StopTransactionResponse stop = client.stopTransaction(
147+
new StopTransactionRequest()
148+
.withTransactionId(start.getTransactionId())
149+
.withTimestamp(DateTime.now())
150+
.withIdTag(REGISTERED_OCPP_TAG)
151+
.withMeterStop(30),
152+
REGISTERED_CHARGE_BOX_ID
153+
);
154+
155+
Assert.assertNotNull(stop);
156+
Assert.assertFalse(__DatabasePreparer__.getOcppTagRecord(REGISTERED_OCPP_TAG).getInTransaction());
157+
}
158+
129159
@Test
130160
public void testStatusNotification() {
131161
CentralSystemService client = getForOcpp16(path);

src/test/java/de/rwth/idsg/steve/__DatabasePreparer__.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
import de.rwth.idsg.steve.repository.dto.TransactionDetails;
1111
import de.rwth.idsg.steve.repository.impl.AddressRepositoryImpl;
1212
import de.rwth.idsg.steve.repository.impl.ChargePointRepositoryImpl;
13+
import de.rwth.idsg.steve.repository.impl.OcppTagRepositoryImpl;
1314
import de.rwth.idsg.steve.repository.impl.ReservationRepositoryImpl;
1415
import de.rwth.idsg.steve.repository.impl.TransactionRepositoryImpl;
1516
import de.rwth.idsg.steve.web.dto.ReservationQueryForm;
1617
import de.rwth.idsg.steve.web.dto.TransactionQueryForm;
1718
import jooq.steve.db.DefaultCatalog;
1819
import jooq.steve.db.tables.SchemaVersion;
1920
import jooq.steve.db.tables.Settings;
21+
import jooq.steve.db.tables.records.OcppTagRecord;
2022
import jooq.steve.db.tables.records.TransactionRecord;
2123
import org.joda.time.DateTime;
2224
import org.jooq.DSLContext;
@@ -106,6 +108,11 @@ public static TransactionDetails getDetails(int transactionPk) {
106108
return impl.getDetails(transactionPk);
107109
}
108110

111+
public static OcppTagRecord getOcppTagRecord(String idTag) {
112+
OcppTagRepositoryImpl impl = new OcppTagRepositoryImpl(dslContext);
113+
return impl.getRecord(idTag);
114+
}
115+
109116
public static ChargePoint.Details getCBDetails(String chargeboxID) {
110117
ChargePointRepositoryImpl impl = new ChargePointRepositoryImpl(dslContext, new AddressRepositoryImpl());
111118
Map<String, Integer> pkMap = impl.getChargeBoxIdPkPair(Arrays.asList(chargeboxID));

0 commit comments

Comments
 (0)