public static void checkMapResults(KernelServices services, ModelNode expected, ModelVersion version, ModelNode operation) throws Exception { ModelNode main = ModelTestUtils.checkOutcome(services.executeOperation(operation.clone())).get(ModelDescriptionConstants.RESULT); ModelNode legacyResult = services.executeOperation(version, services.transformOperation(version, operation.clone())); ModelNode legacy; if (expected.isDefined()) { legacy = ModelTestUtils.checkOutcome(legacyResult).get(ModelDescriptionConstants.RESULT); } else { ModelTestUtils.checkFailed(legacyResult); legacy = new ModelNode(); } Assert.assertEquals(main, legacy); Assert.assertEquals(expected, legacy); }
/** * Executes a given operation asserting that an attachment has been created. Given {@link KernelServices} must have enabled attachment grabber. * * @return {@link ModelNode} result of the transformed operation */ public static ModelNode executeOpInBothControllersWithAttachments(KernelServices services, ModelVersion version, ModelNode operation) throws Exception { OperationTransformer.TransformedOperation op = services.executeInMainAndGetTheTransformedOperation(operation, version); Assert.assertFalse(op.rejectOperation(success())); // System.out.println(operation + "\nbecomes\n" + op.getTransformedOperation()); if (op.getTransformedOperation() != null) { return ModelTestUtils.checkOutcome(services.getLegacyServices(version).executeOperation(op.getTransformedOperation())); } return null; }
ModelTestUtils.checkOutcome(services.executeOperation(add)); ModelTestUtils.checkOutcome(services.executeOperation(remove)); add = Operations.createAddOperation(stackAddress.append(ProtocolResourceDefinition.pathElement("FD")), 3); //The original index of the FD protocol ModelTestUtils.checkOutcome(services.executeOperation(add));
/** * Checks that the result was successful * * @param result the result to check * @return the result contents */ protected static ModelNode checkOutcome(ModelNode result) { return ModelTestUtils.checkOutcome(result); }
/** * Checks that the result was successful * * @param result the result to check * @return the result contents */ protected static ModelNode checkOutcome(ModelNode result) { return ModelTestUtils.checkOutcome(result); }
/** * Checks that the result was successful * * @param result the result to check * @return the result contents */ protected static ModelNode checkOutcome(ModelNode result) { return ModelTestUtils.checkOutcome(result); }
/** * Checks that the result was successful * * @param result the result to check * @return the result contents */ protected static ModelNode checkOutcome(ModelNode result) { return ModelTestUtils.checkOutcome(result); }
/** * Checks that the result was successful * * @param result the result to check * @return the result contents */ protected static ModelNode checkOutcome(ModelNode result) { return ModelTestUtils.checkOutcome(result); }
@Override public TransformerOperationAttachment executeAndGrabTransformerAttachment(ModelNode op) { try { ModelNode wrapper = Util.createEmptyOperation(TransformerAttachmentGrabber.DESC.getName(), PathAddress.EMPTY_ADDRESS); wrapper.get(VALUE).set(op); ModelTestUtils.checkOutcome(executeOperation(wrapper)); return TransformerAttachmentGrabber.getAttachment(); } finally { TransformerAttachmentGrabber.clear(); } }
@Override public TransformerOperationAttachment executeAndGrabTransformerAttachment(ModelNode op) { try { ModelNode wrapper = Util.createEmptyOperation(TransformerAttachmentGrabber.DESC.getName(), PathAddress.EMPTY_ADDRESS); wrapper.get(VALUE).set(op); ModelTestUtils.checkOutcome(executeOperation(wrapper)); return TransformerAttachmentGrabber.getAttachment(); } finally { TransformerAttachmentGrabber.clear(); } }
/** * Checks that the result was successful and gets the real result contents * * @param result the result to check * @return the result contents */ public static ModelNode checkResultAndGetContents(ModelNode result) { checkOutcome(result); Assert.assertTrue("could not check for result as its missing! look for yourself here [" + result.toString() + "] and result.hasDefined(RESULT) returns " + result.hasDefined(RESULT) , result.hasDefined(RESULT)); return result.get(RESULT); }
@Override public TransformedOperation executeInMainAndGetTheTransformedOperation(ModelNode op, ModelVersion modelVersion) { try { ModelNode wrapper = Util.createEmptyOperation(TransformerAttachmentGrabber.DESC.getName(), PathAddress.EMPTY_ADDRESS); wrapper.get(VALUE).set(op); ModelTestUtils.checkOutcome(executeOperation(wrapper)); try { return transformOperation(modelVersion, op, TransformerAttachmentGrabber.getAttachment()); } catch (OperationFailedException e) { throw new RuntimeException(e); } } finally { TransformerAttachmentGrabber.clear(); } }
@Override public TransformedOperation executeInMainAndGetTheTransformedOperation(ModelNode op, ModelVersion modelVersion) { try { ModelNode wrapper = Util.createEmptyOperation(TransformerAttachmentGrabber.DESC.getName(), PathAddress.EMPTY_ADDRESS); wrapper.get(VALUE).set(op); ModelTestUtils.checkOutcome(executeOperation(wrapper)); try { return transformOperation(modelVersion, op, TransformerAttachmentGrabber.getAttachment()); } catch (OperationFailedException e) { throw new RuntimeException(e); } } finally { TransformerAttachmentGrabber.clear(); } }
ModelTestUtils.checkOutcome(mainServices.executeOperation(mainComposite)); Assert.fail(transformedComposite.getFailureDescription()); ModelTestUtils.checkOutcome(mainServices.executeOperation(modelVersion, transformedComposite)); } else { ModelTestUtils.checkOutcome(legacyServices.executeOperation(legacyComposite));