mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gaetan Boismal
17.46.2015 0711e4af7704529225459e20b3888c27a2744e81
OPENDJ-2383 Fix unit test

Fix unit test broken in 392bde20d26
1 files modified
42 ■■■■ changed files
opendj-server-legacy/src/test/java/org/forgerock/opendj/adapter/server3x/ConvertersTestCase.java 42 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/forgerock/opendj/adapter/server3x/ConvertersTestCase.java
@@ -53,7 +53,9 @@
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.CompareResult;
import org.forgerock.opendj.ldap.responses.ExtendedResult;
import org.forgerock.opendj.ldap.responses.GenericExtendedResult;
import org.forgerock.opendj.ldap.responses.PasswordModifyExtendedResult;
import org.forgerock.opendj.ldap.responses.Responses;
import org.forgerock.opendj.ldap.responses.Result;
import org.opends.server.DirectoryServerTestCase;
@@ -75,6 +77,7 @@
import org.opends.server.types.SearchResultEntry;
import org.opends.server.types.SearchResultReference;
import org.opends.server.util.CollectionUtils;
import org.opends.server.util.ServerConstants;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -532,21 +535,18 @@
                ByteString.empty());
    }
    @DataProvider(name = "operation result type")
    public Object[][] getOperationResultTypes() {
    @DataProvider
    public Object[][] operationResultTypes() {
        return new Object[][] {
            { BindOperation.class, BindResult.class },
            { CompareOperation.class, CompareResult.class },
            { ExtendedOperation.class, GenericExtendedResult.class },
            { SearchOperation.class, Result.class },
        };
    }
    /**
     * Tests the type of the result based on the type of the provided operation.
     */
    @Test(dataProvider = "operation result type")
    public static <O extends Operation, R extends Result> void testGetResponseResultAndResultType(
    /** Tests the type of the result based on the type of the provided operation. */
    @Test(dataProvider = "operationResultTypes")
    public <O extends Operation, R extends Result> void testGetResponseResultAndResultType(
        Class<O> operationType, Class<R> resultType) throws Exception {
        // Given
        O operation = mock(operationType);
@@ -554,8 +554,30 @@
        // When
        Result result = getResponseResult(operation);
        // Then
        assertThat(result.getResultCode()).isEqualTo(
            org.forgerock.opendj.ldap.ResultCode.SUCCESS);
        assertThat(result.getResultCode()).isEqualTo(org.forgerock.opendj.ldap.ResultCode.SUCCESS);
        assertThat(result).isInstanceOf(resultType);
    }
    @DataProvider
    public Object[][] operationExtendedResultTypes() {
        return new Object[][] {
                { "", GenericExtendedResult.class },
                { ServerConstants.OID_PASSWORD_MODIFY_REQUEST , PasswordModifyExtendedResult.class }
        };
    }
    /** Tests the type of the result based on the type of the provided operation. */
    @Test(dataProvider = "operationExtendedResultTypes")
    public <R extends ExtendedResult> void testGetResponseResultAndResultType(
            String requestOID, Class<R> resultType) throws Exception {
        // Given
        ExtendedOperation operation = mock(ExtendedOperation.class);
        when(operation.getResultCode()).thenReturn(ResultCode.SUCCESS);
        when(operation.getRequestOID()).thenReturn(requestOID);
        // When
        Result result = getResponseResult(operation);
        // Then
        assertThat(result.getResultCode()).isEqualTo(org.forgerock.opendj.ldap.ResultCode.SUCCESS);
        assertThat(result).isInstanceOf(resultType);
    }