View Javadoc
1   package emissary.core;
2   
3   import emissary.place.ServiceProviderPlace;
4   import emissary.test.core.junit5.UnitTest;
5   
6   import org.junit.jupiter.api.Test;
7   
8   import java.io.IOException;
9   import java.util.ArrayList;
10  import java.util.Collections;
11  import java.util.List;
12  
13  import static org.junit.jupiter.api.Assertions.assertEquals;
14  
15  /**
16   *
17   */
18  class HDMobileAgentTest extends UnitTest {
19  
20      public HDMobileAgentTest() {}
21  
22      @Test
23      void testAtPlaceHDNull() throws Exception {
24          final SimplePlace place = new SimplePlace("emissary.core.FakePlace.cfg");
25          ArrayList<IBaseDataObject> children = new ArrayList<>();
26          IBaseDataObject ibdo = DataObjectFactory.getInstance(new byte[] {}, "testFile", "someFormFileType");
27          children.add(ibdo);
28          children.add(null);
29          place.setReturnCollection(children);
30          HDMobileAgent ma = new HDMobileAgent();
31          List<IBaseDataObject> ret = ma.atPlaceHD(place, Collections.emptyList());
32          assertEquals(1, ret.size());
33  
34          children.clear();
35          children.add(ibdo);
36          children.add(ibdo);
37          ret = ma.atPlaceHD(place, Collections.emptyList());
38          assertEquals(2, ret.size());
39      }
40  
41      static final class SimplePlace extends ServiceProviderPlace {
42  
43          private List<IBaseDataObject> children = Collections.emptyList();
44  
45          public SimplePlace(String configInfo) throws IOException {
46              super(configInfo, "SimplePlace.www.example.com:8001");
47          }
48  
49          void setReturnCollection(List<IBaseDataObject> children) {
50              this.children = children;
51          }
52  
53          @Override
54          public List<IBaseDataObject> agentProcessHeavyDuty(List<IBaseDataObject> payloadListArg) {
55              return children;
56          }
57  
58  
59      }
60  }