<commit_before>/*
 * =============================================================================
 * 
 *   Copyright (c) 2011-2016, The THYMELEAF team (http://www.thymeleaf.org)
 * 
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 * 
 * =============================================================================
 */
package org.thymeleaf.spring5.reactive.exchange;

import java.security.Principal;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.util.MultiValueMap;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebSession;
import reactor.core.publisher.Mono;

public final class TestingServerWebExchange implements ServerWebExchange {

    private final TestingServerHttpRequest request;
    private final TestingServerHttpResponse response;
    private final TestingWebSession session;
    private final Map<String,Object> attributes;


    public TestingServerWebExchange(
            final String path, final Map<String,List<String>> queryParams,
            final Map<String,Object> requestAttributes, final Map<String,Object> sessionAttributes) {
        super();
        this.request = new TestingServerHttpRequest(path, queryParams);
        this.response = new TestingServerHttpResponse();
        this.session = new TestingWebSession(sessionAttributes);
        this.attributes = requestAttributes;
    }



    @Override
    public ServerHttpRequest getRequest() {
        return this.request;
    }

    @Override
    public ServerHttpResponse getResponse() {
        return this.response;
    }

    @Override
    public Map<String, Object> getAttributes() {
        return this.attributes;
    }

    @Override
    public <T> Optional<T> getAttribute(final String s) {
        return Optional.ofNullable((T)this.attributes.get(s));
    }

    @Override
    public Mono<WebSession> getSession() {
        return Mono.just(this.session);
    }

    @Override
    public <T extends Principal> Mono<T> getPrincipal() {
        throw new UnsupportedOperationException();
    }

    @Override
    public Mono<MultiValueMap<String, String>> getFormData() {
        throw new UnsupportedOperationException();
    }

    @Override
    public Mono<MultiValueMap<String, String>> getRequestParams() {
        return Mono.just(this.request.getQueryParams());
    }

    @Override
    public boolean isNotModified() {
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean checkNotModified(final Instant instant) {
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean checkNotModified(final String s) {
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean checkNotModified(final String s, final Instant instant) {
        throw new UnsupportedOperationException();
    }

}<commit_msg>Adapted to the latest changes in the API of ServerWebExchange<commit_after>/*
 * =============================================================================
 * 
 *   Copyright (c) 2011-2016, The THYMELEAF team (http://www.thymeleaf.org)
 * 
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 * 
 * =============================================================================
 */
package org.thymeleaf.spring5.reactive.exchange;

import java.security.Principal;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import org.springframework.http.codec.multipart.Part;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.util.MultiValueMap;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebSession;
import reactor.core.publisher.Mono;

public final class TestingServerWebExchange implements ServerWebExchange {

    private final TestingServerHttpRequest request;
    private final TestingServerHttpResponse response;
    private final TestingWebSession session;
    private final Map<String,Object> attributes;


    public TestingServerWebExchange(
            final String path, final Map<String,List<String>> queryParams,
            final Map<String,Object> requestAttributes, final Map<String,Object> sessionAttributes) {
        super();
        this.request = new TestingServerHttpRequest(path, queryParams);
        this.response = new TestingServerHttpResponse();
        this.session = new TestingWebSession(sessionAttributes);
        this.attributes = requestAttributes;
    }



    @Override
    public ServerHttpRequest getRequest() {
        return this.request;
    }

    @Override
    public ServerHttpResponse getResponse() {
        return this.response;
    }

    @Override
    public Map<String, Object> getAttributes() {
        return this.attributes;
    }

    @Override
    public <T> Optional<T> getAttribute(final String s) {
        return Optional.ofNullable((T)this.attributes.get(s));
    }

    @Override
    public Mono<WebSession> getSession() {
        return Mono.just(this.session);
    }

    @Override
    public <T extends Principal> Mono<T> getPrincipal() {
        throw new UnsupportedOperationException();
    }

    @Override
    public Mono<MultiValueMap<String, String>> getFormData() {
        throw new UnsupportedOperationException();
    }

    @Override
    public Mono<MultiValueMap<String, Part>> getMultipartData() {
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean isNotModified() {
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean checkNotModified(final Instant instant) {
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean checkNotModified(final String s) {
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean checkNotModified(final String s, final Instant instant) {
        throw new UnsupportedOperationException();
    }

}
{'fraction_non_alphanumeric': 0.12190764156129742, 'fraction_numerical': 0.0035733919736118747, 'mean_word_length': 3.6557901471529113, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7063261', 'n_tokens_mistral': 1885, 'n_tokens_neox': 1768, 'n_words': 522}