@Test public void test320GetResourceNoJars() throws Exception { TestUtil.displayTestTile(this, "test320GetResourceNoJars"); // GIVEN Task task = taskManager.createTaskInstance( TestModelServiceContract.class.getName() + ".test320GetResourceNoJars"); OperationResult result = task.getResult(); // WHEN PrismObject<ResourceType> resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_NOJARS_OID, null, task, result); // THEN display("getObject resource", resource); result.computeStatus(); display("getObject result", result); assertEquals( "Expected partial errror in result", OperationResultStatus.PARTIAL_ERROR, result.getStatus()); OperationResultType fetchResult = resource.asObjectable().getFetchResult(); display("resource.fetchResult", fetchResult); assertEquals( "Expected partial errror in fetchResult", OperationResultStatusType.PARTIAL_ERROR, fetchResult.getStatus()); // TODO: better asserts assertNotNull("Null resource", resource); }
@Test public void test221GetResourceNotFoundResolveConnector() throws Exception { final String TEST_NAME = "test221GetResourceNotFoundResolveConnector"; TestUtil.displayTestTile(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection( ResourceType.F_CONNECTOR_REF, GetOperationOptions.createResolve()); // WHEN PrismObject<ResourceType> resource = modelService.getObject( ResourceType.class, RESOURCE_CSVFILE_NOTFOUND_OID, options, task, result); // THEN display("getObject resource", resource); result.computeStatus(); display("getObject result", result); assertEquals( "Expected partial errror in result", OperationResultStatus.PARTIAL_ERROR, result.getStatus()); OperationResultType fetchResult = resource.asObjectable().getFetchResult(); display("resource.fetchResult", fetchResult); assertEquals( "Expected partial errror in fetchResult", OperationResultStatusType.PARTIAL_ERROR, fetchResult.getStatus()); // TODO: better asserts assertNotNull("Null resource", resource); assertNotNull("Connector was not resolved", resource.asObjectable().getConnector()); }
public static void copyResultFromJAXB( ItemDefinition parentDef, QName itemName, OperationResultType jaxb, OperationResult repo, PrismContext prismContext) throws DtoTranslationException { Validate.notNull(repo, "Repo object must not be null."); if (jaxb == null) { return; } repo.setStatus(getRepoEnumValue(jaxb.getStatus(), ROperationResultStatus.class)); if (repo instanceof OperationResultFull) { try { ((OperationResultFull) repo) .setFullResult(RUtil.toRepo(parentDef, itemName, jaxb, prismContext)); } catch (Exception ex) { throw new DtoTranslationException(ex.getMessage(), ex); } } }
public static OperationResult createOperationResult(OperationResultType result) { if (result == null) { return null; } Map<String, Serializable> params = ParamsTypeUtil.fromParamsType(result.getParams()); // if (result.getParams() != null) { // params = new HashMap<String, Serializable>(); // for (EntryType entry : result.getParams().getEntry()) { // params.put(entry.getKey(), (Serializable) entry.getEntryValue()); // } // } Map<String, Serializable> context = ParamsTypeUtil.fromParamsType(result.getContext()); // if (result.getContext() != null) { // context = new HashMap<String, Serializable>(); // for (EntryType entry : result.getContext().getEntry()) { // context.put(entry.getKey(), (Serializable) entry.getEntryValue()); // } // } Map<String, Serializable> returns = ParamsTypeUtil.fromParamsType(result.getReturns()); // if (result.getReturns() != null) { // returns = new HashMap<String, Serializable>(); // for (EntryType entry : result.getReturns().getEntry()) { // returns.put(entry.getKey(), (Serializable) entry.getEntryValue()); // } // } List<OperationResult> subresults = null; if (!result.getPartialResults().isEmpty()) { subresults = new ArrayList<OperationResult>(); for (OperationResultType subResult : result.getPartialResults()) { subresults.add(createOperationResult(subResult)); } } LocalizedMessageType message = result.getLocalizedMessage(); String localizedMessage = message == null ? null : message.getKey(); List<Serializable> localizedArguments = message == null ? null : (List<Serializable>) (List) message.getArgument(); // FIXME: brutal hack OperationResult opResult = new OperationResult( result.getOperation(), params, context, returns, OperationResultStatus.parseStatusType(result.getStatus()), result.getToken(), result.getMessageCode(), result.getMessage(), localizedMessage, localizedArguments, null, subresults); if (result.getCount() != null) { opResult.setCount(result.getCount()); } return opResult; }