Search in sources :

Example 6 with Result

use of org.forgerock.opendj.ldap.responses.Result in project OpenAM by OpenRock.

the class LdapAdapterTest method shouldUseConnectionForCreate.

@Test
public void shouldUseConnectionForCreate() throws Exception {
    // Given
    Token token = new Token("badger", TokenType.SESSION);
    Result successResult = mockSuccessfulResult();
    given(mockConnection.add(any(Entry.class))).willReturn(successResult);
    given(mockConversion.getEntry(any(Token.class))).willReturn(mock(Entry.class));
    // When
    adapter.create(mockConnection, token);
    // Then
    verify(mockConnection).add(any(Entry.class));
}
Also used : Entry(org.forgerock.opendj.ldap.Entry) PartialToken(org.forgerock.openam.sm.datalayer.api.query.PartialToken) Token(org.forgerock.openam.cts.api.tokens.Token) Result(org.forgerock.opendj.ldap.responses.Result) Test(org.testng.annotations.Test)

Example 7 with Result

use of org.forgerock.opendj.ldap.responses.Result in project OpenAM by OpenRock.

the class UmaLabelsStore method createLabel.

private ResourceSetLabel createLabel(String realm, String username, ResourceSetLabel label, String id, Connection connection) throws LdapException, InternalServerErrorException {
    final AddRequest addRequest = LDAPRequests.newAddRequest(getLabelDn(realm, username, id)).addAttribute("objectClass", "top", OBJECT_CLASS).addAttribute(ID_ATTR, id).addAttribute(NAME_ATTR, label.getName()).addAttribute(TYPE_ATTR, label.getType().name());
    if (CollectionUtils.isNotEmpty(label.getResourceSetIds())) {
        addRequest.addAttribute(RESOURCE_SET_ATTR, label.getResourceSetIds().toArray());
    }
    Result result = connection.add(addRequest);
    if (!result.isSuccess()) {
        throw new InternalServerErrorException("Unknown unsuccessful request");
    }
    return new ResourceSetLabel(id, label.getName(), label.getType(), label.getResourceSetIds());
}
Also used : AddRequest(org.forgerock.opendj.ldap.requests.AddRequest) InternalServerErrorException(org.forgerock.json.resource.InternalServerErrorException) Result(org.forgerock.opendj.ldap.responses.Result)

Example 8 with Result

use of org.forgerock.opendj.ldap.responses.Result in project OpenAM by OpenRock.

the class LdapQueryBuilderTest method shouldUseHandlerToPerformSearch.

@Test
public void shouldUseHandlerToPerformSearch() throws CoreTokenException, IOException {
    // Given
    Result mockResult = mock(Result.class);
    given(searchHandler.performSearch(any(Connection.class), any(SearchRequest.class), any(Collection.class))).willReturn(mockResult);
    // When
    Iterator iterator = builder.executeRawResults(mockConnection, PartialToken.class);
    // Then
    verifyZeroInteractions(searchHandler);
    iterator.next();
    verify(searchHandler).performSearch(eq(mockConnection), any(SearchRequest.class), any(Collection.class));
}
Also used : SearchRequest(org.forgerock.opendj.ldap.requests.SearchRequest) Connection(org.forgerock.opendj.ldap.Connection) Iterator(java.util.Iterator) Collection(java.util.Collection) Result(org.forgerock.opendj.ldap.responses.Result) Test(org.testng.annotations.Test)

Aggregations

Result (org.forgerock.opendj.ldap.responses.Result)8 Test (org.testng.annotations.Test)4 Connection (org.forgerock.opendj.ldap.Connection)3 Token (org.forgerock.openam.cts.api.tokens.Token)2 PartialToken (org.forgerock.openam.sm.datalayer.api.query.PartialToken)2 Entry (org.forgerock.opendj.ldap.Entry)2 ModifyRequest (org.forgerock.opendj.ldap.requests.ModifyRequest)2 SearchRequest (org.forgerock.opendj.ldap.requests.SearchRequest)2 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)1 CoreTokenException (org.forgerock.openam.cts.exceptions.CoreTokenException)1 LDAPDataConversion (org.forgerock.openam.cts.utils.LDAPDataConversion)1 LdapTokenAttributeConversion (org.forgerock.openam.cts.utils.LdapTokenAttributeConversion)1 LdapDataLayerConfiguration (org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration)1 DN (org.forgerock.opendj.ldap.DN)1 DecodeException (org.forgerock.opendj.ldap.DecodeException)1 DecodeOptions (org.forgerock.opendj.ldap.DecodeOptions)1 Filter (org.forgerock.opendj.ldap.Filter)1 LdapException (org.forgerock.opendj.ldap.LdapException)1