Example usage for org.springframework.http MediaType APPLICATION_JSON

List of usage examples for org.springframework.http MediaType APPLICATION_JSON

Introduction

In this page you can find the example usage for org.springframework.http MediaType APPLICATION_JSON.

Prototype

MediaType APPLICATION_JSON

To view the source code for org.springframework.http MediaType APPLICATION_JSON.

Click Source Link

Document

Public constant media type for application/json .

Usage

From source file:org.awesomeagile.integrations.hackpad.HackpadClientTest.java

@Test
public void testCreateHackpad() {
    mockServer.expect(requestTo("http://test/api/1.0/pad/create")).andExpect(method(HttpMethod.POST))
            .andExpect(header(HTTP.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE))
            .andExpect(content().string("The Title"))
            .andRespond(withSuccess("{\"padId\":\"C0E68BD495E9\"}", MediaType.APPLICATION_JSON));

    PadIdentity id = client.createHackpad("The Title");
    assertEquals("C0E68BD495E9", id.getPadId());
}

From source file:fi.helsinki.opintoni.server.CoursePageServer.java

public void expectTeacherCourseImplementationEventsRequest(String courseImplementationId) {
    server.expect(requestTo(eventsUrl(courseImplementationId))).andExpect(method(HttpMethod.GET)).andRespond(
            withSuccess(SampleDataFiles.toText("coursepage/teacherevents.json"), MediaType.APPLICATION_JSON));
}

From source file:com.epam.ta.reportportal.events.handler.ProjectActivitiesListenerTest.java

@Test
public void checkProjectActivitiesPositive() throws Exception {
    UpdateProjectRQ updateProjectRQ = new UpdateProjectRQ();
    ProjectConfiguration projectConfiguration = new ProjectConfiguration();
    projectConfiguration.setInterruptJobTime(InterruptionJobDelay.ONE_DAY.getValue());
    projectConfiguration.setKeepLogs(KeepLogsDelay.ONE_MONTH.getValue());
    projectConfiguration.setKeepScreenshots(KeepScreenshotsDelay.ONE_MONTH.getValue());
    projectConfiguration.setIsAAEnabled(false);
    updateProjectRQ.setConfiguration(projectConfiguration);

    this.mvcMock//  w ww.ja va  2s  .  c o  m
            .perform(put("/project/project1").content(objectMapper.writeValueAsBytes(updateProjectRQ))
                    .contentType(MediaType.APPLICATION_JSON).principal(authentication()))
            .andExpect(status().is(200));

    Filter filter = new Filter(Activity.class,
            new HashSet<>(Arrays.asList(new FilterCondition(Condition.EQUALS, false, "project1", "projectRef"),
                    new FilterCondition(Condition.EQUALS, false, "update_project", "actionType"))));
    List<Activity> activities = activityRepository.findByFilter(filter);
    Map<String, Activity.FieldValues> history = activities.get(0).getHistory();

    Assert.assertTrue(history.containsKey(LAUNCH_INACTIVITY));
    Assert.assertTrue(history.containsKey(KEEP_LOGS));
    Assert.assertTrue(history.containsKey(KEEP_SCREENSHOTS));
    Assert.assertTrue(history.containsKey(AUTO_ANALYZE));
}

From source file:org.apereo.openlrs.controllers.AboutControllerIntegrationTest.java

@Test
public void thatAboutReturnsJsonWithVersion() throws Exception {
    this.mockMvc//w w w  .j a  v  a  2 s  . c  o  m
            .perform(get("/xAPI/about").header(XApiConstants.XAPI_VERSION_HEADER, "someversion")
                    .accept(MediaType.APPLICATION_JSON))
            .andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("version").exists());
}

From source file:tds.assessment.web.endpoints.AssessmentWindowControllerIntegrationTests.java

@Test
public void shouldReturnAssessmentWindows() throws Exception {
    Instant startTime = Instant.now();
    Instant endTime = Instant.now().plus(Days.days(20).toStandardDuration());
    AssessmentWindow window = new AssessmentWindow.Builder().withWindowId("windowId")
            .withAssessmentKey("SLA 11").withMode("mode").withWindowMaxAttempts(3).withWindowSessionType(0)
            .withStartTime(startTime).withEndTime(endTime).withFormKey("formKey").withModeMaxAttempts(5)
            .withModeSessionType(-1).build();

    when(mockAssessmentWindowService.findAssessmentWindows(isA(AssessmentWindowParameters.class)))
            .thenReturn(Collections.singletonList(window));

    String url = "/SBAC_PT/assessments/math11/windows";

    http.perform(get(url).param("guestStudent", "false").contentType(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)))
            .andExpect(jsonPath("[0].windowId", is("windowId")))
            .andExpect(jsonPath("[0].assessmentKey", is("SLA 11")))
            .andExpect(jsonPath("[0].windowMaxAttempts", is(3)))
            .andExpect(jsonPath("[0].windowSessionType", is(0)))
            .andExpect(jsonPath("[0].formKey", is("formKey"))).andExpect(jsonPath("[0].modeMaxAttempts", is(5)))
            .andExpect(jsonPath("[0].modeSessionType", is(-1)));
}

From source file:com.test.RestApplicationTests.java

@Test
public void wordsJson() throws Exception {
    assertThat(rest.exchange(RequestEntity.get(new URI("/words")).accept(MediaType.APPLICATION_JSON).build(),
            String.class).getBody()).isEqualTo("[\"foo\",\"bar\"]");
}

From source file:fi.helsinki.opintoni.web.rest.privateapi.FavoriteResourceTest.java

@Test
public void thatUnisportFavoriteIsSaved() throws Exception {
    unisportServer.expectAuthorization();
    mockMvc.perform(post("/api/private/v1/favorites/unisport").with(securityContext(studentSecurityContext()))
            .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk()).andExpect(content().contentType(WebConstants.APPLICATION_JSON_UTF8))
            .andExpect(jsonPath("$.id").value(any(Number.class)));
}

From source file:at.ac.tuwien.dsg.cloud.utilities.gateway.registry.UserController.java

@RequestMapping(method = RequestMethod.PUT, value = REST_USER_PATH_VARIABLE)
public ResponseEntity<String> register(@PathVariable String user) {

    RequestEntity<KongUserCreateDto> request = RequestEntity
            .post(URI.create(this.kongUris.getKongConsumersUri())).contentType(MediaType.APPLICATION_JSON)
            .body(KongUserCreateDto.build(user));

    ResponseEntity<KongUser> resp = restUtilities.simpleRestExchange(request, KongUser.class);

    if (resp == null || resp.getStatusCode() != HttpStatus.CREATED) {
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }//  ww w.j  av a2 s. c o  m

    KongUser kongUser = resp.getBody();
    kongUser.setKey(kongService.createKeyForUser(kongUser.getUserName()));

    if (kongUser.getKey() == null) {
        return new ResponseEntity<>("User was created but key generation failed!",
                HttpStatus.FAILED_DEPENDENCY);
    }

    this.kongUsers.getUsers().add(kongUser);
    return new ResponseEntity(kongUser.getKey().getKey(), HttpStatus.OK);
}

From source file:org.zalando.github.spring.TeamsTemplate.java

@Override
public Team updateTeam(long teamId, TeamRequest teamRequest) {
    Map<String, Object> uriVariables = new HashMap<>();
    uriVariables.put("teamid", teamId);

    RequestEntity<TeamRequest> entity = RequestEntity.patch(buildUri("/teams/{teamid}", uriVariables))
            .contentType(MediaType.APPLICATION_JSON).body(teamRequest);

    return getRestOperations().exchange(entity, Team.class).getBody();
}