1 | package at.hl.okb.wsclient;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertTrue;
|
---|
4 |
|
---|
5 | import org.junit.After;
|
---|
6 | import org.junit.AfterClass;
|
---|
7 | import org.junit.Before;
|
---|
8 | import org.junit.BeforeClass;
|
---|
9 | import org.junit.Test;
|
---|
10 |
|
---|
11 | import com.heuristiclab.okb.wsclient.Exception.OKBWebServiceFailedException;
|
---|
12 | import com.heuristiclab.okb.wsclient.admin.AdministrationService;
|
---|
13 | import com.heuristiclab.okb.wsclient.admin.Algorithm;
|
---|
14 | import com.heuristiclab.okb.wsclient.admin.AlgorithmClass;
|
---|
15 | import com.heuristiclab.okb.wsclient.admin.ArrayOfAlgorithm;
|
---|
16 | import com.heuristiclab.okb.wsclient.admin.IAdministrationService;
|
---|
17 | import com.heuristiclab.okb.wsclient.admin.ObjectFactory;
|
---|
18 |
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * @author HolperM
|
---|
22 | *
|
---|
23 | */
|
---|
24 | public class OKBClientTest {
|
---|
25 |
|
---|
26 |
|
---|
27 | AdministrationService srv = null;
|
---|
28 | IAdministrationService port = null;
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * @throws java.lang.Exception
|
---|
32 | */
|
---|
33 | @BeforeClass
|
---|
34 | public static void setUpBeforeClass() throws Exception {
|
---|
35 | }
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * @throws java.lang.Exception
|
---|
39 | */
|
---|
40 | @AfterClass
|
---|
41 | public static void tearDownAfterClass() throws Exception {
|
---|
42 | }
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * @throws java.lang.Exception
|
---|
46 | */
|
---|
47 | @Before
|
---|
48 | public void setUp() throws Exception {
|
---|
49 | this.srv = new AdministrationService();
|
---|
50 | this.port = srv.getJavaAdministrationService(); //.getWSHttpBindingIAdministrationService1();
|
---|
51 | }
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * @throws java.lang.Exception
|
---|
55 | */
|
---|
56 | @After
|
---|
57 | public void tearDown() throws Exception {
|
---|
58 | }
|
---|
59 |
|
---|
60 | //TODO: fix -->Problem deleting existing Algorithm
|
---|
61 | @Test
|
---|
62 | public void AddAlgorithmTest() throws Exception {
|
---|
63 |
|
---|
64 | ObjectFactory fac = new ObjectFactory();
|
---|
65 | Long retval = 0L;
|
---|
66 |
|
---|
67 | //delete existing Algo and Class first
|
---|
68 | if (port.getAlgorithmClass(1000L)!=null) {
|
---|
69 | port.deleteAlgorithmClass(1000L);
|
---|
70 | }
|
---|
71 | if (port.getAlgorithm(1000L)!=null) {
|
---|
72 | port.deleteAlgorithm(1000L);
|
---|
73 | }
|
---|
74 |
|
---|
75 | //add AlgorithmClassId first
|
---|
76 | AddAlgorithmClassTest();
|
---|
77 | Algorithm a = fac.createAlgorithm();
|
---|
78 |
|
---|
79 | a.setAlgorithmClassId(1000L);
|
---|
80 | a.setDescription(fac.createNamedOKBItemDescription("a new Algo"));
|
---|
81 | a.setId(1000L);
|
---|
82 | a.setName(fac.createNamedOKBItemName("Algorithm Name 6"));
|
---|
83 | a.setPlatformId(1L);
|
---|
84 | try {
|
---|
85 | retval = port.addAlgorithm(a);
|
---|
86 | } catch (Exception e) {
|
---|
87 | throw new OKBWebServiceFailedException(e.getMessage());
|
---|
88 | }
|
---|
89 | assertTrue("Algortihm wasn't added", retval > 0);
|
---|
90 | }
|
---|
91 |
|
---|
92 | @Test
|
---|
93 | public void AddAlgorithmClassTest() throws Exception {
|
---|
94 |
|
---|
95 | ObjectFactory fac = new ObjectFactory();
|
---|
96 | Long retval = 0L;
|
---|
97 |
|
---|
98 | //delete existing Algo first (if exists)
|
---|
99 | if (port.getAlgorithmClass(1000L)!=null) {
|
---|
100 | port.deleteAlgorithmClass(1000L);
|
---|
101 | }
|
---|
102 |
|
---|
103 | AlgorithmClass a = fac.createAlgorithmClass();
|
---|
104 | a.setId(1000L);
|
---|
105 | a.setName(fac.createNamedOKBItemName("a new AlgoClass"));
|
---|
106 |
|
---|
107 | try {
|
---|
108 | retval = port.addAlgorithmClass(a);
|
---|
109 | } catch (Exception e) {
|
---|
110 | throw new OKBWebServiceFailedException(e.getMessage());
|
---|
111 | }
|
---|
112 | assertTrue("AlgortihmClass wasn't added", retval > 0);
|
---|
113 | }
|
---|
114 |
|
---|
115 | @Test
|
---|
116 | public void GetAlgorithmsTest() {
|
---|
117 |
|
---|
118 | ArrayOfAlgorithm algos = port.getAlgorithms();
|
---|
119 |
|
---|
120 | for (Algorithm algo : algos.getAlgorithm()) {
|
---|
121 | System.out.println("algo ClassId:=" + algo.getAlgorithmClassId());
|
---|
122 | System.out.println("algo Id:=" + algo.getId());
|
---|
123 | System.out.println("algo PlattformId:=" + algo.getPlatformId());
|
---|
124 | System.out.println("algo Class:=" + algo.getClass());
|
---|
125 | System.out.println("algo Description:="
|
---|
126 | + algo.getDescription().getValue());
|
---|
127 | System.out.println("algo Name:=" + algo.getName().getValue());
|
---|
128 | }
|
---|
129 | assertTrue("No Algorithms found!", algos.getAlgorithm().size() > 0);
|
---|
130 | }
|
---|
131 |
|
---|
132 |
|
---|
133 |
|
---|
134 |
|
---|
135 | //
|
---|
136 | // @Test
|
---|
137 | // public void GetDataTypesTest() {
|
---|
138 | //
|
---|
139 | // ArrayOfDataType dataTypes = port.getDataTypes();
|
---|
140 | //
|
---|
141 | // for (DataType dataType : dataTypes.getDataType()) {
|
---|
142 | // System.out.println("algo Id:=" + dataType.getId());
|
---|
143 | // System.out.println("algo platformId:=" + dataType.getPlatformId());
|
---|
144 | // System.out.println("algo Name:=" + dataType.getName());
|
---|
145 | // System.out.println("algo Class:=" + dataType.getClass());
|
---|
146 | // System.out.println("algo SQLName:="
|
---|
147 | // + dataType.getSqlName().getValue());
|
---|
148 | // }
|
---|
149 | // assertTrue("No dataTypes found!", dataTypes.getDataType().size() > 0);
|
---|
150 | // }
|
---|
151 | //
|
---|
152 | // @Test
|
---|
153 | // public void GetPlatFormTest() {
|
---|
154 | // Platform f = port.getPlatform(1L);
|
---|
155 | // assertTrue(f.getName().getValue().length() > 0);
|
---|
156 | // }
|
---|
157 | //
|
---|
158 | // AdministrationServiceClient client = new AdministrationServiceClient();
|
---|
159 | //
|
---|
160 | // @Test
|
---|
161 | // public void testGetPlatform() {
|
---|
162 | // client.getPlatformId("ECJ");
|
---|
163 | // }
|
---|
164 |
|
---|
165 |
|
---|
166 | }
|
---|