Package sagan.team

Examples of sagan.team.MemberProfile


        mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
    }

    @Test
    public void getTeamMemberPage() throws Exception {
        MemberProfile profile = new MemberProfile();
        profile.setName("First Last");
        profile.setGithubUsername("someguy");
        profile.setUsername("someguy");

        teamRepository.save(profile);

        mockMvc.perform(get("/team/someguy"))
                .andExpect(status().isOk())
View Full Code Here


        mockMvc.perform(get("/team/not-a-user")).andExpect(status().isNotFound());
    }

    @Test
    public void getTeamMemberPage_404sWhenMemberIsHidden() throws Exception {
        MemberProfile profile = new MemberProfile();
        profile.setName("Hidden User");
        profile.setGithubUsername("hidden-user");
        profile.setUsername("hidden-user");
        profile.setHidden(true);

        teamRepository.save(profile);

        mockMvc.perform(get("/team/hidden-user")).andExpect(status().isNotFound());
    }
View Full Code Here

        mockMvc.perform(get("/team/hidden-user")).andExpect(status().isNotFound());
    }

    @Test
    public void getTeamMemberPageShowsPosts() throws Exception {
        MemberProfile profile = new MemberProfile();
        profile.setName("First Last");
        profile.setGithubUsername("someguy");
        profile.setUsername("someguy");

        teamRepository.save(profile);

        Post post = PostBuilder.post().author(profile).title("My Post").build();
        postRepository.save(post);
View Full Code Here

        mockMvc.perform(get("/team/someguy")).andExpect(status().isNotFound());
    }

    @Test
    public void getTeamMemberPageForNameWithDashes() throws Exception {
        MemberProfile profile = new MemberProfile();
        profile.setName("First Last");
        profile.setGithubUsername("some-guy");
        profile.setUsername("some-guy");

        teamRepository.save(profile);

        mockMvc.perform(get("/team/some-guy"))
                .andExpect(status().isOk())
View Full Code Here

                .andExpect(content().string(containsString("some-guy")));
    }

    @Test
    public void givenPostsCreatedOutOfOrder_authorsPostsShownOrderedByPublishedDate() throws Exception {
        MemberProfile activeAuthor = MemberProfileBuilder.profile().username("active_author").build();
        createAuthoredPost(activeAuthor, "Happy New Year", "2013-01-01 00:00");
        createAuthoredPost(activeAuthor, "Back to Work", "2013-01-03 00:00");
        createAuthoredPost(activeAuthor, "Off to the Sales", "2013-01-02 00:00");

        MvcResult response = mockMvc.perform(get("/team/active_author")).andExpect(status().isOk()).andReturn();
View Full Code Here

        return "team/index";
    }

    @RequestMapping(value = "/{username}", method = { GET, HEAD })
    public String showProfile(@PathVariable String username, Model model) {
        MemberProfile profile = teamService.fetchMemberProfileUsername(username);
        if (profile == MemberProfile.NOT_FOUND) {
            throw new MemberNotFoundException(username);
        }
        if (profile.isHidden()) {
            throw new MemberNotFoundException("Member profile for username '%s' is hidden", username);
        }
        model.addAttribute("profile", profile);
        Page<Post> posts = blogService.getPublishedPostsForMember(profile, PageableFactory.forLists(1));
        Page<PostView> postViewPage = PostView.pageOf(posts, dateFactory);
        model.addAttribute("posts", postViewPage);

        List<TeamLocation> teamLocations = new ArrayList<>();
        if (profile.getTeamLocation() != null) {
            teamLocations.add(profile.getTeamLocation());
        }
        model.addAttribute("teamLocations", teamLocations);

        return "team/show";
    }
View Full Code Here

        return "admin/team/index";
    }

    @RequestMapping(value = "/admin/profile", method = { GET, HEAD })
    public String editProfileForm(Principal principal, Model model) {
        MemberProfile profile = teamService.fetchMemberProfile(new Long(principal.getName()));
        model.addAttribute("profile", profile);
        model.addAttribute("formAction", "/admin/profile");
        return "admin/team/edit";
    }
View Full Code Here

        return "admin/team/edit";
    }

    @RequestMapping(value = "/admin/team/{username}", method = { GET, HEAD })
    public String editTeamMemberForm(@PathVariable("username") String username, Model model) {
        MemberProfile profile = teamService.fetchMemberProfileUsername(username);
        if (profile == MemberProfile.NOT_FOUND) {
            throw new MemberNotFoundException(username);
        }
        model.addAttribute("profile", profile);
        model.addAttribute("formAction", "/admin/team/" + username);
View Full Code Here

        teamImporter.importTeamMembers(gitHub);
        return "redirect:/admin/team";
    }

    private GitHub getGitHub(Principal principal) {
        MemberProfile profile = teamService.fetchMemberProfile(new Long(principal.getName()));
        String githubId = profile.getGithubId().toString();
        ConnectionRepository connectionRepository = usersConnectionRepository.createConnectionRepository(githubId);
        Connection<GitHub> connection = connectionRepository.findPrimaryConnection(GitHub.class);
        if (connection != null) {
            return connection.getApi();
        }
View Full Code Here

            try {
                if (!signInService.isSpringMember(githubUsername, gitHub)) {
                    throw new BadCredentialsException("User not member of required org");
                }

                MemberProfile member = signInService.getOrCreateMemberProfile(new Long(githubId), gitHub);
                Authentication authentication = new UsernamePasswordAuthenticationToken(
                        member.getId(), member.getGithubUsername(),
                        AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER"));
                SecurityContextHolder.getContext().setAuthentication(authentication);
                return path;

            } catch (RestClientException ex) {
View Full Code Here

TOP

Related Classes of sagan.team.MemberProfile

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.