Skip to content

Commit 11fb2aa

Browse files
committed
Created JSONClient
1 parent e33c28a commit 11fb2aa

File tree

4 files changed

+45
-13
lines changed

4 files changed

+45
-13
lines changed

ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ of this software and associated documentation files (the "Software"), to deal
3535
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3636
SOFTWARE.
3737
*/
38-
public class Client
38+
public abstract class Client
3939
{
40-
private final int INDEX_UNIQUEID = 1;
41-
4240
private HashMap<String, CompletableFuture<Confirmation>> promises;
4341
private ArrayList<Feature> featureList;
4442
private Session session;

ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,14 @@ public class ClientTest extends TestUtilities {
6060

6161
@Before
6262
public void setup() {
63-
request = new Request() {
64-
@Override
65-
public boolean validate() {
66-
return false;
67-
}
68-
};
63+
request = () -> false;
6964
doReturn(request.getClass()).when(feature).getRequestType();
7065
doReturn(TestConfirmation.class).when(feature).getConfirmationType();
7166
when(feature.getAction()).thenReturn(null);
7267
doAnswer(invocation -> eventHandler = invocation.getArgumentAt(1, SessionEvents.class)).when(session).open(any(), any());
7368

74-
client = new Client(session);
69+
client = new Client(session) {
70+
};
7571

7672
when(profile.getFeatureList()).thenReturn(aList(feature));
7773
client.addFeatureProfile(profile);

ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeChargePoint.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package eu.chargetime.ocpp.test;
22

3-
import eu.chargetime.ocpp.*;
3+
import eu.chargetime.ocpp.Client;
4+
import eu.chargetime.ocpp.JSONClient;
5+
import eu.chargetime.ocpp.PropertyConstraintException;
6+
import eu.chargetime.ocpp.UnsupportedFeatureException;
47
import eu.chargetime.ocpp.feature.profile.ClientCoreEventHandler;
58
import eu.chargetime.ocpp.feature.profile.CoreProfile;
69
import eu.chargetime.ocpp.model.*;
@@ -99,8 +102,7 @@ public UnlockConnectorConfirmation handleUnlockConnectorRequest(UnlockConnectorR
99102
return new UnlockConnectorConfirmation(UnlockStatus.Unlocked);
100103
}
101104
});
102-
client = new Client(new Session(new JSONCommunicator(new WebSocketTransmitter()), new Queue()));
103-
client.addFeatureProfile(core);
105+
client = new JSONClient(core);
104106
}
105107

106108
public void connect() {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package eu.chargetime.ocpp;
2+
3+
import eu.chargetime.ocpp.feature.profile.CoreProfile;
4+
5+
/**
6+
* ChargeTime.eu - Java-OCA-OCPP
7+
* <p>
8+
* MIT License
9+
* <p>
10+
* Copyright (C) 2016 Thomas Volden <[email protected]>
11+
* <p>
12+
* Permission is hereby granted, free of charge, to any person obtaining a copy
13+
* of this software and associated documentation files (the "Software"), to deal
14+
* in the Software without restriction, including without limitation the rights
15+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16+
* copies of the Software, and to permit persons to whom the Software is
17+
* furnished to do so, subject to the following conditions:
18+
* <p>
19+
* The above copyright notice and this permission notice shall be included in all
20+
* copies or substantial portions of the Software.
21+
* <p>
22+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28+
* SOFTWARE.
29+
*/
30+
public class JSONClient extends Client {
31+
32+
public JSONClient(CoreProfile coreProfile) {
33+
super(new Session(new JSONCommunicator(new WebSocketTransmitter()), new Queue()));
34+
addFeatureProfile(coreProfile);
35+
}
36+
}

0 commit comments

Comments
 (0)