View Javadoc
1   package com.srv4pos.server.api.receiptSettings;
2   
3   import com.srv4pos.server.api.ServiceFactory;
4   import com.srv4pos.server.api.infrastructure.credentials.Credentials;
5   import com.srv4pos.server.api.infrastructure.http.Transport;
6   import com.srv4pos.server.api.seller.SellerService;
7   
8   import java.net.URL;
9   
10  import static org.junit.Assert.assertEquals;
11  
12  /**
13   * User: Pavel Abizyaev, Date: 11.03.2015 18:07.
14   */
15  public class ReceiptSettingsServiceSample {
16      private final SellerService sellerService;
17      private final ReceiptSettingsService receiptSettingsService;
18  
19      public ReceiptSettingsServiceSample(URL url, Credentials credentials, Transport transport) {
20          ServiceFactory serviceFactory = new ServiceFactory(url, credentials, transport);
21          receiptSettingsService = serviceFactory.getReceiptSettingsService();
22          sellerService = serviceFactory.getSellerService();
23      }
24  
25      public void test() throws Exception {
26          // get the version
27          int currentSellerVersion = sellerService.getThisVersion().getVersion();
28  
29          // update receipt settings
30          ReceiptSettingsInfo receiptSettingsInfo = new ReceiptSettingsInfo();
31  
32          receiptSettingsInfo.setLogoWidth(100);
33          receiptSettingsInfo.setShowCompanyName(true);
34          receiptSettingsInfo.setTextBottom("bottom");
35          receiptSettingsInfo.setTextTop("top");
36          receiptSettingsInfo.setShowLogo(true);
37  
38          receiptSettingsService.update(currentSellerVersion, receiptSettingsInfo);
39  
40          ReceiptSettingsInfo receivedReceiptSettingsInfo = receiptSettingsService.get(null);
41          assertEquals("Logo width mismatch. Make sure server return right data", receiptSettingsInfo.getLogoWidth(), receivedReceiptSettingsInfo.getLogoWidth());
42          assertEquals("Logo top mismatch. Make sure server return right data", receiptSettingsInfo.getTextTop(), receivedReceiptSettingsInfo.getTextTop());
43          assertEquals("Text bottom mismatch. Make sure server return right data",
44                  receiptSettingsInfo.getTextBottom(), receivedReceiptSettingsInfo.getTextBottom());
45          assertEquals("Show company name mismatch. Make sure server return right data",
46                  receiptSettingsInfo.isShowCompanyName(), receivedReceiptSettingsInfo.isShowCompanyName());
47          assertEquals("Show logo mismatch. Make sure server return right data", receiptSettingsInfo.isShowLogo(), receivedReceiptSettingsInfo.isShowLogo());
48      }
49  }