Example usage for org.springframework.http ResponseEntity ok

List of usage examples for org.springframework.http ResponseEntity ok

Introduction

In this page you can find the example usage for org.springframework.http ResponseEntity ok.

Prototype

public static BodyBuilder ok() 

Source Link

Document

Create a builder with the status set to HttpStatus#OK OK .

Usage

From source file:com.consol.citrus.samples.todolist.web.TodoController.java

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public ResponseEntity deleteEntry(@PathVariable(value = "id") String id) {
    todoListService.deleteEntry(UUID.fromString(id));

    return ResponseEntity.ok().build();
}

From source file:org.lecture.controller.UserSourceContainerController.java

@RequestMapping(value = "/{id}/test-report", method = RequestMethod.GET)
public ResponseEntity<TestReportResource> getTestReport(@PathVariable String id) {
    SourceContainer container = codesubmissionRepository.findOne(id);
    TestReport report = testService.runTests(container);
    if (report.isAllPassed()) {
        nats.publish("finish-task",
                "{\"userId\":\"" + container.getUserId() + "\",\"taskId\":\"" + container.getTaskId() + "\"}");
    }//  www. ja  v a  2s  .  co m
    return ResponseEntity.ok().body(new TestReportResource(testService.runTests(container)));
}

From source file:com.intuit.karate.demo.controller.HeadersController.java

@GetMapping
public ResponseEntity getToken(HttpServletResponse response) {
    String token = UUID.randomUUID().toString();
    String time = System.currentTimeMillis() + "";
    tokens.put(token, time);//w  w w . j  a  v  a  2 s  .co m
    response.addCookie(new Cookie("time", time));
    return ResponseEntity.ok().body(token);
}

From source file:com.consol.citrus.admin.connector.WebSocketPushMessageListenerTest.java

@Test
public void testOnInboundMessage() throws Exception {
    Message inbound = new DefaultMessage("Hello Citrus!");

    reset(restTemplate, context);//from  w w  w .ja  v a 2  s  . c om
    when(restTemplate.exchange(eq("http://localhost:8080/connector/message/inbound?processId=MySampleTest"),
            eq(HttpMethod.POST), any(HttpEntity.class), eq(String.class))).thenAnswer(invocation -> {
                HttpEntity request = (HttpEntity) invocation.getArguments()[2];

                Assert.assertEquals(request.getBody().toString(), inbound.toString());

                return ResponseEntity.ok().build();
            });

    when(context.getVariables())
            .thenReturn(Collections.singletonMap(Citrus.TEST_NAME_VARIABLE, "MySampleTest"));
    when(context.getVariable(Citrus.TEST_NAME_VARIABLE)).thenReturn("MySampleTest");

    pushMessageListener.onInboundMessage(inbound, context);
    verify(restTemplate).exchange(eq("http://localhost:8080/connector/message/inbound?processId=MySampleTest"),
            eq(HttpMethod.POST), any(HttpEntity.class), eq(String.class));
}

From source file:de.codecentric.boot.admin.registry.StatusUpdaterTest.java

@Test
@SuppressWarnings("rawtypes")
public void test_update_statusChanged() {
    when(template.getForEntity("health", Map.class))
            .thenReturn(ResponseEntity.ok().body((Map) Collections.singletonMap("status", "UP")));

    updater.updateStatus(Application.create("foo").withId("id").withHealthUrl("health").build());

    Application app = store.find("id");

    assertThat(app.getStatusInfo().getStatus(), is("UP"));
    verify(publisher).publishEvent(argThat(isA(ClientApplicationStatusChangedEvent.class)));
}

From source file:org.lecture.controller.TestCaseController.java

/**
 * Returns a single testcase container by exercise id.
 *
 * @param taskId The id of the task the testcase container belongs to.
 * @return a Resource representing the testcase container.
 *//*  www.  j a v  a2  s  .co m*/
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<SourceContainerResource> getByExerciseId(@RequestParam("taskId") String taskId) {

    SourceContainer result = this.testRepository.findByTaskIdAndTests(taskId, true);

    return ResponseEntity.ok().header("Accept-FilePatch", "application/json;charset=UTF-8")
            .body(new SourceContainerResource(result));
}

From source file:de.document.controller.KrankheitController.java

@RequestMapping(value = "/versionnig/bearbeiten", method = { RequestMethod.POST })
public ResponseEntity versionnigBearbeiten(@RequestBody Krankheit request) {

    this.service.versionnigBearbeiten(request);
    return ResponseEntity.ok().build();
}

From source file:de.dominikschadow.javasecurity.controller.IndexController.java

@GetMapping("download")
@ResponseBody//  www  .  j a  v a 2  s .  c o m
public ResponseEntity<Resource> download(@RequestParam("name") String name) {
    try {
        String originalName = resourceService.getFileByIndirectReference(name).getName();
        String contentType = URLConnection.guessContentTypeFromName(originalName);
        Resource resource = resourceService.loadAsResource(originalName);
        return ResponseEntity.ok().contentType(MediaType.parseMediaType(contentType)).body(resource);
    } catch (MalformedURLException | AccessControlException ex) {
        log.error(ex.getMessage(), ex);
    }

    return ResponseEntity.notFound().build();
}

From source file:org.moserp.product.rest.ProductCatalogController.java

@ResponseBody
@RequestMapping(method = RequestMethod.PUT, value = "/{catalogId}/products")
public ResponseEntity<?> updateProducts(@PathVariable String catalogId, @RequestBody List<Product> products) {
    ProductCatalog productCatalog = productCatalogRepository.findOne(catalogId);
    if (productCatalog == null) {
        return ResponseEntity.notFound().build();
    }/*ww w.  ja  va2  s.co m*/
    for (Product newProduct : products) {
        Product product = productRepository.findByExternalId(newProduct.getExternalId());
        if (product == null) {
            product = newProduct;
        } else {
            domainObjectMerger.merge(newProduct, product, DomainObjectMerger.NullHandlingPolicy.IGNORE_NULLS);
        }
        product.setCatalog(productCatalog);
        productRepository.save(product);
    }
    return ResponseEntity.ok().build();
}

From source file:fi.helsinki.opintoni.web.rest.publicapi.PublicImageResource.java

@RequestMapping(value = "/avatar/{oodiPersonId}", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE)
public ResponseEntity<BufferedImage> getUserAvatarByOodiPersonId(
        @PathVariable("oodiPersonId") String oodiPersonId) throws IOException {
    return ResponseEntity.ok().headers(headersWithContentType(MediaType.IMAGE_JPEG))
            .body(userSettingsService.getUserAvatarImageByOodiPersonId(oodiPersonId));
}