Search in sources :

Example 6 with SecurityQuestionTO

use of org.apache.syncope.common.lib.to.SecurityQuestionTO in project syncope by apache.

the class SecurityQuestionITCase method list.

@Test
public void list() {
    List<SecurityQuestionTO> securityQuestionTOs = securityQuestionService.list();
    assertNotNull(securityQuestionTOs);
    assertFalse(securityQuestionTOs.isEmpty());
    for (SecurityQuestionTO instance : securityQuestionTOs) {
        assertNotNull(instance);
    }
}
Also used : SecurityQuestionTO(org.apache.syncope.common.lib.to.SecurityQuestionTO) Test(org.junit.jupiter.api.Test)

Example 7 with SecurityQuestionTO

use of org.apache.syncope.common.lib.to.SecurityQuestionTO in project syncope by apache.

the class SecurityQuestionITCase method read.

@Test
public void read() {
    SecurityQuestionTO securityQuestionTO = securityQuestionService.read("887028ea-66fc-41e7-b397-620d7ea6dfbb");
    assertNotNull(securityQuestionTO);
}
Also used : SecurityQuestionTO(org.apache.syncope.common.lib.to.SecurityQuestionTO) Test(org.junit.jupiter.api.Test)

Example 8 with SecurityQuestionTO

use of org.apache.syncope.common.lib.to.SecurityQuestionTO in project syncope by apache.

the class SecurityQuestionITCase method update.

@Test
public void update() {
    SecurityQuestionTO securityQuestionTO = securityQuestionService.read("887028ea-66fc-41e7-b397-620d7ea6dfbb");
    securityQuestionTO.setContent("What is your favorite color?");
    securityQuestionService.update(securityQuestionTO);
    SecurityQuestionTO actual = securityQuestionService.read(securityQuestionTO.getKey());
    assertNotNull(actual);
    assertEquals(actual, securityQuestionTO);
}
Also used : SecurityQuestionTO(org.apache.syncope.common.lib.to.SecurityQuestionTO) Test(org.junit.jupiter.api.Test)

Example 9 with SecurityQuestionTO

use of org.apache.syncope.common.lib.to.SecurityQuestionTO in project syncope by apache.

the class SecurityQuestionServiceImpl method create.

@Override
public Response create(final SecurityQuestionTO securityQuestionTO) {
    SecurityQuestionTO created = logic.create(securityQuestionTO);
    URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
    return Response.created(location).header(RESTHeaders.RESOURCE_KEY, created.getKey()).build();
}
Also used : URI(java.net.URI) SecurityQuestionTO(org.apache.syncope.common.lib.to.SecurityQuestionTO)

Example 10 with SecurityQuestionTO

use of org.apache.syncope.common.lib.to.SecurityQuestionTO in project syncope by apache.

the class SecurityQuestionLogic method delete.

@PreAuthorize("hasRole('" + StandardEntitlement.SECURITY_QUESTION_DELETE + "')")
public SecurityQuestionTO delete(final String key) {
    SecurityQuestion securityQuestion = securityQuestionDAO.find(key);
    if (securityQuestion == null) {
        LOG.error("Could not find security question '" + key + "'");
        throw new NotFoundException(String.valueOf(key));
    }
    SecurityQuestionTO deleted = binder.getSecurityQuestionTO(securityQuestion);
    securityQuestionDAO.delete(key);
    return deleted;
}
Also used : NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) SecurityQuestion(org.apache.syncope.core.persistence.api.entity.user.SecurityQuestion) SecurityQuestionTO(org.apache.syncope.common.lib.to.SecurityQuestionTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

SecurityQuestionTO (org.apache.syncope.common.lib.to.SecurityQuestionTO)10 Test (org.junit.jupiter.api.Test)5 SecurityQuestionService (org.apache.syncope.common.rest.api.service.SecurityQuestionService)3 IOException (java.io.IOException)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Response (javax.ws.rs.core.Response)2 AbstractResource (org.apache.wicket.request.resource.AbstractResource)2 IResource (org.apache.wicket.request.resource.IResource)2 URI (java.net.URI)1 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)1 SecurityQuestion (org.apache.syncope.core.persistence.api.entity.user.SecurityQuestion)1 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)1 StringValue (org.apache.wicket.util.string.StringValue)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1