Examples of JSONResponse


Examples of org.jtalks.jcommune.web.dto.json.JsonResponse

        dto.setNewlyAddedGroupIds(Arrays.asList(1L, 2L));
        dto.setRemovedGroupIds(Arrays.asList(1L, 2L));
        when(permissionManager.findBranchPermissionByMask(targetPermission.getMask())).thenReturn(targetPermission);

        JsonResponse response = administrationController.editBranchPermissions(dto);

        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS);
        verify(branchService).changeBranchPermissions(anyLong(),
                eq(dto.getBranchId()), eq(dto.isAllowed()), any(PermissionChanges.class));
    }
View Full Code Here

Examples of org.jtalks.jcommune.web.dto.json.JsonResponse

        when(permissionManager.findBranchPermissionByMask(targetPermission.getMask())).thenReturn(targetPermission);
        doThrow(new NotFoundException()).when(branchService).changeBranchPermissions(anyLong(),
                eq(dto.getBranchId()), eq(dto.isAllowed()), any(PermissionChanges.class));

        JsonResponse response = administrationController.editBranchPermissions(dto);

        assertEquals(response.getStatus(), JsonResponseStatus.FAIL);
    }
View Full Code Here

Examples of org.jtalks.jcommune.web.dto.json.JsonResponse

    public void getCodeReviewSuccess() throws NotFoundException {
        CodeReview review = new CodeReview();
        review.setId(REVIEW_ID);
        when(codeReviewService.get(REVIEW_ID)).thenReturn(review);

        JsonResponse response = controller.getCodeReview(REVIEW_ID);

        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS);
        assertEquals(((CodeReviewDto) response.getResult()).getId(), REVIEW_ID);
    }
View Full Code Here

Examples of org.jtalks.jcommune.web.dto.json.JsonResponse

    @Test
    public void testGetQuotedAjax() throws NotFoundException {
        String expected = "[quote=\"user\"]" + POST_CONTENT + "[/quote]";
        when(bbCodeService.quote(POST_CONTENT, user)).thenReturn(expected);
        JsonResponse response = controller.getQuote(post.getId(), null);

        assertEquals(response.getResult(), expected);
    }
View Full Code Here

Examples of org.jtalks.jcommune.web.dto.json.JsonResponse

        String selection = "Content";
        String expected = "[quote=\"user\"]" + selection + "[/quote]";
        when(postService.get(anyLong())).thenReturn(post);
        when(bbCodeService.quote(selection, user)).thenReturn(expected);

        JsonResponse response = controller.getQuote(post.getId(), selection);

        assertEquals(response.getResult(), expected);
    }
View Full Code Here

Examples of org.jtalks.jcommune.web.dto.json.JsonResponse

        assertNullFields(dto);
    }

    @Test
    public void testRegistrationFormWithoutAnyPluginShouldBeSuccessful() {
        JsonResponse response = userController.registrationForm(request, Locale.ENGLISH);

        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS);
    }
View Full Code Here

Examples of org.jtalks.jcommune.web.dto.json.JsonResponse

    public void testRegistrationFormWithAvailablePluginShouldBeSuccessful() {
        RegistrationPlugin plugin = mock(RegistrationPlugin.class);
        when(pluginService.getRegistrationPlugins()).thenReturn(
                new ImmutableMap.Builder<Long, RegistrationPlugin>().put(1L, plugin).build());

        JsonResponse response = userController.registrationForm(request, Locale.ENGLISH);

        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS);
    }
View Full Code Here

Examples of org.jtalks.jcommune.web.dto.json.JsonResponse

    public void testRegisterUserAjaxShouldBeSuccessful() throws Exception {
        RegisterUserDto dto = createRegisterUserDto(null);
        BindingResult bindingResult = new BeanPropertyBindingResult(dto, "newUser");
        when(authenticator.register(dto)).thenReturn(bindingResult);

        JsonResponse response = userController.registerUserAjax(dto, request, Locale.ENGLISH);

        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS,
                "User without validation errors should pass registration.");
    }
View Full Code Here

Examples of org.jtalks.jcommune.web.dto.json.JsonResponse

        RegisterUserDto dto = createRegisterUserDto(null);
        BindingResult bindingResult = mock(BindingResult.class);
        when(bindingResult.hasErrors()).thenReturn(true);
        when(authenticator.register(dto)).thenReturn(bindingResult);

        JsonResponse response = userController.registerUserAjax(dto, request, Locale.ENGLISH);

        assertEquals(response.getStatus(), JsonResponseStatus.FAIL,
                "User with validation errors should fail registration.");
    }
View Full Code Here

Examples of org.jtalks.jcommune.web.dto.json.JsonResponse

    @Test
    public void testRegisterAjaxFailIfUnexpectedErrorOccurred() throws Exception {
        RegisterUserDto dto = createRegisterUserDto(null);
        doThrow(new UnexpectedErrorException()).when(authenticator).register(dto);

        JsonResponse response = userController.registerUserAjax(dto, request, Locale.ENGLISH);

        assertEquals(response.getStatus(), JsonResponseStatus.FAIL, "Unexpected error should fail registration.");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.