2 * Copyright (C) 2014 Cisco Systems, Inc.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 * Authors : Thomas Bachman
11 package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages;
13 import static org.junit.Assert.assertTrue;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.groupbasedpolicy.jsonrpc.RpcMessage;
18 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.Role;
19 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointDeclareRequest;
20 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointDeclareResponse;
21 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUndeclareRequest;
22 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUndeclareResponse;
23 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUnresolveRequest;
24 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUnresolveResponse;
25 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUpdateRequest;
26 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUpdateResponse;
27 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointResolveRequest;
28 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointResolveResponse;
29 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.IdentityRequest;
30 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.IdentityResponse;
31 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyResolveRequest;
32 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyResolveResponse;
33 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUnresolveRequest;
34 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUnresolveResponse;
35 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUpdateRequest;
36 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUpdateResponse;
37 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.StateReportRequest;
38 import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.StateReportResponse;
39 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
40 import org.slf4j.Logger;
41 import org.slf4j.LoggerFactory;
43 import com.fasterxml.jackson.databind.DeserializationFeature;
44 import com.fasterxml.jackson.databind.ObjectMapper;
48 * Test the serialization and deserialization of RPC Messages,
49 * and check against expected structure and values.
51 public class OpflexMessageTest {
52 protected static final Logger logger = LoggerFactory.getLogger(OpflexMessageTest.class);
54 // private enum Role {
55 // POLICY_REPOSITORY("policy_repository"),
56 // ENDPOINT_REGISTRY("endpoint_registry"),
57 // OBSERVER("observer"),
58 // POLICY_ELEMENT("policy_element");
60 // private String role;
61 // Role(String role) {
65 // public String toString() {
70 // TODO: should just import these from somewhere?
72 * common JSON definitions
74 private static final String JSON_OBJECT_OPEN = "{";
75 private static final String JSON_OBJECT_CLOSE = "}";
76 private static final String JSON_ARRAY_OPEN = "[";
77 private static final String JSON_ARRAY_CLOSE = "]";
80 * common JSON-RPC definitions
82 // Just use the same UUID for all IDs
83 private static final String ID_UUID = "2da9e3d7-0bbe-4099-b343-12783777452f";
84 private static final String JSONRPC_ID = "\"id\": [\"send_itentity\", \"" + ID_UUID + "\"],";
85 private static final String JSONRPC_METHOD = " \"method\":";
86 private static final String JSONRPC_PARAMS_OPEN = "\"params\": " + JSON_ARRAY_OPEN;
87 private static final String JSONRPC_PARAMS_CLOSE = JSON_ARRAY_CLOSE;
88 private static final String JSONRPC_RESULT_OPEN = "\"result\": " + JSON_OBJECT_OPEN;
89 private static final String JSONRPC_RESULT_CLOSE = JSON_OBJECT_CLOSE;
90 private static final String JSONRPC_ERROR_OPEN = "\"error\": " + JSON_OBJECT_OPEN;
91 private static final String JSONRPC_ERROR_CLOSE = JSON_OBJECT_CLOSE;
94 * Common OpFlex message definitions
96 public static final String SUBJECT = "\"subject\":";
99 * Identity message-specific definitions
101 private static final String DOMAIN_UUID = "75caaff2-cb4f-4509-b45e-47b447cb35a9";
102 private static final String TEST_NAME = "vm1";
103 private static final String IDENTITY = "192.168.0.1:56732";
104 // Use the same protocol version for all test messages
105 private static final String OPFLEX_PROTO_VERSION = "1.0";
106 private static final String PROTO_VERSION = "\"proto_version\": \"" + OPFLEX_PROTO_VERSION + "\",";
107 private static final String MY_ROLE_OPEN = "\"my_role\": " + JSON_ARRAY_OPEN;
108 private static final String MY_ROLE_CLOSE = JSON_ARRAY_CLOSE;
109 private static final String PEERS_OPEN = "\"peers\":" + JSON_ARRAY_OPEN + JSON_OBJECT_OPEN;
110 private static final String PEERS_CLOSE = JSON_OBJECT_CLOSE + JSON_ARRAY_CLOSE;
111 private static final String OPFLEX_ROLE_OPEN = "\"role\":" + JSON_ARRAY_OPEN;
112 private static final String OPFLEX_ROLE_CLOSE = JSON_ARRAY_CLOSE;
113 // Use the same test name for all OpFlex name fields
114 private static final String OPFLEX_NAME = "\"name\": \"" + TEST_NAME + "\",";
115 // Use the same Domain for all test messages
116 private static final String OPFLEX_DOMAIN = "\"domain\": \"" + DOMAIN_UUID + "\",";
121 private static final String opflexIdentityRequest =
124 JSONRPC_METHOD + "\"" + IdentityRequest.IDENTITY_MESSAGE + "\"," +
125 JSONRPC_PARAMS_OPEN + JSON_OBJECT_OPEN +
130 "\"" + Role.POLICY_ELEMENT.toString() + "\"" +
132 JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE +
135 private static final String opflexIdentityResponse =
139 JSONRPC_ERROR_CLOSE + "," +
140 JSONRPC_RESULT_OPEN +
144 "\"" + Role.POLICY_REPOSITORY.toString() + "\"" +
145 MY_ROLE_CLOSE + "," +
148 "\"" + Role.ENDPOINT_REGISTRY.toString() + "\"," +
149 "\"" + Role.OBSERVER.toString() + "\"" +
150 OPFLEX_ROLE_CLOSE + "," +
151 "\"connectivity_info\": \"" + IDENTITY + "\"" +
153 JSONRPC_RESULT_CLOSE +
157 * Policy message-specific definitions
159 public static final String POLICY_URI = "\"policy_uri\":";
160 public static final String DATA = "\"data\":";
161 public static final String PRR = "\"prr\":";
162 public static final String POLICY_IDENT_OPEN = "\"policy_ident\":" + JSON_OBJECT_OPEN;
163 public static final String POLICY_IDENT_CLOSE = JSON_OBJECT_CLOSE;
164 public static final String POLICY_IDENT_CONTEXT = "\"context\":";
165 public static final String POLICY_IDENT_NAME = "\"name\":";
167 public static final Uri POLICY_IDENT_CONTEXT_VALUE =
168 new Uri("/PolicyUniverse/PolicySpace/f4d908bd-2911-43d4-9f22-a09f36ed3ddb");
169 public static final Uri POLICY_URI_VALUE =
170 new Uri("/PolicyUniverse/PolicySpace/f4d908bd-2911-43d4-9f22-a09f36ed3ddb" +
171 "/GbpContract/b3506f37-b324-4092-80dd-f8a63bd193db");
172 public static final String POLICY_CONTEXT = "Contract";
173 public static final String PROP_NAME = "subject";
174 public static final String PROP_DATA = "http";
175 public static final Uri URI_NAME = new Uri("/foo/bar/t/robot");
176 public static final Uri PARENT_URI_NAME = new Uri("/foo/bar/t");
177 public static final String SUBJECT_NAME = "webFarmContract";
178 public static final String PARENT_RELATION_NAME = "fooboo";
179 public static final String PARENT_SUBJECT_NAME = "webFarmContractParent";
180 public static final String POLICY_IDENT_URI = "ef130684-ac17-4118-ad36-8dea0babc7b2";
181 public static final String DATA_NAME = "condition:notAuthorized";
182 public static final String PRR_VALUE = "100";
185 * Policy Request using URI
187 private static final String opflexPolicyResolve1 =
190 JSONRPC_METHOD + "\"" + PolicyResolveRequest.RESOLVE_MESSAGE + "\"," +
191 JSONRPC_PARAMS_OPEN + JSON_OBJECT_OPEN +
192 SUBJECT + "\"" + SUBJECT_NAME + "\"," +
193 POLICY_URI + "\"" + POLICY_URI_VALUE.getValue() + "\"," +
195 POLICY_IDENT_NAME + "\"\"," +
196 POLICY_IDENT_CONTEXT + "\"\"" +
197 POLICY_IDENT_CLOSE + "," +
198 DATA + "\"" + DATA_NAME + "\"," +
199 PRR + "\"" + PRR_VALUE + "\"" +
200 JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE +
204 * Policy Request using policy identity
206 private static final String opflexPolicyResolve2 =
209 JSONRPC_METHOD + "\"" + PolicyResolveRequest.RESOLVE_MESSAGE + "\"," +
210 JSONRPC_PARAMS_OPEN + JSON_OBJECT_OPEN +
211 SUBJECT + "\"" + SUBJECT_NAME + "\"," +
212 POLICY_URI + "\"\"," +
214 POLICY_IDENT_NAME + "\"" + POLICY_IDENT_URI + "\"," +
215 POLICY_IDENT_CONTEXT + "\"" + POLICY_IDENT_CONTEXT_VALUE.getValue() + "\"" +
216 POLICY_IDENT_CLOSE + "," +
217 DATA + "\"" + DATA_NAME + "\"," +
218 PRR + "\"" + PRR_VALUE + "\"" +
219 JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE +
223 * Managed Object definitions
225 private static final String URI = " \"uri\":";
226 private static final String PROPERTIES_OPEN = "\"properties\":" + JSON_ARRAY_OPEN;
227 private static final String PROPERTIES_CLOSE = JSON_ARRAY_CLOSE;
228 private static final String PROPERTY_NAME = "\"name\":";
229 private static final String PROPERTY_DATA = "\"data\":";
230 private static final String PARENT_SUBJECT = "\"parent_subject\":";
231 private static final String PARENT_URI = "\"parent_uri\":";
232 private static final String PARENT_RELATION = "\"parent_relation\":";
233 private static final String CHILDREN = "\"children\":";
234 private static final String POLICY_OPEN = "\"policy\":" + JSON_ARRAY_OPEN;
235 private static final String POLICY_CLOSE = JSON_ARRAY_CLOSE;
237 private static final String managedObject =
238 SUBJECT + "\"" + SUBJECT_NAME + "\"," +
239 URI + "\"" + URI_NAME.getValue() + "\"," +
242 PROPERTY_NAME + "\"" + PROP_NAME + "\", " +
243 PROPERTY_DATA + "\"" + PROP_DATA + "\"" +
245 PROPERTIES_CLOSE + ", " +
246 PARENT_SUBJECT + "\"" + PARENT_SUBJECT_NAME + "\"," +
247 PARENT_URI + "\"" + PARENT_URI_NAME.getValue() + "\"," +
248 PARENT_RELATION + "\"" + PARENT_RELATION_NAME + "\"," +
249 CHILDREN + JSON_ARRAY_OPEN + JSON_ARRAY_CLOSE;
251 private static final String opflexPolicyResponse =
255 JSONRPC_ERROR_CLOSE + "," +
256 JSONRPC_RESULT_OPEN +
258 JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE +
260 JSONRPC_RESULT_CLOSE +
264 * Policy Unresolve message-specific definitions
266 private static final String opflexPolicyUnresolveRequest =
267 JSON_OBJECT_OPEN + JSONRPC_ID +
268 JSONRPC_METHOD + "\"" + PolicyUnresolveRequest.UNRESOLVE_MESSAGE + "\"," +
269 JSONRPC_PARAMS_OPEN + JSON_OBJECT_OPEN +
270 SUBJECT + "\"" + SUBJECT_NAME + "\"," +
271 POLICY_URI + "\"\"," +
273 POLICY_IDENT_NAME + "\"" + POLICY_IDENT_URI + "\"," +
274 POLICY_IDENT_CONTEXT + "\"" + POLICY_IDENT_CONTEXT_VALUE.getValue() + "\"" +
276 JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE +
279 private static final String opflexPolicyUnresolveResponse =
283 JSONRPC_ERROR_CLOSE + "," +
284 JSONRPC_RESULT_OPEN +
285 JSONRPC_RESULT_CLOSE +
289 * Pollicy Update message-specific definitions
291 private static final String REPLACE_OPEN = "\"replace\":" + JSON_ARRAY_OPEN;
292 private static final String REPLACE_CLOSE = JSON_ARRAY_CLOSE;
293 private static final String MERGE_CHILDREN_OPEN = "\"merge_children\":" + JSON_ARRAY_OPEN;
294 private static final String MERGE_CHILDREN_CLOSE = JSON_ARRAY_CLOSE;
295 private static final String DELETE_URI_OPEN = "\"delete_uri\":" + JSON_ARRAY_OPEN;
296 private static final String DELETE_URI_CLOSE = JSON_ARRAY_CLOSE;
298 private static final String opflexUpdateRequest =
301 JSONRPC_METHOD + "\"" + PolicyUpdateRequest.UPDATE_MESSAGE + "\"," +
302 JSONRPC_PARAMS_OPEN +
305 JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE +
306 REPLACE_CLOSE + "," +
307 MERGE_CHILDREN_OPEN +
308 JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE +
309 MERGE_CHILDREN_CLOSE + "," +
310 DELETE_URI_OPEN + "\"" + POLICY_URI_VALUE.getValue() + "\"" + DELETE_URI_CLOSE +
312 JSONRPC_PARAMS_CLOSE +
315 private static final String opflexUpdateResponse =
319 JSONRPC_ERROR_CLOSE + "," +
320 JSONRPC_RESULT_OPEN +
321 JSONRPC_RESULT_CLOSE +
326 * Endoint Declare message-specific definitions
328 private static final String ENDPOINT_OPEN = "\"endpoint\":" + JSON_ARRAY_OPEN;
329 private static final String ENDPOINT_CLOSE = JSON_ARRAY_CLOSE;
332 private static final String opflexEpDeclareRequest =
335 JSONRPC_METHOD + "\"" + EndpointDeclareRequest.DECLARE_MESSAGE + "\"," +
336 JSONRPC_PARAMS_OPEN +
339 JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE +
340 ENDPOINT_CLOSE + "," +
341 PRR + "\"" + PRR_VALUE + "\"" +
343 JSONRPC_PARAMS_CLOSE +
346 private static final String opflexEpDeclareResponse =
350 JSONRPC_ERROR_CLOSE + "," +
351 JSONRPC_RESULT_OPEN +
352 JSONRPC_RESULT_CLOSE +
356 * Endpoint Resolve message-specific definitions
358 public static final String ENDPOINT_IDENT_OPEN = "\"endpoint_ident\":" + JSON_OBJECT_OPEN;
359 public static final String ENDPOINT_IDENT_CLOSE = JSON_OBJECT_CLOSE;
360 public static final String ENDPOINT_IDENT_CONTEXT = "\"context\":";
361 public static final String ENDPOINT_IDENT_NAME = "\"identifier\":";
362 public static final Uri ENDPOINT_IDENT_CONTEXT_VALUE =
363 new Uri("/EprL2Universe/EprL2Ep/f4d908bd-2911-43d4-9f22-a09f36ed3ddb");
364 public static final Uri ENDPOINT_URI_VALUE =
365 new Uri("/EprL2Universe/EprL2Ep/f4d908bd-2911-43d4-9f22-a09f36ed3ddb/b3506f37-b324-4092-80dd-f8a63bd193db");
366 public static final String ENDPOINT_IDENT_URI = "ef130684-ac17-4118-ad36-8dea0babc7b2";
367 public static final String ENDPOINT = "\"endpoint\":";
371 * Endpoint Undeclare message-specific definitions
373 private static final String ENDPOINT_URI = "\"endpoint_uri\":";
374 private static final String opflexEpUndeclareRequest =
377 JSONRPC_METHOD + "\"" + EndpointUndeclareRequest.UNDECLARE_MESSAGE + "\"," +
378 JSONRPC_PARAMS_OPEN +
380 SUBJECT + "\"" + SUBJECT_NAME + "\"," +
381 ENDPOINT_URI + "\"" + ENDPOINT_URI_VALUE.getValue() + "\"" +
383 JSONRPC_PARAMS_CLOSE +
386 private static final String opflexEpUndeclareResponse =
390 JSONRPC_ERROR_CLOSE + "," +
391 JSONRPC_RESULT_OPEN +
392 JSONRPC_RESULT_CLOSE +
396 * Endpoint Resolve using URI
398 private static final String opflexEpResolveRequest1 =
401 JSONRPC_METHOD + "\"" + EndpointResolveRequest.EP_RESOLVE_REQUEST_MESSAGE + "\"," +
402 JSONRPC_PARAMS_OPEN +
404 SUBJECT + "\"" + SUBJECT_NAME + "\"," +
405 ENDPOINT_URI + "\"" + ENDPOINT_URI_VALUE.getValue() + "\"," +
406 ENDPOINT_IDENT_OPEN +
407 ENDPOINT_IDENT_CLOSE + "," +
408 PRR + "\"" + PRR_VALUE + "\"" +
409 JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE +
413 * Endpoint Resolve using Identity
415 private static final String opflexEpResolveRequest2 =
418 JSONRPC_METHOD + "\"" + EndpointResolveRequest.EP_RESOLVE_REQUEST_MESSAGE + "\"," +
419 JSONRPC_PARAMS_OPEN +
421 SUBJECT + "\"" + SUBJECT_NAME + "\"," +
422 ENDPOINT_URI + "\"\"," +
423 ENDPOINT_IDENT_OPEN +
424 ENDPOINT_IDENT_NAME + "\"" + ENDPOINT_IDENT_URI + "\"," +
425 ENDPOINT_IDENT_CONTEXT + "\"" + ENDPOINT_IDENT_CONTEXT_VALUE.getValue() + "\"" +
426 ENDPOINT_IDENT_CLOSE + "," +
427 PRR + "\"" + PRR_VALUE + "\"" +
428 JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE +
431 private static final String opflexEpResponse =
435 JSONRPC_ERROR_CLOSE + "," +
436 JSONRPC_RESULT_OPEN +
438 JSON_ARRAY_OPEN + JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE + JSON_ARRAY_CLOSE +
439 JSONRPC_RESULT_CLOSE +
443 * Endpoint Unresolve message-specific defines
447 * Endpoint Unresolve using URI
449 private static final String opflexEpUnresolveRequest1 =
452 JSONRPC_METHOD + "\"" + EndpointUnresolveRequest.EP_UNRESOLVE_REQUEST_MESSAGE + "\"," +
453 JSONRPC_PARAMS_OPEN +
455 SUBJECT + "\"" + SUBJECT_NAME + "\"," +
456 ENDPOINT_URI + "\"" + ENDPOINT_URI_VALUE.getValue() + "\"," +
457 ENDPOINT_IDENT_OPEN +
458 ENDPOINT_IDENT_CLOSE +
459 JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE +
463 * Endpoint Unresolve using Identity
465 private static final String opflexEpUnresolveRequest2 =
468 JSONRPC_METHOD + "\"" + EndpointUnresolveRequest.EP_UNRESOLVE_REQUEST_MESSAGE+ "\"," +
469 JSONRPC_PARAMS_OPEN +
471 SUBJECT + "\"" + SUBJECT_NAME + "\"," +
472 ENDPOINT_URI + "\"\"," +
473 ENDPOINT_IDENT_OPEN +
474 ENDPOINT_IDENT_NAME + "\"" + ENDPOINT_IDENT_URI + "\"," +
475 ENDPOINT_IDENT_CONTEXT + "\"" + ENDPOINT_IDENT_CONTEXT_VALUE.getValue() + "\"" +
476 ENDPOINT_IDENT_CLOSE +
477 JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE +
480 private static final String opflexEpUnresolveResponse =
484 JSONRPC_ERROR_CLOSE + "," +
485 JSONRPC_RESULT_OPEN +
486 JSONRPC_RESULT_CLOSE +
490 * Endpoint Update message-specific definitions
494 private static final String opflexEpUpdateRequest =
497 JSONRPC_METHOD + "\"" + EndpointUpdateRequest.EP_UPDATE_MESSAGE + "\"," +
498 JSONRPC_PARAMS_OPEN +
501 JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE +
502 REPLACE_CLOSE + "," +
503 DELETE_URI_OPEN + "\"" + POLICY_URI_VALUE.getValue() + "\"" + DELETE_URI_CLOSE +
505 JSONRPC_PARAMS_CLOSE +
508 private static final String opflexEpUpdateResponse =
512 JSONRPC_ERROR_CLOSE + "," +
513 JSONRPC_RESULT_OPEN +
514 JSONRPC_RESULT_CLOSE +
518 * State Report message-specific definitions
520 private static final String OBJECT = "\"object\":";
521 private static final Uri OBJECT_VALUE =
522 new Uri("/EprL2Universe/EprL2Ep/f4d908bd-2911-43d4-9f22-a09f36ed3ddb");
523 private static final String OBSERVABLE = "\"observable\":";
524 private static final String opflexStateRequest =
527 JSONRPC_METHOD + "\"" + StateReportRequest.STATE_MESSAGE + "\"," +
528 JSONRPC_PARAMS_OPEN +
530 OBJECT + "\"" + OBJECT_VALUE.getValue() + "\"," +
532 JSON_ARRAY_OPEN + JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE + JSON_ARRAY_CLOSE +
534 JSONRPC_PARAMS_CLOSE +
539 private static final String opflexStateResponse =
543 JSONRPC_ERROR_CLOSE + "," +
544 JSONRPC_RESULT_OPEN +
545 JSONRPC_RESULT_CLOSE +
549 public void setUp() throws Exception {
550 ObjectMapper objectMapper = new ObjectMapper();
551 objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
556 public void testIdentityRequest() throws Exception {
557 ObjectMapper objectMapper = new ObjectMapper();
558 RpcMessage rpcMsg = objectMapper.
559 readValue(opflexIdentityRequest, IdentityRequest.class);
560 String foo = objectMapper.writeValueAsString(rpcMsg);
561 System.out.println(foo);
562 assertTrue(rpcMsg instanceof IdentityRequest);
563 IdentityRequest opflexRequest = (IdentityRequest)rpcMsg;
564 assertTrue(opflexRequest.getId().toString().contains(ID_UUID));
565 assertTrue(opflexRequest.getMethod().equals(IdentityRequest.IDENTITY_MESSAGE));
566 assertTrue(opflexRequest.getParams()
567 .get(0).getProto_version().equals(OPFLEX_PROTO_VERSION));
568 assertTrue(opflexRequest.getParams()
569 .get(0).getDomain().equals(DOMAIN_UUID));
570 assertTrue(opflexRequest.getParams()
571 .get(0).getName().equals(TEST_NAME));
572 assertTrue(opflexRequest.getParams()
573 .get(0).getMy_role().get(0).equals(Role.POLICY_ELEMENT.toString()));
574 assertTrue(opflexRequest.getParams()
575 .get(0).getName().equals(TEST_NAME));
579 public void testIdentityResponse() throws Exception {
580 ObjectMapper objectMapper = new ObjectMapper();
581 RpcMessage rpcMsg = objectMapper.
582 readValue(opflexIdentityResponse, IdentityResponse.class);
583 assertTrue(rpcMsg instanceof IdentityResponse);
584 IdentityResponse opflexResponse = (IdentityResponse)rpcMsg;
585 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
586 assertTrue(opflexResponse.getResult()
587 .getDomain().equals(DOMAIN_UUID));
588 assertTrue(opflexResponse.getResult()
589 .getName().equals(TEST_NAME));
590 assertTrue(opflexResponse.getResult()
591 .getMy_role().get(0).equals(Role.POLICY_REPOSITORY.toString()));
592 assertTrue(opflexResponse.getResult()
593 .getPeers().get(0).getRole().get(0).equals(Role.ENDPOINT_REGISTRY.toString()));
594 assertTrue(opflexResponse.getResult()
595 .getPeers().get(0).getRole().get(1).equals(Role.OBSERVER.toString()));
599 * Test a policy resolve message that uses the URI instead of the
600 * policy identity for passing the policy requested.
605 public void testPolicyResolve1() throws Exception {
606 ObjectMapper objectMapper = new ObjectMapper();
607 RpcMessage rpcMsg = objectMapper.
608 readValue(opflexPolicyResolve1, PolicyResolveRequest.class);
609 assertTrue(rpcMsg instanceof PolicyResolveRequest);
610 PolicyResolveRequest opflexRequest = (PolicyResolveRequest)rpcMsg;
611 assertTrue(opflexRequest.getId().toString().contains(ID_UUID));
612 assertTrue(opflexRequest.getMethod().equals(PolicyResolveRequest.RESOLVE_MESSAGE));
613 assertTrue(opflexRequest.getParams()
614 .get(0).getPolicy_uri().getValue().equals(POLICY_URI_VALUE.getValue()));
615 assertTrue(opflexRequest.getParams()
616 .get(0).getPolicy_ident().getContext().getValue() == "");
617 assertTrue(opflexRequest.getParams()
618 .get(0).getPolicy_ident().getName() == "");
619 assertTrue(opflexRequest.getParams()
620 .get(0).getPrr() == Integer.parseInt(PRR_VALUE));
621 assertTrue(opflexRequest.getParams()
622 .get(0).getSubject().equals(SUBJECT_NAME));
623 assertTrue(opflexRequest.getParams()
624 .get(0).getData().equals(DATA_NAME));
629 * Test a policy resolve message that uses he policy identity instead
630 * of the URI for passing the policy requested.
635 public void testPolicyResolve2() throws Exception {
636 ObjectMapper objectMapper = new ObjectMapper();
637 RpcMessage rpcMsg = objectMapper.
638 readValue(opflexPolicyResolve2, PolicyResolveRequest.class);
639 assertTrue(rpcMsg instanceof PolicyResolveRequest);
640 PolicyResolveRequest opflexRequest = (PolicyResolveRequest)rpcMsg;
641 assertTrue(opflexRequest.getId().toString().contains(ID_UUID));
642 assertTrue(opflexRequest.getMethod().equals(PolicyResolveRequest.RESOLVE_MESSAGE));
643 assertTrue(opflexRequest.getParams()
644 .get(0).getPolicy_uri().getValue() == "");
645 assertTrue(opflexRequest.getParams()
646 .get(0).getPolicy_ident().getName().equals(POLICY_IDENT_URI));
647 assertTrue(opflexRequest.getParams()
648 .get(0).getPolicy_ident().getContext().getValue()
649 .equals(POLICY_IDENT_CONTEXT_VALUE.getValue()));
650 assertTrue(opflexRequest.getParams()
651 .get(0).getPrr() == Integer.parseInt(PRR_VALUE));
652 assertTrue(opflexRequest.getParams()
653 .get(0).getSubject().equals(SUBJECT_NAME));
654 assertTrue(opflexRequest.getParams()
655 .get(0).getData().equals(DATA_NAME));
660 * Test the response to the policy resolve message
665 public void testPolicyResolveResponse() throws Exception {
666 ObjectMapper objectMapper = new ObjectMapper();
667 RpcMessage rpcMsg = objectMapper.
668 readValue(opflexPolicyResponse, PolicyResolveResponse.class);
669 assertTrue(rpcMsg instanceof PolicyResolveResponse);
670 PolicyResolveResponse opflexResponse = (PolicyResolveResponse)rpcMsg;
671 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
672 // TODO: add support for testing children?
673 assertTrue(opflexResponse.getResult()
674 .getPolicy().get(0).getChildren().size() == 0);
675 assertTrue(opflexResponse.getResult()
676 .getPolicy().get(0).getParent_relation().equals(PARENT_RELATION_NAME));
677 assertTrue(opflexResponse.getResult()
678 .getPolicy().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME));
679 assertTrue(opflexResponse.getResult()
680 .getPolicy().get(0).getParent_uri().getValue().equals(PARENT_URI_NAME.getValue()));
681 assertTrue(opflexResponse.getResult()
682 .getPolicy().get(0).getUri().getValue().equals(URI_NAME.getValue()));
683 assertTrue(opflexResponse.getResult()
684 .getPolicy().get(0).getProperties().get(0).getName().equals(PROP_NAME));
685 assertTrue(opflexResponse.getResult()
686 .getPolicy().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA));
687 assertTrue(opflexResponse.getResult()
688 .getPolicy().get(0).getSubject().equals(SUBJECT_NAME));
692 * Test a policy unresolve message that uses the URI instead of the
693 * policy identity for passing the policy requested.
698 public void testPolicyUnresolveRequest() throws Exception {
699 ObjectMapper objectMapper = new ObjectMapper();
700 System.out.println(opflexPolicyUnresolveRequest);
701 RpcMessage rpcMsg = objectMapper.
702 readValue(opflexPolicyUnresolveRequest, PolicyResolveRequest.class);
703 assertTrue(rpcMsg instanceof PolicyResolveRequest);
704 PolicyResolveRequest opflexRequest = (PolicyResolveRequest)rpcMsg;
705 assertTrue(opflexRequest.getId().toString().contains(ID_UUID));
706 assertTrue(opflexRequest.getMethod().equals(PolicyUnresolveRequest.UNRESOLVE_MESSAGE));
707 System.out.println(POLICY_URI_VALUE.getValue());
708 assertTrue(opflexRequest.getParams()
709 .get(0).getPolicy_ident().getContext().getValue().equals(POLICY_IDENT_CONTEXT_VALUE.getValue()));
710 assertTrue(opflexRequest.getParams()
711 .get(0).getPolicy_uri().getValue() == "");
712 assertTrue(opflexRequest.getParams()
713 .get(0).getSubject().equals(SUBJECT_NAME));
719 public void testPolicyUnresolveResponse() throws Exception {
720 ObjectMapper objectMapper = new ObjectMapper();
721 RpcMessage rpcMsg = objectMapper.
722 readValue(opflexPolicyUnresolveResponse, PolicyUnresolveResponse.class);
723 assertTrue(rpcMsg instanceof PolicyUnresolveResponse);
724 PolicyUnresolveResponse opflexResponse = (PolicyUnresolveResponse)rpcMsg;
725 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
729 public void testPolicyUpdateRequest() throws Exception {
730 ObjectMapper objectMapper = new ObjectMapper();
731 System.out.println(opflexUpdateRequest);
732 RpcMessage rpcMsg = objectMapper.
733 readValue(opflexUpdateRequest, PolicyUpdateRequest.class);
734 assertTrue(rpcMsg instanceof PolicyUpdateRequest);
735 PolicyUpdateRequest opflexResponse = (PolicyUpdateRequest)rpcMsg;
736 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
737 assertTrue(opflexResponse.getParams().get(0)
738 .getDelete_uri().get(0).getValue().equals(POLICY_URI_VALUE.getValue()));
739 assertTrue(opflexResponse.getParams().get(0)
740 .getMerge_children().get(0).getParent_relation().equals(PARENT_RELATION_NAME));
741 assertTrue(opflexResponse.getParams().get(0)
742 .getMerge_children().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME));
743 assertTrue(opflexResponse.getParams().get(0)
744 .getMerge_children().get(0).getParent_uri().getValue().equals(PARENT_URI_NAME.getValue()));
745 assertTrue(opflexResponse.getParams().get(0)
746 .getMerge_children().get(0).getUri().getValue().equals(URI_NAME.getValue()));
747 assertTrue(opflexResponse.getParams().get(0)
748 .getMerge_children().get(0).getProperties().get(0).getName().equals(PROP_NAME));
749 assertTrue(opflexResponse.getParams().get(0)
750 .getMerge_children().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA));
751 assertTrue(opflexResponse.getParams().get(0)
752 .getMerge_children().get(0).getSubject().equals(SUBJECT_NAME));
753 // TODO: add support for testing children?
754 assertTrue(opflexResponse.getParams().get(0)
755 .getMerge_children().get(0).getChildren().size() == 0);
756 assertTrue(opflexResponse.getParams().get(0)
757 .getReplace().get(0).getParent_relation().equals(PARENT_RELATION_NAME));
758 assertTrue(opflexResponse.getParams().get(0)
759 .getReplace().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME));
760 assertTrue(opflexResponse.getParams().get(0)
761 .getReplace().get(0).getParent_uri().getValue().equals(PARENT_URI_NAME.getValue()));
762 assertTrue(opflexResponse.getParams().get(0)
763 .getReplace().get(0).getUri().getValue().equals(URI_NAME.getValue()));
764 assertTrue(opflexResponse.getParams().get(0)
765 .getReplace().get(0).getProperties().get(0).getName().equals(PROP_NAME));
766 assertTrue(opflexResponse.getParams().get(0)
767 .getReplace().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA));
768 assertTrue(opflexResponse.getParams().get(0)
769 .getReplace().get(0).getSubject().equals(SUBJECT_NAME));
770 // TODO: add support for testing children?
771 assertTrue(opflexResponse.getParams().get(0)
772 .getReplace().get(0).getChildren().size() == 0);
776 public void testUpdateResponse() throws Exception {
777 ObjectMapper objectMapper = new ObjectMapper();
778 RpcMessage rpcMsg = objectMapper.
779 readValue(opflexUpdateResponse, PolicyUpdateResponse.class);
780 assertTrue(rpcMsg instanceof PolicyUpdateResponse);
781 PolicyUpdateResponse opflexResponse = (PolicyUpdateResponse)rpcMsg;
782 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
788 public void testEpDeclareRequest() throws Exception {
789 ObjectMapper objectMapper = new ObjectMapper();
790 RpcMessage rpcMsg = objectMapper.
791 readValue(opflexEpDeclareRequest, EndpointDeclareRequest.class);
792 assertTrue(rpcMsg instanceof EndpointDeclareRequest);
793 EndpointDeclareRequest opflexResponse = (EndpointDeclareRequest)rpcMsg;
794 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
795 assertTrue(opflexResponse.getParams().get(0)
796 .getEndpoint().get(0).getParent_relation().equals(PARENT_RELATION_NAME));
797 assertTrue(opflexResponse.getParams().get(0)
798 .getEndpoint().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME));
799 assertTrue(opflexResponse.getParams().get(0)
800 .getEndpoint().get(0).getParent_uri().getValue().equals(PARENT_URI_NAME.getValue()));
801 assertTrue(opflexResponse.getParams().get(0)
802 .getEndpoint().get(0).getUri().getValue().equals(URI_NAME.getValue()));
803 assertTrue(opflexResponse.getParams().get(0)
804 .getEndpoint().get(0).getProperties().get(0).getName().equals(PROP_NAME));
805 assertTrue(opflexResponse.getParams().get(0)
806 .getEndpoint().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA));
807 assertTrue(opflexResponse.getParams().get(0)
808 .getEndpoint().get(0).getSubject().equals(SUBJECT_NAME));
809 // TODO: add support for testing children?
810 assertTrue(opflexResponse.getParams().get(0)
811 .getEndpoint().get(0).getChildren().size() == 0);
812 assertTrue(opflexResponse.getParams().get(0)
813 .getPrr() == Integer.parseInt(PRR_VALUE));
817 public void testEpDeclareResponse() throws Exception {
818 ObjectMapper objectMapper = new ObjectMapper();
819 RpcMessage rpcMsg = objectMapper.
820 readValue(opflexEpDeclareResponse, EndpointDeclareResponse.class);
821 assertTrue(rpcMsg instanceof EndpointDeclareResponse);
822 EndpointDeclareResponse opflexResponse = (EndpointDeclareResponse)rpcMsg;
823 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
827 public void testEndpointUndeclareRequest() throws Exception {
828 ObjectMapper objectMapper = new ObjectMapper();
829 RpcMessage rpcMsg = objectMapper.
830 readValue(opflexEpUndeclareRequest, EndpointUndeclareRequest.class);
831 assertTrue(rpcMsg instanceof EndpointUndeclareRequest);
832 EndpointUndeclareRequest opflexRequest = (EndpointUndeclareRequest)rpcMsg;
833 assertTrue(opflexRequest.getId().toString().contains(ID_UUID));
834 assertTrue(opflexRequest.getMethod().equals(EndpointUndeclareRequest.UNDECLARE_MESSAGE));
835 assertTrue(opflexRequest.getParams()
836 .get(0).getEndpoint_uri().getValue().equals(ENDPOINT_URI_VALUE.getValue()));
837 assertTrue(opflexRequest.getParams()
838 .get(0).getSubject().equals(SUBJECT_NAME));
844 public void testEpUndeclareResponse() throws Exception {
845 ObjectMapper objectMapper = new ObjectMapper();
846 RpcMessage rpcMsg = objectMapper.
847 readValue(opflexEpUndeclareResponse, EndpointUndeclareResponse.class);
848 assertTrue(rpcMsg instanceof EndpointUndeclareResponse);
849 EndpointUndeclareResponse opflexResponse = (EndpointUndeclareResponse)rpcMsg;
850 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
854 public void testEpResolveRequest1() throws Exception {
855 ObjectMapper objectMapper = new ObjectMapper();
856 RpcMessage rpcMsg = objectMapper.
857 readValue(opflexEpResolveRequest1, EndpointResolveRequest.class);
858 assertTrue(rpcMsg instanceof EndpointResolveRequest);
859 EndpointResolveRequest opflexResponse = (EndpointResolveRequest)rpcMsg;
860 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
861 assertTrue(opflexResponse.getParams()
862 .get(0).getSubject().equals(SUBJECT_NAME));
863 assertTrue(opflexResponse.getParams()
864 .get(0).getEndpoint_uri().getValue().equals(ENDPOINT_URI_VALUE.getValue()));
865 assertTrue(opflexResponse.getParams()
866 .get(0).getEndpoint_ident().getContext() == null);
867 assertTrue(opflexResponse.getParams()
868 .get(0).getEndpoint_ident().getIdentifier() == null);
873 public void testEpResolveRequest2() throws Exception {
874 ObjectMapper objectMapper = new ObjectMapper();
875 System.out.println(opflexEpResolveRequest2);
876 RpcMessage rpcMsg = objectMapper.
877 readValue(opflexEpResolveRequest2, EndpointResolveRequest.class);
878 assertTrue(rpcMsg instanceof EndpointResolveRequest);
879 EndpointResolveRequest opflexResponse = (EndpointResolveRequest)rpcMsg;
880 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
881 assertTrue(opflexResponse.getParams()
882 .get(0).getSubject().equals(SUBJECT_NAME));
883 assertTrue(opflexResponse.getParams()
884 .get(0).getEndpoint_uri().getValue() == "");
885 assertTrue(opflexResponse.getParams()
886 .get(0).getEndpoint_ident().getIdentifier().equals(ENDPOINT_IDENT_URI));
887 assertTrue(opflexResponse.getParams()
888 .get(0).getEndpoint_ident().getContext()
889 .getValue().equals(ENDPOINT_IDENT_CONTEXT_VALUE.getValue()));
893 public void testEpResolveResponse() throws Exception {
894 ObjectMapper objectMapper = new ObjectMapper();
895 RpcMessage rpcMsg = objectMapper.
896 readValue(opflexEpResponse, EndpointResolveResponse.class);
897 assertTrue(rpcMsg instanceof EndpointResolveResponse);
898 EndpointResolveResponse opflexResponse = (EndpointResolveResponse)rpcMsg;
899 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
900 assertTrue(opflexResponse.getResult()
901 .getEndpoint().get(0).getParent_relation().equals(PARENT_RELATION_NAME));
902 assertTrue(opflexResponse.getResult()
903 .getEndpoint().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME));
904 assertTrue(opflexResponse.getResult()
905 .getEndpoint().get(0).getParent_uri().getValue().equals(PARENT_URI_NAME.getValue()));
906 assertTrue(opflexResponse.getResult()
907 .getEndpoint().get(0).getUri().getValue().equals(URI_NAME.getValue()));
908 assertTrue(opflexResponse.getResult()
909 .getEndpoint().get(0).getProperties().get(0).getName().equals(PROP_NAME));
910 assertTrue(opflexResponse.getResult()
911 .getEndpoint().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA));
912 assertTrue(opflexResponse.getResult()
913 .getEndpoint().get(0).getSubject().equals(SUBJECT_NAME));
914 // TODO: add support for testing children?
915 assertTrue(opflexResponse.getResult()
916 .getEndpoint().get(0).getChildren().size() == 0);
920 public void testEpUnresolveRequest1() throws Exception {
921 ObjectMapper objectMapper = new ObjectMapper();
922 RpcMessage rpcMsg = objectMapper.
923 readValue(opflexEpUnresolveRequest1, EndpointUnresolveRequest.class);
924 assertTrue(rpcMsg instanceof EndpointUnresolveRequest);
925 EndpointUnresolveRequest opflexResponse = (EndpointUnresolveRequest)rpcMsg;
926 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
927 assertTrue(opflexResponse.getParams()
928 .get(0).getSubject().equals(SUBJECT_NAME));
929 assertTrue(opflexResponse.getParams()
930 .get(0).getEndpoint_uri().getValue().equals(ENDPOINT_URI_VALUE.getValue()));
931 assertTrue(opflexResponse.getParams()
932 .get(0).getEndpoint_ident().getContext() == null);
933 assertTrue(opflexResponse.getParams()
934 .get(0).getEndpoint_ident().getIdentifier() == null);
938 public void testEpUnresolveRequest2() throws Exception {
939 ObjectMapper objectMapper = new ObjectMapper();
940 RpcMessage rpcMsg = objectMapper.
941 readValue(opflexEpUnresolveRequest2, EndpointUnresolveRequest.class);
942 assertTrue(rpcMsg instanceof EndpointUnresolveRequest);
943 EndpointUnresolveRequest opflexResponse = (EndpointUnresolveRequest)rpcMsg;
944 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
945 assertTrue(opflexResponse.getParams()
946 .get(0).getSubject().equals(SUBJECT_NAME));
947 assertTrue(opflexResponse.getParams()
948 .get(0).getEndpoint_uri().getValue() == "");
949 assertTrue(opflexResponse.getParams()
950 .get(0).getEndpoint_ident().getIdentifier().equals(ENDPOINT_IDENT_URI));
951 assertTrue(opflexResponse.getParams()
952 .get(0).getEndpoint_ident().getContext()
953 .getValue().equals(ENDPOINT_IDENT_CONTEXT_VALUE.getValue()));
957 public void testEpUnresolveResponse() throws Exception {
958 ObjectMapper objectMapper = new ObjectMapper();
959 RpcMessage rpcMsg = objectMapper.
960 readValue(opflexEpUnresolveResponse, EndpointUnresolveResponse.class);
961 assertTrue(rpcMsg instanceof EndpointUnresolveResponse);
962 EndpointUnresolveResponse opflexResponse = (EndpointUnresolveResponse)rpcMsg;
963 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
967 public void testEpUpdateRequest() throws Exception {
968 ObjectMapper objectMapper = new ObjectMapper();
969 RpcMessage rpcMsg = objectMapper.
970 readValue(opflexEpUpdateRequest, EndpointUpdateRequest.class);
971 assertTrue(rpcMsg instanceof EndpointUpdateRequest);
972 EndpointUpdateRequest opflexResponse = (EndpointUpdateRequest)rpcMsg;
973 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
974 assertTrue(opflexResponse.getParams().get(0)
975 .getReplace().get(0).getParent_relation().equals(PARENT_RELATION_NAME));
976 assertTrue(opflexResponse.getParams().get(0)
977 .getReplace().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME));
978 assertTrue(opflexResponse.getParams().get(0)
979 .getReplace().get(0).getParent_uri().getValue().equals(PARENT_URI_NAME.getValue()));
980 assertTrue(opflexResponse.getParams().get(0)
981 .getReplace().get(0).getUri().getValue().equals(URI_NAME.getValue()));
982 assertTrue(opflexResponse.getParams().get(0)
983 .getReplace().get(0).getProperties().get(0).getName().equals(PROP_NAME));
984 assertTrue(opflexResponse.getParams().get(0)
985 .getReplace().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA));
986 assertTrue(opflexResponse.getParams().get(0)
987 .getReplace().get(0).getSubject().equals(SUBJECT_NAME));
988 // TODO: add support for testing children?
989 assertTrue(opflexResponse.getParams().get(0)
990 .getReplace().get(0).getChildren().size() == 0);
991 assertTrue(opflexResponse.getParams().get(0)
992 .getDelete_uri().get(0).getValue().equals(POLICY_URI_VALUE.getValue()));
997 public void testEpUpdateResponse() throws Exception {
998 ObjectMapper objectMapper = new ObjectMapper();
999 RpcMessage rpcMsg = objectMapper.
1000 readValue(opflexEpUpdateResponse, EndpointUpdateResponse.class);
1001 assertTrue(rpcMsg instanceof EndpointUpdateResponse);
1002 EndpointUpdateResponse opflexResponse = (EndpointUpdateResponse)rpcMsg;
1003 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
1008 public void testStateRequest() throws Exception {
1009 ObjectMapper objectMapper = new ObjectMapper();
1010 RpcMessage rpcMsg = objectMapper.
1011 readValue(opflexStateRequest, StateReportRequest.class);
1012 assertTrue(rpcMsg instanceof StateReportRequest);
1013 StateReportRequest opflexResponse = (StateReportRequest)rpcMsg;
1014 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));
1015 assertTrue(opflexResponse.getParams().get(0)
1016 .getObservable().get(0).getParent_relation().equals(PARENT_RELATION_NAME));
1017 assertTrue(opflexResponse.getParams().get(0)
1018 .getObservable().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME));
1019 assertTrue(opflexResponse.getParams().get(0)
1020 .getObservable().get(0).getParent_uri().equals(PARENT_URI_NAME.getValue()));
1021 assertTrue(opflexResponse.getParams().get(0)
1022 .getObservable().get(0).getUri().equals(URI_NAME.getValue()));
1023 assertTrue(opflexResponse.getParams().get(0)
1024 .getObservable().get(0).getProperties().get(0).getName().equals(PROP_NAME));
1025 assertTrue(opflexResponse.getParams().get(0)
1026 .getObservable().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA));
1027 assertTrue(opflexResponse.getParams().get(0)
1028 .getObservable().get(0).getSubject().equals(SUBJECT_NAME));
1029 // TODO: add support for testing children?
1030 assertTrue(opflexResponse.getParams().get(0)
1031 .getObservable().get(0).getChildren() == null);
1032 assertTrue(opflexResponse.getParams().get(0)
1033 .getObject().getValue().equals(OBJECT_VALUE.getValue()));
1037 public void testStateResponse() throws Exception {
1038 ObjectMapper objectMapper = new ObjectMapper();
1039 RpcMessage rpcMsg = objectMapper.
1040 readValue(opflexStateResponse, StateReportResponse.class);
1041 assertTrue(rpcMsg instanceof StateReportResponse);
1042 StateReportResponse opflexResponse = (StateReportResponse)rpcMsg;
1043 assertTrue(opflexResponse.getId().toString().contains(ID_UUID));