Package org.jtalks.common.model.entity

Examples of org.jtalks.common.model.entity.Component


        assertEquals(response.getContentAsByteArray(), validImage);
    }

    @Test
    public void getFavIconICOLogoShouldReturnPropertyIconWhenPropertyExists() throws IOException, ImageProcessException {
        Component forumComponent = new Component();

        String logoProperty = "logo";
        Base64Wrapper wrapper = new Base64Wrapper();
        byte[] logoBytes = wrapper.decodeB64Bytes(logoProperty);

        forumComponent.addProperty(TransactionalComponentService.COMPONENT_FAVICON_ICO_PARAM, logoProperty);
        when(componentService.getComponentOfForum()).thenReturn(forumComponent);
        when(componentService.getComponentModificationTime()).thenReturn(new Date());

        MockHttpServletResponse response = new MockHttpServletResponse();
        administrationController.getFavIconICO(new MockHttpServletRequest(), response);
View Full Code Here


        assertEquals(resultUrl, "redirect:" + initialPage);
    }

    @Test
    public void validForumInformationShouldProduceSuccessResponse() {
        Component component = setupComponentMock();

        BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(new Object(), "");
        ComponentInformation ci = new ComponentInformation();
        when(favIconIcoControllerUtils.getImageService()).thenReturn(iconImageService);
        JsonResponse response = administrationController.setForumInformation(ci, bindingResult, Locale.UK);
View Full Code Here

        assertEquals(response.getStatus(), JsonResponseStatus.FAIL);
    }

    @Test
    public void validBranchInformationShouldProduceSuccessResponse() throws NotFoundException {
        Component component = setupComponentMock();

        BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(new Object(), "");
        BranchDto branchDto = new BranchDto();
        JsonResponse response = administrationController.setBranchInformation(branchDto, bindingResult, Locale.UK);
View Full Code Here

    @Test
    public void showBranchPermissionsShouldReturnModelAndViewWithBranchAndPermissionsInformation()
            throws Exception {
        long branchId = 42;
        Component component = setupComponentMock();

        GroupsPermissions expectedPermissions = new GroupsPermissions();
        Branch expectedBranch = new Branch("name", "description");
        when(branchService.get(branchId)).thenReturn(expectedBranch);
        doReturn(expectedPermissions).when(branchService).getPermissionsFor(component.getId(), branchId);

        mockMvc = MockMvcBuilders.standaloneSetup(administrationController).build();
        this.mockMvc.perform(get("/branch/permissions/42").accept(MediaType.TEXT_HTML))
                .andExpect(model().attribute("branch", expectedBranch))
                .andExpect(model().attribute("permissions", expectedPermissions));
View Full Code Here

                .andExpect(model().attribute("permissions", expectedPermissions));
    }

    @Test
    public void getGroupsForBranchPermissionShouldReturnFailIfBranchWasNotFound() throws Exception {
        Component component = setupComponentMock();

        BranchPermission targetPermission = BranchPermission.CREATE_POSTS;
        BranchPermissionDto dto = createBranchPermissionDto(targetPermission);
        when(permissionManager.findBranchPermissionByMask(targetPermission.getMask())).thenReturn(targetPermission);
        when(branchService.getPermissionGroupsFor(component.getId(), dto.getBranchId(), dto.isAllowed(), targetPermission))
                .thenThrow(new NotFoundException());

        JsonResponse jsonResponse = administrationController.getGroupsForBranchPermission(dto);

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

    }

    @Test
    public void getGroupsForBranchPermissionShouldReturnSuccessIfBranchExistsAndPermissionHasNoGroups()
            throws Exception {
        Component component = setupComponentMock();

        BranchPermission targetPermission = BranchPermission.CREATE_POSTS;
        BranchPermissionDto dto = createBranchPermissionDto(targetPermission);
        when(branchService.getPermissionGroupsFor(component.getId(), dto.getBranchId(), dto.isAllowed(), targetPermission))
                .thenReturn(Collections.EMPTY_LIST);
        when(permissionManager.findBranchPermissionByMask(targetPermission.getMask())).thenReturn(targetPermission);
        when(permissionManager.getAllGroupsWithoutExcluded(anyList(), eq(targetPermission))).thenReturn(Collections.EMPTY_LIST);

View Full Code Here

        assertEquals(jsonResponse.getStatus(), JsonResponseStatus.SUCCESS);
    }

    @Test
    public void getGroupsForBranchPermissionShouldReturnSuccessIfBranchExists() throws Exception {
        Component component = setupComponentMock();

        BranchPermission targetPermission = BranchPermission.CREATE_POSTS;
        BranchPermissionDto dto = createBranchPermissionDto(targetPermission);

        List<Group> selectedGroupList = Arrays.asList(new Group("1"), new Group("2"), new Group("3"));
        when(branchService.getPermissionGroupsFor(component.getId(), dto.getBranchId(), dto.isAllowed(), targetPermission))
                .thenReturn(selectedGroupList);

        List<Group> allGroupList = Arrays.asList(new Group("4"), new Group("5"), new Group("6"));
        when(permissionManager.getAllGroupsWithoutExcluded(selectedGroupList, targetPermission)).thenReturn(allGroupList);
        when(permissionManager.findBranchPermissionByMask(targetPermission.getMask())).thenReturn(targetPermission);
View Full Code Here

        assertEquals(result.getSelectedGroups().size(), 3);
    }

    @Test
    public void editBranchPermissionsShouldReturnSuccessIfBranchExist() throws Exception {
        Component component = setupComponentMock();

        BranchPermission targetPermission = BranchPermission.CREATE_POSTS;
        BranchPermissionDto dto = createBranchPermissionDto(targetPermission);

        dto.setNewlyAddedGroupIds(Arrays.asList(1L, 2L));
View Full Code Here

                eq(dto.getBranchId()), eq(dto.isAllowed()), any(PermissionChanges.class));
    }

    @Test
    public void editBranchPermissionsShouldReturnFailIfBranchNotFound() throws Exception {
        Component component = setupComponentMock();

        BranchPermission targetPermission = BranchPermission.CREATE_POSTS;
        BranchPermissionDto dto = createBranchPermissionDto(targetPermission);

        dto.setNewlyAddedGroupIds(Arrays.asList(1L, 2L));
View Full Code Here

        assertEquals(response.getStatus(), JsonResponseStatus.FAIL);
    }

    private Component setupComponentMock() {
        Component component = new Component();
        component.setId(1L);
        when(componentService.getComponentOfForum()).thenReturn(component);
        return component;
    }
View Full Code Here

TOP

Related Classes of org.jtalks.common.model.entity.Component

Copyright © 2018 www.massapicom. 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.