1 package com.srv4pos.server.api.registration;
2
3 import com.srv4pos.server.api.ServiceFactory;
4 import com.srv4pos.server.api.activation.ActivationServiceSample;
5 import com.srv4pos.server.api.exceptions.ForbiddenJsonException;
6 import com.srv4pos.server.api.infrastructure.credentials.Credentials;
7 import com.srv4pos.server.api.infrastructure.http.Transport;
8 import com.srv4pos.server.api.posplus.KdInfo;
9 import com.srv4pos.server.api.posplus.KdReplyInfo;
10 import com.srv4pos.server.api.posplus.PosPlusService;
11 import com.srv4pos.server.api.posplus.PrintType;
12 import com.srv4pos.server.api.seller.SellerService;
13
14 import java.net.URL;
15 import java.util.Date;
16 import java.util.HashMap;
17
18 import static com.srv4pos.server.api.infrastructure.DiagnosticsUtil.assertExceptionThrown;
19
20
21
22
23 public class RegistrationServiceSample {
24
25 private final RegistrationService registrationService;
26 public RegistrationServiceSample(URL url, Credentials activationCredentials, Transport transport) {
27 ServiceFactory serviceFactory = new ServiceFactory(url, activationCredentials, transport);
28
29 registrationService = serviceFactory.getRegistrationService();
30 }
31
32 public void test() throws Exception {
33
34 assertExceptionThrown("RegistrationService.list() is forbidden!", ForbiddenJsonException.class, new Runnable() {
35 public void run() {
36 registrationService.list(null);
37 }
38 });
39
40 KdInfo kdInfo = new KdInfo();
41 kdInfo.setRefund(false);
42
43 kdInfo.setBrutto(1000);
44 kdInfo.setDate(new Date());
45 kdInfo.setPrintType(PrintType.Normal);
46 kdInfo.setReceiptNumber(0);
47 HashMap<Integer, Long> vatRateToSum = new HashMap<Integer, Long>();
48 vatRateToSum.put(6, 1000L);
49
50 kdInfo.setVatRateToSum(vatRateToSum);
51 String sellerId = "se9876543217";
52 String cashRegisterName = "TESTCASH";
53 KdReplyInfo kd = registrationService.kd(kdInfo, sellerId, cashRegisterName);
54
55 org.junit.Assert.assertEquals("Make sure test control unit exists", ActivationServiceSample.CONTROL_UNIT_SERIAL_NUMBER, kd.getControlUnitSerial());
56 org.junit.Assert.assertNotNull("Make sure test control unit replies", kd.getResponse());
57 }
58 }