org.springframework.http.HttpHeaders.LOCATION

Here are the examples of the java api org.springframework.http.HttpHeaders.LOCATION taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

71 Examples 7

19 Source : DyUrlPluginExecutor.java
with GNU Affero General Public License v3.0
from xggz

public String getInfo(String info) {
    if (!StrUtil.contains(info, "https://v.douyin.com")) {
        return "请重试,并发送正确的抖音分享链接";
    }
    String url = ReUtil.findAll("https://v.douyin.com/(.*?)/", info, 0).get(0);
    if (url != null) {
        String src = HttpRequest.get(url).header(HttpHeaders.USER_AGENT, USER_AGENT).execute().body();
        String id = ReUtil.findAll("video/(.*?)/", src, 1).get(0).trim();
        if (id != null) {
            String jk = "https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=" + id;
            String json = HttpRequest.get(jk).execute().body();
            String rel_url = ReUtil.findAll("play_addr\":\\{\"uri\":\"(.*?)\",\"url_list\":\\[\"(.*?)\"", json, 2).get(0);
            if (rel_url != null) {
                String video_url = rel_url.replaceAll("playwm", "play");
                HttpResponse response = HttpRequest.get(video_url).header(HttpHeaders.USER_AGENT, USER_AGENT).execute();
                if (HttpStatus.HTTP_MOVED_TEMP == response.getStatus()) {
                    return StrUtil.format("视频下载地址为:【{}】,请复制到浏览器进行下载", response.header(HttpHeaders.LOCATION));
                }
            } else {
                return "获取真正的视频链接失败!";
            }
        } else {
            return "获取视频id失败!";
        }
    }
    return "提取视频链接失败!";
}

19 Source : MockHttpServletResponse.java
with MIT License
from Vip-Augus

@Nullable
public String getRedirectedUrl() {
    return getHeader(HttpHeaders.LOCATION);
}

19 Source : RelativeRedirectResponseWrapper.java
with MIT License
from Vip-Augus

@Override
public void sendRedirect(String location) {
    setStatus(this.redirectStatus.value());
    setHeader(HttpHeaders.LOCATION, location);
}

19 Source : XmlContentTests.java
with MIT License
from Vip-Augus

@Test
public void postXmlContent() {
    String content = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<person><name>John</name></person>";
    this.client.post().uri("/persons").contentType(MediaType.APPLICATION_XML).syncBody(content).exchange().expectStatus().isCreated().expectHeader().valueEquals(HttpHeaders.LOCATION, "/persons/John").expectBody().isEmpty();
}

19 Source : HomeControllerTests.java
with MIT License
from PacktPublishing

// end::4[]
// tag::5[]
@Test
public void deleteImageShouldWork() {
    given(imageService.deleteImage(any())).willReturn(Mono.empty());
    webClient.delete().uri("/images/alpha.png").exchange().expectStatus().isSeeOther().expectHeader().valueEquals(HttpHeaders.LOCATION, "/");
    verify(imageService).deleteImage("alpha.png");
    verifyNoMoreInteractions(imageService);
}

19 Source : HomeControllerTests.java
with MIT License
from PacktPublishing

// end::4[]
// tag::5[]
@Test
public void deleteImageShouldWork() {
    Image alphaImage = new Image("1", "alpha.png");
    given(imageService.deleteImage(any())).willReturn(Mono.empty());
    webClient.delete().uri("/images/alpha.png").exchange().expectStatus().isSeeOther().expectHeader().valueEquals(HttpHeaders.LOCATION, "/");
    verify(imageService).deleteImage("alpha.png");
    verifyNoMoreInteractions(imageService);
}

19 Source : JLineupWebApplicationTests.java
with Apache License 2.0
from otto-de

private String startAfterRun(String location) {
    return given().when().post(location).then().replacedertThat().statusCode(ACCEPTED.value()).header(HttpHeaders.LOCATION, RegexMatcher.regex(contextPath + "/runs/[a-zA-Z0-9\\-]*")).and().extract().header(HttpHeaders.LOCATION);
}

19 Source : TeamController.java
with Apache License 2.0
from FordLabs

@PostMapping("/team/login")
@ApiOperation(value = "Logs in a user given a login request", notes = "deprecated")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = String.clreplaced) })
public ResponseEnreplacedy<String> login(@RequestBody @Valid LoginRequest team) {
    Team savedTeamEnreplacedy = teamService.login(team);
    String jwt = jwtBuilder.buildJwt(savedTeamEnreplacedy.getUri());
    HttpHeaders headers = new HttpHeaders();
    headers.add(HttpHeaders.LOCATION, savedTeamEnreplacedy.getUri());
    return new ResponseEnreplacedy<>(jwt, headers, OK);
}

19 Source : FlowableUiApplicationSecurityTest.java
with Apache License 2.0
from flowable

@Test
public void nonAuthenticatedUserShouldBeRedirectedToLogin() {
    String rootUrl = "http://localhost:" + serverPort + "/flowable-ui/";
    ResponseEnreplacedy<String> result = restTemplate.getForEnreplacedy(rootUrl, String.clreplaced);
    replacedertThat(result.getStatusCode()).as("GET app definitions").isEqualTo(HttpStatus.FOUND);
    replacedertThat(result.getHeaders().getFirst(HttpHeaders.LOCATION)).as("redirect location").isEqualTo("http://localhost:" + serverPort + "/flowable-ui/idm/#/login");
}

19 Source : ProductApiController.java
with Apache License 2.0
from callistaenterprise

@PostMapping(value = "/products", consumes = { ContentType.PRODUCT_1_0 }, produces = { ContentType.PRODUCT_1_0 })
public ResponseEnreplacedy<ProductValue> createProduct(@Valid @RequestBody ProductValue productValue) {
    ProductValue product = productService.createProduct(productValue);
    MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
    headers.add(HttpHeaders.LOCATION, "/products/" + product.getProductId());
    return new ResponseEnreplacedy<>(product, headers, HttpStatus.CREATED);
}

18 Source : ControllerEndpointHandlerMappingIntegrationTests.java
with Apache License 2.0
from yuanmabiji

@Test
public void post() {
    this.contextRunner.run(withWebTestClient((webTestClient) -> webTestClient.post().uri("/actuator/example/two").syncBody(Collections.singletonMap("id", "test")).exchange().expectStatus().isCreated().expectHeader().valueEquals(HttpHeaders.LOCATION, "/example/test")));
}

18 Source : InviteEndpointTest.java
with GNU Affero General Public License v3.0
from wolfiabot

@Test
void whenGet_redirects() throws Exception {
    mockMvc.perform(get("/invite")).andExpect(header().exists(HttpHeaders.LOCATION)).andExpect(isProperInviteUrl());
}

18 Source : InviteEndpointTest.java
with GNU Affero General Public License v3.0
from wolfiabot

private ResultMatcher hasRedirectUrl(String redirectUrl) {
    return result -> {
        String location = result.getResponse().getHeader(HttpHeaders.LOCATION);
        replacedertThat(location).isNotNull();
        HttpUrl httpUrl = HttpUrl.get(location);
        replacedertThat(httpUrl).isNotNull();
        replacedertThat(httpUrl.queryParameter("redirect_uri")).isEqualTo(redirectUrl);
    };
}

18 Source : InviteEndpointTest.java
with GNU Affero General Public License v3.0
from wolfiabot

private ResultMatcher hasGuildId(long guildId) {
    return result -> {
        String location = result.getResponse().getHeader(HttpHeaders.LOCATION);
        replacedertThat(location).isNotNull();
        HttpUrl httpUrl = HttpUrl.get(location);
        replacedertThat(httpUrl).isNotNull();
        replacedertThat(httpUrl.queryParameter("guild_id")).isEqualTo(Long.toString(guildId));
    };
}

18 Source : RelativeRedirectFilterTests.java
with MIT License
from Vip-Augus

@Test
public void doFilterSendRedirectWhenDefaultsThenLocationAnd303() throws Exception {
    String location = "/foo";
    sendRedirect(location);
    InOrder inOrder = Mockito.inOrder(this.response);
    inOrder.verify(this.response).setStatus(HttpStatus.SEE_OTHER.value());
    inOrder.verify(this.response).setHeader(HttpHeaders.LOCATION, location);
}

18 Source : RelativeRedirectFilterTests.java
with MIT License
from Vip-Augus

@Test
public void doFilterSendRedirectWhenCustomSendRedirectHttpStatusThenLocationAnd301() throws Exception {
    String location = "/foo";
    HttpStatus status = HttpStatus.MOVED_PERMANENTLY;
    this.filter.setRedirectStatus(status);
    sendRedirect(location);
    InOrder inOrder = Mockito.inOrder(this.response);
    inOrder.verify(this.response).setStatus(status.value());
    inOrder.verify(this.response).setHeader(HttpHeaders.LOCATION, location);
}

18 Source : MockHttpServletResponse.java
with MIT License
from Vip-Augus

@Override
public void sendRedirect(String url) throws IOException {
    replacedert.state(!isCommitted(), "Cannot send redirect - response is already committed");
    replacedert.notNull(url, "Redirect URL must not be null");
    setHeader(HttpHeaders.LOCATION, url);
    setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
    setCommitted(true);
}

18 Source : JsonApiWebMvcIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_patch_movie() throws Exception {
    String input = readFile("patchMovie.json");
    this.mockMvc.perform(patch("/movies/1").content(input).contentType(JSON_API)).andExpect(status().isNoContent()).andExpect(header().stringValues(HttpHeaders.LOCATION, "http://localhost/movies/1"));
    String movieJson = this.mockMvc.perform(get("/movies/1").accept(JSON_API)).andExpect(status().isOk()).andReturn().getResponse().getContentreplacedtring();
    compareWithFile(movieJson, "patchedMovie.json");
}

18 Source : JsonApiWebMvcIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_create_new_movie_with_relationships() throws Exception {
    String input = readFile("postMovieWithTwoRelationships.json");
    this.mockMvc.perform(post("/moviesWithDirectors").content(input).contentType(JSON_API)).andExpect(status().isCreated()).andExpect(header().stringValues(HttpHeaders.LOCATION, "http://localhost/movies/3"));
    String movieJson = this.mockMvc.perform(get("/moviesWithDirectors/3").accept(JSON_API)).andExpect(status().isOk()).andReturn().getResponse().getContentreplacedtring();
    compareWithFile(movieJson, "movieCreatedWithDirectors.json");
}

18 Source : JsonApiWebMvcIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_create_new_movie() throws Exception {
    String input = readFile("postMovie.json");
    this.mockMvc.perform(post("/movies").content(input).contentType(JSON_API)).andExpect(status().isCreated()).andExpect(header().stringValues(HttpHeaders.LOCATION, "http://localhost/movies/3"));
    String movieJson = this.mockMvc.perform(get("/movies/3").accept(JSON_API)).andExpect(status().isOk()).andReturn().getResponse().getContentreplacedtring();
    compareWithFile(movieJson, "movieCreated.json");
}

18 Source : JsonApiWebMvcIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_create_new_movie_with_rating() throws Exception {
    String input = readFile("postMovieWithRating.json");
    this.mockMvc.perform(post("/moviesWithPolymorphy").content(input).contentType(JSON_API)).andExpect(status().isCreated()).andExpect(header().stringValues(HttpHeaders.LOCATION, "http://localhost/movies/3"));
    String movieJson = this.mockMvc.perform(get("/moviesWithDirectors/3").accept(JSON_API)).andExpect(status().isOk()).andReturn().getResponse().getContentreplacedtring();
    compareWithFile(movieJson, "polymorphicMovie.json");
}

18 Source : JsonApiWebMvcIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_create_new_movie_with_single_relationship() throws Exception {
    String input = readFile("postMovieWithOneRelationship.json");
    this.mockMvc.perform(post("/moviesWithSingleDirector").content(input).contentType(JSON_API)).andExpect(status().isCreated()).andExpect(header().stringValues(HttpHeaders.LOCATION, "http://localhost/movies/3"));
    String movieJson = this.mockMvc.perform(get("/moviesWithDirectors/3").accept(JSON_API)).andExpect(status().isOk()).andReturn().getResponse().getContentreplacedtring();
    compareWithFile(movieJson, "movieCreatedWithSingleDirector.json");
}

18 Source : InventoryControllerTest.java
with Apache License 2.0
from teixeira-fernando

@Test
@DisplayName("GET /product/{id} - Success")
void testGetProductByIdSuccess() throws Exception {
    // Arrange: Setup our mock
    String id = "12345";
    String productName = "Samsung TV Led";
    Integer quanreplacedy = 50;
    Category category = Category.ELECTRONICS;
    Product mockProduct = new Product(id, productName, quanreplacedy, category);
    doReturn(mockProduct).when(service).findById(id);
    // Execute the GET request
    mockMvc.perform(get("/product/{id}", id)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(header().string(HttpHeaders.LOCATION, "/product/" + id)).andExpect(jsonPath("$.id", is(id))).andExpect(jsonPath("$.name", is(productName))).andExpect(jsonPath("$.quanreplacedy", is(quanreplacedy))).andExpect(jsonPath("$.category", is(category.toString())));
}

18 Source : InventoryControllerTest.java
with Apache License 2.0
from teixeira-fernando

@Test
@DisplayName("POST /product - Success")
void testCreateProductSuccess() throws Exception {
    // Arrange: Setup our mock
    String id = "12345";
    String productName = "Dark Souls 3";
    Integer quanreplacedy = 20;
    Category category = Category.VIDEOGAMES;
    Product mockProduct = new Product(id, productName, quanreplacedy, category);
    doReturn(mockProduct).when(service).createProduct(any());
    // Execute the POST request
    mockMvc.perform(post("/product").contentType(MediaType.APPLICATION_JSON).content(new ObjectMapper().writeValuereplacedtring(mockProduct))).andExpect(status().isCreated()).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(header().string(HttpHeaders.LOCATION, "/product/" + id)).andExpect(jsonPath("$.id", is(id))).andExpect(jsonPath("$.name", is(productName))).andExpect(jsonPath("$.quanreplacedy", is(quanreplacedy))).andExpect(jsonPath("$.category", is(category.toString())));
}

18 Source : RewriteLocationResponseHeaderGatewayFilterFactoryUnitTests.java
with Apache License 2.0
from spring-cloud

private void setupTest(String location, String host, String path) {
    Mockito.when(responseHeaders.getFirst(HttpHeaders.LOCATION)).thenReturn(location);
    Mockito.when(requestHeaders.getFirst(HttpHeaders.HOST)).thenReturn(host);
    uri = URI.create("http://" + host + path);
    Mockito.when(request.getURI()).thenReturn(uri);
}

18 Source : RedirectToGatewayFilterFactoryTests.java
with Apache License 2.0
from spring-cloud

@Test
public void redirectToFilterWorks() {
    testClient.get().uri("/").header("Host", "www.redirectto.org").exchange().expectStatus().isEqualTo(HttpStatus.FOUND).expectHeader().valueEquals(HttpHeaders.LOCATION, "https://example.org");
}

18 Source : RedirectToGatewayFilterFactoryTests.java
with Apache License 2.0
from spring-cloud

@Test
public void redirectToRelativeUrlFilterWorks() {
    testClient.get().uri("/").header("Host", "www.relativeredirect.org").exchange().expectStatus().isEqualTo(HttpStatus.FOUND).expectHeader().valueEquals(HttpHeaders.LOCATION, "/index.html#/customers");
}

18 Source : XmlContentTests.java
with Apache License 2.0
from SourceHot

@Test
public void postXmlContent() {
    String content = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<person><name>John</name></person>";
    this.client.post().uri("/persons").contentType(MediaType.APPLICATION_XML).bodyValue(content).exchange().expectStatus().isCreated().expectHeader().valueEquals(HttpHeaders.LOCATION, "/persons/John").expectBody().isEmpty();
}

18 Source : JLineupWebApplicationTests.java
with Apache License 2.0
from otto-de

private String startBeforeRun(JobConfig jobConfig) {
    return given().body(jobConfig).contentType(ContentType.JSON).when().post(contextPath + "/runs").then().replacedertThat().statusCode(ACCEPTED.value()).header(HttpHeaders.LOCATION, RegexMatcher.regex(contextPath + "/runs/[a-zA-Z0-9\\-]*")).and().extract().header(HttpHeaders.LOCATION);
}

18 Source : ResultVo.java
with Apache License 2.0
from java110

/**
 * 页面跳转
 *
 * @param url
 * @return
 */
public static ResponseEnreplacedy<String> redirectPage(String url) {
    HttpHeaders headers = new HttpHeaders();
    headers.add(HttpHeaders.LOCATION, url);
    ResponseEnreplacedy<String> responseEnreplacedy = new ResponseEnreplacedy<String>("", headers, HttpStatus.FOUND);
    return responseEnreplacedy;
}

18 Source : ClaimEndpoint.java
with Apache License 2.0
from HL7-DaVinci

/**
 * The submitOperation function for both json and xml
 *
 * @param body        - the body of the post request.
 * @param requestType - the RequestType of the request.
 * @return - claimResponse response
 */
private ResponseEnreplacedy<String> submitOperation(String body, RequestType requestType, HttpServletRequest request) {
    logger.info("POST /Claim/$submit fhir+" + requestType.name());
    App.setBaseUrl(Endpoint.getServiceBaseUrl(request));
    if (!AuthEndpoint.validateAccessToken(request))
        return ResponseEnreplacedy.status(HttpStatus.UNAUTHORIZED).contentType(MediaType.APPLICATION_JSON).body("{ error: \"Invalid access token. Make sure to use Authorization: Bearer (token)\" }");
    String id = null;
    String patient = null;
    HttpStatus status = HttpStatus.BAD_REQUEST;
    String formattedData = null;
    AuditEventOutcome auditOutcome = AuditEventOutcome.MINOR_FAILURE;
    try {
        IParser parser = requestType == RequestType.JSON ? App.getFhirContext().newJsonParser() : App.getFhirContext().newXmlParser();
        IBaseResource resource = parser.parseResource(body);
        if (resource instanceof Bundle) {
            Bundle bundle = (Bundle) resource;
            if (bundle.hasEntry() && (bundle.getEntry().size() >= 1) && bundle.getEntry().get(0).hasResource() && bundle.getEntry().get(0).getResource().getResourceType() == ResourceType.Claim) {
                Bundle responseBundle = processBundle(bundle);
                if (responseBundle == null) {
                    // Failed processing bundle...
                    OperationOutcome error = FhirUtils.buildOutcome(IssueSeverity.ERROR, IssueType.INVALID, PROCESS_FAILED);
                    formattedData = FhirUtils.getFormattedData(error, requestType);
                    logger.severe("ClaimEndpoint::SubmitOperation:Failed to process Bundle:" + bundle.getId());
                    auditOutcome = AuditEventOutcome.SERIOUS_FAILURE;
                } else {
                    ClaimResponse response = FhirUtils.getClaimResponseFromResponseBundle(responseBundle);
                    id = FhirUtils.getIdFromResource(response);
                    patient = FhirUtils.getPatientIdentifierFromBundle(responseBundle);
                    formattedData = FhirUtils.getFormattedData(responseBundle, requestType);
                    status = HttpStatus.CREATED;
                    auditOutcome = AuditEventOutcome.SUCCESS;
                }
            } else {
                // Claim is required...
                OperationOutcome error = FhirUtils.buildOutcome(IssueSeverity.ERROR, IssueType.INVALID, REQUIRES_BUNDLE);
                formattedData = FhirUtils.getFormattedData(error, requestType);
                logger.severe("ClaimEndpoint::SubmitOperation:First bundle entry is not a PASClaim");
            }
        } else {
            // Bundle is required...
            OperationOutcome error = FhirUtils.buildOutcome(IssueSeverity.ERROR, IssueType.INVALID, REQUIRES_BUNDLE);
            formattedData = FhirUtils.getFormattedData(error, requestType);
            logger.severe("ClaimEndpoint::SubmitOperation:Body is not a Bundle");
        }
    } catch (Exception e) {
        // The submission failed so spectacularly that we need to
        // catch an exception and send back an error message...
        OperationOutcome error = FhirUtils.buildOutcome(IssueSeverity.FATAL, IssueType.STRUCTURE, e.getMessage());
        formattedData = FhirUtils.getFormattedData(error, requestType);
        auditOutcome = AuditEventOutcome.SERIOUS_FAILURE;
    }
    new Audit(AuditEventType.REST, AuditEventAction.E, auditOutcome, null, request, "POST /Claim/$submit");
    MediaType contentType = requestType == RequestType.JSON ? MediaType.APPLICATION_JSON : MediaType.APPLICATION_XML;
    return ResponseEnreplacedy.status(status).contentType(contentType).header(HttpHeaders.LOCATION, App.getBaseUrl() + "/ClaimResponse?identifier=" + id + "&patient.identifier=" + patient).body(formattedData);
}

18 Source : PostControllerMockMvcTest.java
with GNU General Public License v3.0
from hantsy

@Test
@WithMockUser
public void createPostWithMockUser() throws Exception {
    Post _data = Post.builder().replacedle("my first post").content("my content of my post").build();
    given(this.postService.createPost(any(PostForm.clreplaced))).willReturn(_data);
    MvcResult result = this.mockMvc.perform(post("/posts").content(objectMapper.writeValuereplacedtring(PostForm.builder().replacedle("my first post").content("my content of my post").build())).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated()).andExpect(header().string(HttpHeaders.LOCATION, containsString("/posts"))).andReturn();
    log.debug("mvc result::" + result.getResponse().getContentreplacedtring());
    verify(this.postService, times(1)).createPost(any(PostForm.clreplaced));
}

18 Source : CommandsControllerTests.java
with GNU General Public License v3.0
from dmfrey

@Test
public void testCreateBoard() throws Exception {
    UUID boardUuid = UUID.randomUUID();
    when(this.service.createBoard()).thenReturn(boardUuid);
    this.mockMvc.perform(post("/boards/").param("name", "Test Board")).andDo(print()).andExpect(status().isCreated()).andExpect(header().string(HttpHeaders.LOCATION, is(equalTo("http://localhost/boards/" + boardUuid.toString()))));
    verify(this.service, times(1)).createBoard();
}

18 Source : CommandsControllerTests.java
with GNU General Public License v3.0
from dmfrey

@Test
public void testCreateStoryOnBoard() throws Exception {
    UUID boardUuid = UUID.randomUUID();
    UUID storyUuid = UUID.randomUUID();
    when(this.service.addStory(any(UUID.clreplaced), anyString())).thenReturn(storyUuid);
    this.mockMvc.perform(post("/boards/{boardUuid}/stories", boardUuid).param("name", "Test Story")).andDo(print()).andExpect(status().isCreated()).andExpect(header().string(HttpHeaders.LOCATION, is(equalTo("http://localhost/boards/" + boardUuid.toString() + "/stories/" + storyUuid.toString()))));
    verify(this.service, times(1)).addStory(any(UUID.clreplaced), anyString());
}

18 Source : ApiControllerTests.java
with GNU General Public License v3.0
from dmfrey

@Test
public void testCreateStoryOnBoard() throws Exception {
    UUID boardUuid = UUID.randomUUID();
    UUID storyUuid = UUID.randomUUID();
    when(this.service.addStory(any(UUID.clreplaced), anyString())).thenReturn(ResponseEnreplacedy.created(URI.create("http://localhost/boards/" + boardUuid.toString() + "/stories/" + storyUuid.toString())).build());
    this.mockMvc.perform(post("/boards/{boardUuid}/stories", boardUuid).param("name", "Test Story")).andDo(print()).andExpect(status().isCreated()).andExpect(header().string(HttpHeaders.LOCATION, is(equalTo("http://localhost/boards/" + boardUuid.toString() + "/stories/" + storyUuid.toString())))).andDo(doreplacedent("add-story", pathParameters(parameterWithName("boardUuid").description("The unique id of the board")), requestParameters(parameterWithName("name").description("The new story to add to the Board"))));
    verify(this.service, times(1)).addStory(any(UUID.clreplaced), anyString());
}

18 Source : ApiControllerTests.java
with GNU General Public License v3.0
from dmfrey

@Test
public void testCreateBoard() throws Exception {
    UUID boardUuid = UUID.randomUUID();
    when(this.service.createBoard()).thenReturn(ResponseEnreplacedy.created(URI.create("http://localhost/boards/" + boardUuid.toString())).build());
    this.mockMvc.perform(post("/boards")).andDo(print()).andExpect(status().isCreated()).andExpect(header().string(HttpHeaders.LOCATION, is(equalTo("http://localhost/boards/" + boardUuid.toString())))).andDo(doreplacedent("create-board"));
    verify(this.service, times(1)).createBoard();
}

18 Source : BoardServiceTests.java
with GNU General Public License v3.0
from dmfrey

@Test
public void testCreateBoard() throws Exception {
    UUID boardUuid = UUID.randomUUID();
    when(this.commandClient.createBoard()).thenReturn(ResponseEnreplacedy.created(URI.create("http://localhost/boards/" + boardUuid.toString())).build());
    ResponseEnreplacedy response = this.service.createBoard();
    replacedertThat(response.getStatusCode()).isEqualTo(HttpStatus.CREATED);
    replacedertThat(response.getHeaders()).containsKey(HttpHeaders.LOCATION).containsValue(singletonList("http://localhost/boards/" + boardUuid.toString()));
    verify(this.commandClient, times(1)).createBoard();
}

18 Source : SignOutControllerTest.java
with MIT License
from cloudogu

@Test
public void testLogoutWithoutSession() {
    ResponseEnreplacedy<Void> enreplacedy = controller.logout(request);
    replacedertThat(enreplacedy.getStatusCode()).isEqualTo(HttpStatus.TEMPORARY_REDIRECT);
    replacedertThat(enreplacedy.getHeaders().get(HttpHeaders.LOCATION)).contains("/cas/logout");
}

18 Source : AjaxAwareAuthenticationRedirectStrategyTest.java
with MIT License
from cloudogu

@Test
public void testRedirectWithAjaxRequest() throws IOException {
    when(request.getHeader(AJAX_HEADER)).thenReturn(AJAX_HEADER_VALUE);
    redirectStrategy.redirect(request, response, REDIRECT_TARGET);
    verify(response).setStatus(HttpStatus.UNAUTHORIZED.value());
    verify(response).setHeader(HttpHeaders.LOCATION, REDIRECT_TARGET);
}

18 Source : ModifyResponseHeaderLocationGatewayFilterFactory.java
with MIT License
from botorabi

@Override
public GatewayFilter apply(NameConfig config) {
    return (exchange, chain) -> chain.filter(exchange).then(Mono.fromRunnable(() -> {
        HttpHeaders headers = exchange.getResponse().getHeaders();
        final String locationUri = headers.getFirst(HttpHeaders.LOCATION);
        if (locationUri != null) {
            if (locationUri.isEmpty() || locationUri.equals("/")) {
                headers.set(HttpHeaders.LOCATION, config.getName());
            }
        }
    }));
}

18 Source : ConsentService.java
with Apache License 2.0
from adorsys

@Transactional
public String createConsentForAccountsAndTransactions(String bankId) {
    UUID redirectCode = UUID.randomUUID();
    UUID serviceSessionId = UUID.randomUUID();
    ResponseEnreplacedy<TransactionsResponse> apiResponse = aisApi.getTransactionsWithoutAccountId(bankingConfig.getDataProtectionPreplacedword(), bankingConfig.getUserId(), apiConfig.getRedirectOkUri(redirectCode.toString()), apiConfig.getRedirectNokUri(), UUID.randomUUID(), null, null, null, bankId, serviceSessionId, null, null, null, "both", false);
    if (apiResponse.getStatusCode() == HttpStatus.ACCEPTED) {
        RedirectState redirectState = new RedirectState();
        redirectState.setId(redirectCode);
        redirectState.setServiceSessionId(serviceSessionId);
        redirectState.setBankId(bankId);
        redirectState.setAuthorizationSessionId(apiResponse.getHeaders().get("Authorization-Session-ID").get(0));
        redirectStateRepository.save(redirectState);
        return apiResponse.getHeaders().get(HttpHeaders.LOCATION).get(0);
    }
    throw new IllegalStateException("Bad API return code: " + apiResponse.getStatusCode());
}

17 Source : JsonApiWebFluxIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_create_new_movie_with_relationships() throws Exception {
    String input = readFile("postMovieWithTwoRelationships.json");
    this.testClient.post().uri("http://localhost/moviesWithDirectors").contentType(JSON_API).bodyValue(input).exchange().expectStatus().isCreated().expectHeader().valueEquals(HttpHeaders.LOCATION, "http://localhost/movies/3");
    EnreplacedyExchangeResult<String> result = this.testClient.get().uri("http://localhost/moviesWithDirectors/3").accept(JSON_API).exchange().expectStatus().isOk().expectHeader().contentType(JSON_API).expectBody(String.clreplaced).returnResult();
    compareWithFile(result.getResponseBody(), "movieCreatedWithDirectors.json");
}

17 Source : JsonApiWebFluxIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_create_new_movie() throws Exception {
    String input = readFile("postMovie.json");
    this.testClient.post().uri("http://localhost/movies").contentType(JSON_API).bodyValue(input).exchange().expectStatus().isCreated().expectHeader().valueEquals(HttpHeaders.LOCATION, "http://localhost/movies/3");
    EnreplacedyExchangeResult<String> result = this.testClient.get().uri("http://localhost/movies/3").accept(JSON_API).exchange().expectStatus().isOk().expectHeader().contentType(JSON_API).expectBody(String.clreplaced).returnResult();
    compareWithFile(result.getResponseBody(), "movieCreated.json");
}

17 Source : JsonApiWebFluxIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_patch_movie() throws Exception {
    String input = readFile("patchMovie.json");
    this.testClient.patch().uri("http://localhost/movies/1").contentType(JSON_API).bodyValue(input).exchange().expectStatus().isNoContent().expectHeader().valueEquals(HttpHeaders.LOCATION, "http://localhost/movies/1");
    EnreplacedyExchangeResult<String> result = this.testClient.get().uri("http://localhost/movies/1").accept(JSON_API).exchange().expectStatus().isOk().expectHeader().contentType(JSON_API).expectBody(String.clreplaced).returnResult();
    compareWithFile(result.getResponseBody(), "patchedMovie.json");
}

17 Source : TravelGatewayApplicationTest.java
with MIT License
from timtebeek

@Test
void testGetIndexAnonymously() throws Exception {
    client.get().uri("/").exchange().expectStatus().is3xxRedirection().expectHeader().value(HttpHeaders.LOCATION, is("/oauth2/authorization/keycloak"));
}

17 Source : WebSecurityConfig.java
with Mozilla Public License 2.0
from SafeExamBrowser

@RequestMapping("/error")
public void handleError(final HttpServletResponse response) throws IOException {
    // response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
    response.setHeader(HttpHeaders.LOCATION, this.guiRedirect);
    response.flushBuffer();
}

17 Source : CaseService.java
with GNU General Public License v3.0
from JUGIstanbul

public ResponseEnreplacedy createCase(Case aCase) {
    caseValidator.validate(aCase);
    Case saveCase = caseRepository.save(aCase);
    HttpHeaders headers = new HttpHeaders();
    headers.add(HttpHeaders.LOCATION, "/api/v1/cases/" + saveCase.getId());
    return new ResponseEnreplacedy<>(headers, HttpStatus.CREATED);
}

17 Source : TreatmentController.java
with GNU General Public License v3.0
from JUGIstanbul

@PostMapping
public ResponseEnreplacedy save(HttpServletRequest httpServletRequest, @RequestBody Treatment treatment) {
    Treatment savedTreatment = treatmentService.save(treatment);
    HttpHeaders headers = new HttpHeaders();
    headers.add(HttpHeaders.LOCATION, UrlHelper.getFullRequestUrl(httpServletRequest) + "/" + savedTreatment.getId());
    return new ResponseEnreplacedy<>(headers, HttpStatus.CREATED);
}

17 Source : MedicineController.java
with GNU General Public License v3.0
from JUGIstanbul

@PostMapping()
public ResponseEnreplacedy save(HttpServletRequest httpServletRequest, @RequestBody Medicine medicine) {
    Medicine savedTreatment = medicineService.save(medicine);
    HttpHeaders headers = new HttpHeaders();
    headers.add(HttpHeaders.LOCATION, UrlHelper.getFullRequestUrl(httpServletRequest) + "/" + savedTreatment.getId());
    return new ResponseEnreplacedy<>(headers, HttpStatus.CREATED);
}

17 Source : IdentitiesEndpoint_Creating_Test.java
with MIT License
from InnovateUKGitHub

@Test
public void createNewIdenreplacedySuccessfully() throws Exception {
    final String uuid = "31a05805-c748-492d-a862-c047102516be";
    final String email = "[email protected]";
    final String preplacedword = "P@55word1357";
    setupSuccessfullyCreatedIdenreplacedy(uuid, preplacedword, email);
    mockMvc.perform(MockMvcRequestBuilders.post("/idenreplacedies").contentType(MediaType.APPLICATION_JSON_UTF8).content(convertToJson(new NewIdenreplacedy(email, preplacedword)))).andExpect(status().isCreated()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(jsonPath("$.uuid", is(equalTo(uuid)))).andExpect(jsonPath("$.email", is(equalTo(email)))).andExpect(header().string(HttpHeaders.LOCATION, is(equalTo("/idenreplacedies/" + uuid))));
    verify(createService).createIdenreplacedy(email, preplacedword);
    verifyNoMoreInteractions(createService, deleteService, findService, updateService, activateUserService, userAccountLockoutService);
}

See More Examples