Exemplo n.º 1
0
  private void saveProfile(String editTeamUri) throws Exception {
    MockHttpServletRequestBuilder requestBuilder = put(editTeamUri).principal(principal);
    requestBuilder.param("name", "Some_ Guy_");
    requestBuilder.param("jobTitle", "Rock Star");
    requestBuilder.param("location", "London_");
    requestBuilder.param("bio", "I am just a guy_");
    requestBuilder.param("twitterUsername", "tw_some-guy_");
    requestBuilder.param("speakerdeckUsername", "sd_some-guy_");
    requestBuilder.param("lanyrdUsername", "ly_some-guy_");
    requestBuilder.param("geoLocation", "-12.5,45.3");
    requestBuilder.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(
        "<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));
  }
Exemplo n.º 2
0
  @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");

    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();
  }