![JAR search and dependency download from the Maven repository](/logo.png)
org.identityconnectors.contract.test.ObjectClassRunner Maven / Gradle / Ivy
The newest version!
/*
* ====================
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of the Common Development
* and Distribution License("CDDL") (the "License"). You may not use this file
* except in compliance with the License.
*
* You can obtain a copy of the License at
* http://opensource.org/licenses/cddl1.php
* See the License for the specific language governing permissions and limitations
* under the License.
*
* When distributing the Covered Code, include this CDDL Header Notice in each file
* and include the License file at http://opensource.org/licenses/cddl1.php.
* If applicable, add the following below this CDDL Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
* ====================
* Portions Copyrighted 2010-2013 ForgeRock AS.
* Portions Copyrighted 2018 ConnId
*/
package org.identityconnectors.contract.test;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
import org.identityconnectors.common.CollectionUtil;
import org.identityconnectors.common.logging.Log;
import org.identityconnectors.contract.exceptions.ContractException;
import org.identityconnectors.contract.exceptions.ObjectNotFoundException;
import org.identityconnectors.framework.api.operations.APIOperation;
import org.identityconnectors.framework.api.operations.GetApiOp;
import org.identityconnectors.framework.api.operations.SearchApiOp;
import org.identityconnectors.framework.api.operations.SyncApiOp;
import org.identityconnectors.framework.common.objects.ObjectClass;
import org.identityconnectors.framework.common.objects.ObjectClassInfo;
import org.identityconnectors.framework.common.objects.OperationOptions;
import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
import org.identityconnectors.framework.common.objects.Schema;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
/**
* Simple base class that will run through all the {@link ObjectClass}s.
*/
public abstract class ObjectClassRunner extends ContractTestBase {
private static final Log LOG = Log.getLog(ObjectClassRunner.class);
/**
* Main contract test entry point, it calls {@link #testRun()} method
* in configured number of iterations, runs the iteration only if the
* operation is supported by the connector
*/
@ParameterizedTest
@MethodSource("objectClasses")
public void testContract(final ObjectClass objectClass) {
//run the contract test for supported operation only
if (ConnectorHelper.operationsSupported(getConnectorFacade(), objectClass, getAPIOperations())) {
boolean supported = isObjectClassSupported(objectClass);
try {
LOG.info("--------------------------------------------------------------------------------------");
LOG.info("Running test ''{0}'' for object class ''{1}''.", getTestName(), objectClass);
LOG.info("--------------------------------------------------------------------------------------");
testRun(objectClass);
if (!supported) {
//should throw RuntimeException
fail("ObjectClass " + objectClass + " is not supported, must" + " throw RuntimeException");
}
} catch (RuntimeException e) {
if (supported) {
throw new ContractException("Unexpected RuntimeException thrown during contract test.", e);
}
}
} else {
LOG.info("--------------------------------------------------------------------------------------");
LOG.info("Skipping test ''{0}'' for object class ''{1}''.", getTestName(), objectClass);
LOG.info("--------------------------------------------------------------------------------------");
}
}
/**
* This method will be called configured number of times
*/
protected abstract void testRun(ObjectClass objectClass);
/**
* Return all the base {@link ObjectClass}s.
*/
protected static Stream objectClasses() {
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy