All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mattressframework.test.model.ValidSimpleResourceBean Maven / Gradle / Ivy

/*
 * Copyright 2007-2008, Josh Devins.
 *
 * 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.mattressframework.test.model;

import org.mattressframework.api.annotations.HeaderParam;
import org.mattressframework.api.annotations.HttpContext;
import org.mattressframework.api.annotations.HttpEntity;
import org.mattressframework.api.annotations.HttpResource;
import org.mattressframework.api.annotations.HttpResourceMethod;
import org.mattressframework.api.annotations.InjectedParam;
import org.mattressframework.api.annotations.Path;
import org.mattressframework.api.annotations.PathParam;
import org.mattressframework.api.annotations.QueryParam;
import org.mattressframework.api.http.HttpMethod;
import org.mattressframework.api.http.HttpStatus;
import org.mattressframework.api.http.Response;
import org.mattressframework.test.TestConstants;

@HttpResource
@Path("validSimpleResourceBean")
public class ValidSimpleResourceBean {

    public static final String INJECT_PARAM_BEAN_NAME = "bean";

    public static final String TEST_CONTEXT_VARIABLE_METHOD =
            "contextVariableMethod";

    public static final String TEST_ENTITY_VARIABLE_METHOD =
            "entityVariableMethod";

    public static final String TEST_HEADER_VARIABLE_METHOD =
            "headerVariableMethod";

    public static final String TEST_PATH_VARIABLE_METHOD = "pathVariableMethod";

    public static final String TEST_QUERY_VARIABLE_METHOD =
            "queryVariableMethod";

    public static final String TEST_SIMPLE_METHOD = "simpleMethod";

    public static final String TEST_METHOD = "method";

    private static final String TEST_INJECTED_VARIABLE_METHOD =
            "injectedVariableMethod";

    @HttpResourceMethod
    @Path(TEST_CONTEXT_VARIABLE_METHOD)
    public void contextVariableMethod(@HttpContext
    final Response response) {
        response.setStatus(HttpStatus.SUCCESS_CREATED);
    }

    @HttpResourceMethod(HttpMethod.POST)
    @Path(TEST_ENTITY_VARIABLE_METHOD)
    public String entityVariableMethod(@HttpEntity
    final String entityVariable) {
        return entityVariable;
    }

    @HttpResourceMethod
    @Path(TEST_HEADER_VARIABLE_METHOD)
    public String headerVariableMethod(@HeaderParam(TestConstants.TEST_STRING)
    final String headerVariable) {
        return headerVariable;
    }

    @HttpResourceMethod
    @Path(TEST_INJECTED_VARIABLE_METHOD)
    public String injectedVariableMethod(@InjectedParam(INJECT_PARAM_BEAN_NAME)
    final String injectedVariable) {
        return injectedVariable;
    }

    public void method() {
    }

    @HttpResourceMethod
    @Path(TEST_PATH_VARIABLE_METHOD + "/{" + TestConstants.TEST_STRING + "}")
    public String pathVariableMethod(@PathParam(TestConstants.TEST_STRING)
    final String pathVariable) {
        return pathVariable;
    }

    @HttpResourceMethod
    @Path(TEST_QUERY_VARIABLE_METHOD)
    public String queryVariableMethod(@QueryParam(TestConstants.TEST_STRING)
    final String queryVariable) {
        return queryVariable;
    }

    @HttpResourceMethod
    @Path(TEST_SIMPLE_METHOD)
    public void simpleMethod() {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy