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));
}
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());
}
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));
}
Aggregations