Package sagan.team

Examples of sagan.team.MemberProfile


    @Test
    public void importAddsNewTeamMembersAndSetsThemToBeHidden() throws Exception {
        teamImporter.importTeamMembers(gitHub);

        MemberProfile john = teamRepository.findByGithubId(123L);
        assertThat(john, not(nullValue()));
        assertThat(john.getGithubUsername(), equalTo("jdoe"));
        assertThat(john.getUsername(), equalTo("jdoe"));
        assertThat(john.getName(), equalTo("John Doe"));
        assertThat(john.isHidden(), equalTo(true));

        MemberProfile adam = teamRepository.findByGithubId(987L);
        assertThat(adam, not(nullValue()));
        assertThat(adam.getGithubUsername(), equalTo("asmith"));
        assertThat(adam.getName(), equalTo("Adam Smith"));
        assertThat(adam.isHidden(), equalTo(true));
    }
View Full Code Here


        assertThat(adam.isHidden(), equalTo(true));
    }

    @Test
    public void importUpdatesExistingTeamMembersGithubUsername() throws Exception {
        MemberProfile profile = new MemberProfile();
        profile.setGithubId(123L);
        profile.setGithubUsername("oldusername");
        profile.setUsername("oldusername");
        teamRepository.save(profile);

        teamImporter.importTeamMembers(gitHub);

        MemberProfile updatedProfile = teamRepository.findByGithubId(123L);
        assertThat(updatedProfile, not(nullValue()));
        assertThat(updatedProfile.getGithubUsername(), equalTo("jdoe"));
        assertThat(updatedProfile.getUsername(), equalTo("oldusername"));
        assertThat(updatedProfile.isHidden(), equalTo(false));
    }
View Full Code Here

        assertThat(updatedProfile.isHidden(), equalTo(false));
    }

    @Test
    public void importHidesActiveMembersNoLongerOnTheTeam() throws Exception {
        MemberProfile profile = new MemberProfile();
        profile.setGithubId(456L);
        profile.setGithubUsername("quitter");
        profile.setUsername("quitter");
        profile.setHidden(false);
        teamRepository.save(profile);

        teamImporter.importTeamMembers(gitHub);

        MemberProfile updatedProfile = teamRepository.findByGithubId(456L);
        assertThat(updatedProfile, not(nullValue()));
        assertThat(updatedProfile.getGithubUsername(), equalTo("quitter"));
        assertThat(updatedProfile.isHidden(), equalTo(true));
    }
View Full Code Here

        assertThat(updatedProfile.isHidden(), equalTo(true));
    }

    @Test
    public void importHidesActiveMembersNoLongerOnTheTeamWithoutAGithubId() throws Exception {
        MemberProfile profile = new MemberProfile();
        profile.setGithubUsername("quitter");
        profile.setUsername("quitter");
        profile.setHidden(false);
        teamRepository.save(profile);

        teamImporter.importTeamMembers(gitHub);

        MemberProfile updatedProfile = teamRepository.findByUsername("quitter");
        assertThat(updatedProfile, not(nullValue()));
        assertThat(updatedProfile.isHidden(), equalTo(true));
    }
View Full Code Here

    public String createPost(Principal principal, @Valid PostForm postForm, BindingResult bindingResult, Model model) {
        if (bindingResult.hasErrors()) {
            model.addAttribute("categories", PostCategory.values());
            return "admin/blog/new";
        } else {
            MemberProfile memberProfile = teamRepository.findById(new Long(principal.getName()));
            try {
                Post post = service.addPost(postForm, memberProfile.getUsername());
                PostView postView = PostView.of(post, dateFactory);
                return "redirect:" + postView.getPath();
            } catch (DataIntegrityViolationException ex) {
                model.addAttribute("categories", PostCategory.values());
                model.addAttribute("postForm", postForm);
View Full Code Here

    private MockMvc mockMvc;
    private Principal principal;

    @Before
    public void setup() {
        MemberProfile existingProfile = new MemberProfile();
        existingProfile.setUsername("some-guy");
        existingProfile.setName("Some");
        existingProfile.setJobTitle("Engineer");
        existingProfile.setLocation("London");
        existingProfile.setBio("I am just a guy");
        existingProfile.setGithubUsername("gh-some-guy");
        existingProfile.setTwitterUsername("tw_some-guy");
        existingProfile.setSpeakerdeckUsername("sd_some-guy");
        existingProfile.setLanyrdUsername("ly_some-guy");
        existingProfile.setGplusId("123456");

        final MemberProfile memberProfile = teamRepository.save(existingProfile);

        principal = () -> memberProfile.getId().toString();
        mockMvc = MockMvcBuilders.webAppContextSetup(wac)
                .addFilters(springSecurityFilterChain)
                .defaultRequest(get("/").with(csrf()).with(user(memberProfile.getId()).roles("USER"))).build();
    }
View Full Code Here

                .param("videoEmbeds",
                        "<iframe width=\"420\" height=\"315\" src=\"//www.youtube.com/embed/J---aiyznGQ\" frameborder=\"0\" allowfullscreen></iframe>");

        performRequestAndExpectRedirect(requestBuilder, editTeamUri);

        MemberProfile profile = teamRepository.findByUsername("some-guy");
        assertThat(profile, not(nullValue()));
        assertEquals("some-guy", profile.getUsername());
        assertEquals("gh-some-guy", profile.getGithubUsername());
        assertEquals("Some_ Guy_", profile.getName());
        assertEquals("Rock Star", profile.getJobTitle());
        assertEquals("London_", profile.getLocation());
        assertEquals("I am just a guy_", profile.getBio());
        assertEquals("tw_some-guy_", profile.getTwitterUsername());
        assertEquals("sd_some-guy_", profile.getSpeakerdeckUsername());
        assertEquals("ly_some-guy_", profile.getLanyrdUsername());
        assertEquals("654321", profile.getGplusId());
        assertEquals(
                "<iframe width=\"420\" height=\"315\" src=\"//www.youtube.com/embed/J---aiyznGQ\" frameborder=\"0\" allowfullscreen></iframe>",
                profile.getVideoEmbeds());

        assertThat(profile.getGeoLocation(), not(nullValue()));
        assertThat((double) profile.getGeoLocation().getLatitude(), closeTo(-12.5, 0.1));
        assertThat((double) profile.getGeoLocation().getLongitude(), closeTo(45.3, 0.1));
    }
View Full Code Here

    private PostFormAdapter adapter;

    @Before
    public void setup() {
        MemberProfile profile = new MemberProfile();
        profile.setUsername(AUTHOR_USERNAME);
        profile.setName(AUTHOR_NAME);
        given(teamRepository.findByUsername(AUTHOR_USERNAME)).willReturn(profile);

        given(renderer.render(content)).willReturn(RENDERED_HTML);
        given(postSummary.forContent(anyString(), anyInt())).willReturn(RENDERED_SUMMARY);
        given(dateFactory.now()).willReturn(now);
View Full Code Here

    private Principal principal;

    @Before
    public void setup() {
        MemberProfile profile = new MemberProfile();
        profile.setUsername("author");
        profile.setName("Mr Author");
        profile = teamRepository.save(profile);

        final Long profileId = profile.getId();

        principal = profileId::toString;
        mockMvc = MockMvcBuilders.webAppContextSetup(wac)
                .addFilters(springSecurityFilterChain)
                .defaultRequest(get("/").with(csrf()).with(user(profileId).roles("USER"))).build();
View Full Code Here

    @Autowired
    private TeamRepository teamRepository;

    @Test
    public void blogIndexPostsIncludeLinkToAuthor() throws Exception {
        MemberProfile activeAuthor = MemberProfileBuilder.profile().username("active_author").build();
        teamRepository.save(activeAuthor);

        Post post = new PostBuilder().title("Blog Post ").author(activeAuthor).build();
        postRepository.save(post);

        MvcResult response = mockMvc.perform(get("/blog")).andReturn();
        Document html = Jsoup.parse(response.getResponse().getContentAsString());
        assertThat(html.select("a.author").first().attr("href"), containsString(activeAuthor.getUsername()));
    }
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.