+ @Test
+ public void testGetPnf() {
+ ControlLoopEventContext context = new ControlLoopEventContext(onset);
+ params = params.toBuilder().context(context).build();
+ operation = new GrpcOperation(params, config);
+
+ // in neither property nor context
+ assertThatIllegalArgumentException().isThrownBy(() -> operation.getPnfData())
+ .withMessage("missing PNF data");
+
+ // only in context
+ Pnf pnf = new Pnf();
+ params.getContext().setProperty(AaiGetPnfOperation.getKey(params.getTargetEntity()), pnf);
+ assertSame(pnf, operation.getPnfData());
+
+ // both - should choose the property
+ Pnf pnf2 = new Pnf();
+ operation.setProperty(OperationProperties.AAI_PNF, pnf2);
+ assertSame(pnf2, operation.getPnfData());
+ }
+
+ @Test
+ public void testGetServiceInstanceId() {
+ ControlLoopEventContext context = new ControlLoopEventContext(onset);
+ params = params.toBuilder().context(context).build();
+ operation = new GrpcOperation(params, config);
+
+ // in neither property nor custom query
+ context.setProperty(AaiCqResponse.CONTEXT_KEY, mock(AaiCqResponse.class));
+ assertThatIllegalArgumentException().isThrownBy(() -> operation.getServiceInstanceId())
+ .withMessage("Target service instance could not be found");
+
+ // only in custom query
+ loadCqData(params.getContext());
+ assertEquals(MY_SVC_ID, operation.getServiceInstanceId());
+
+ // both - should choose the property
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("another-service-id");
+ operation.setProperty(OperationProperties.AAI_SERVICE, serviceInstance);
+ assertEquals("another-service-id", operation.getServiceInstanceId());
+ }
+
+ @Test
+ public void testGetVnfId() {
+ ControlLoopEventContext context = new ControlLoopEventContext(onset);
+ params = params.toBuilder().context(context).build();
+ operation = new GrpcOperation(params, config);
+
+ // in neither property nor custom query
+ context.setProperty(AaiCqResponse.CONTEXT_KEY, mock(AaiCqResponse.class));
+ assertThatIllegalArgumentException().isThrownBy(() -> operation.getVnfId())
+ .withMessage("Target generic vnf could not be found");
+
+ // only in custom query
+ loadCqData(params.getContext());
+ assertEquals(MY_VNF, operation.getVnfId());
+
+ // both - should choose the property
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("another-vnf-id");
+ operation.setProperty(OperationProperties.AAI_RESOURCE_VNF, vnf);
+ assertEquals("another-vnf-id", operation.getVnfId());
+ }
+