Java Code Examples for io.swagger.models.parameters.SerializableParameter#setName()

The following examples show how to use io.swagger.models.parameters.SerializableParameter#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractSerializableParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 6 votes vote down vote up
@Test()
public void testArrayMulti() {
    String name = "myName";
    SerializableParameter parameter = new QueryParameter();
    parameter.setName("myName");
    parameter.setType("array");
    parameter.setCollectionFormat("multi");
    List<String> paramsList = new ArrayList<>();
    paramsList.add("toto");
    paramsList.add("tutu");
    paramsList.add("titi");
    MultiMap params = MultiMap.caseInsensitiveMultiMap();
    params.add(name, paramsList);

    Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
    Assert.assertArrayEquals(paramsList.toArray(), ((List) result).toArray());
}
 
Example 2
Source File: AbstractSerializableParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testMissingRequiredParam() {
    String name = "myName";
    SerializableParameter parameter = new QueryParameter();
    parameter.setName("myName");
    parameter.setRequired(true);

    abstractSerializableParameterExtractor.extract(name, parameter,
            MultiMap.caseInsensitiveMultiMap());
}
 
Example 3
Source File: AbstractSerializableParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 5 votes vote down vote up
@Test()
public void testMissingNonRequiredParam() {
    String name = "myName";
    SerializableParameter parameter = new QueryParameter();
    parameter.setName("myName");
    parameter.setRequired(false);

    Object result = abstractSerializableParameterExtractor.extract(name, parameter,
            MultiMap.caseInsensitiveMultiMap());
    Assert.assertNull(result);
}
 
Example 4
Source File: AbstractSerializableParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testNotAllowEmptyValueWithEmptyParameter() {
    String name = "myName";
    SerializableParameter parameter = new QueryParameter();
    parameter.setName("myName");
    parameter.setAllowEmptyValue(false);
    MultiMap params = MultiMap.caseInsensitiveMultiMap();
    params.add(name, "");

    abstractSerializableParameterExtractor.extract(name, parameter, params);
}
 
Example 5
Source File: AbstractSerializableParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testNullAllowEmptyValueWithEmptyParameter() {
    String name = "myName";
    SerializableParameter parameter = new QueryParameter();
    parameter.setName("myName");
    MultiMap params = MultiMap.caseInsensitiveMultiMap();
    params.add(name, "");

    abstractSerializableParameterExtractor.extract(name, parameter, params);
}
 
Example 6
Source File: AbstractSerializableParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 5 votes vote down vote up
@Test()
public void testArray() {
    String name = "myName";
    SerializableParameter parameter = new QueryParameter();
    parameter.setName("myName");
    parameter.setType("array");
    parameter.setCollectionFormat(null);
    String param = "toto,tutu,titi";
    MultiMap params = MultiMap.caseInsensitiveMultiMap();
    params.add(name, param);

    Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
    Assert.assertArrayEquals(new String[] { "toto", "tutu", "titi" },
            ((List) result).toArray());
}
 
Example 7
Source File: AbstractSerializableParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 5 votes vote down vote up
@Test()
public void testArraySsv() {
    String name = "myName";
    SerializableParameter parameter = new QueryParameter();
    parameter.setName("myName");
    parameter.setType("array");
    parameter.setCollectionFormat("ssv");
    String param = "toto tutu titi";
    MultiMap params = MultiMap.caseInsensitiveMultiMap();
    params.add(name, param);

    Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
    Assert.assertArrayEquals(new String[] { "toto", "tutu", "titi" },
            ((List) result).toArray());
}
 
Example 8
Source File: AbstractSerializableParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 5 votes vote down vote up
@Test()
public void testArrayCsv() {
    String name = "myName";
    SerializableParameter parameter = new QueryParameter();
    parameter.setName("myName");
    parameter.setType("array");
    parameter.setCollectionFormat("csv");
    String param = "toto,tutu,titi";
    MultiMap params = MultiMap.caseInsensitiveMultiMap();
    params.add(name, param);

    Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
    Assert.assertArrayEquals(new String[] { "toto", "tutu", "titi" },
            ((List) result).toArray());
}
 
Example 9
Source File: AbstractSerializableParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 5 votes vote down vote up
@Test()
public void testArrayTsv() {
    String name = "myName";
    SerializableParameter parameter = new QueryParameter();
    parameter.setName("myName");
    parameter.setType("array");
    parameter.setCollectionFormat("tsv");
    String param = "toto\ttutu\ttiti";
    MultiMap params = MultiMap.caseInsensitiveMultiMap();
    params.add(name, param);

    Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
    Assert.assertArrayEquals(new String[] { "toto", "tutu", "titi" },
            ((List) result).toArray());
}
 
Example 10
Source File: AbstractSerializableParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 5 votes vote down vote up
@Test()
public void testArrayPipes() {
    String name = "myName";
    SerializableParameter parameter = new QueryParameter();
    parameter.setName("myName");
    parameter.setType("array");
    parameter.setCollectionFormat("pipes");
    String param = "toto|tutu|titi";
    MultiMap params = MultiMap.caseInsensitiveMultiMap();
    params.add(name, param);

    Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
    Assert.assertArrayEquals(new String[] { "toto", "tutu", "titi" },
            ((List) result).toArray());
}
 
Example 11
Source File: AbstractSerializableParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 5 votes vote down vote up
@Test()
public void testArrayOther() {
    String name = "myName";
    SerializableParameter parameter = new QueryParameter();
    parameter.setName("myName");
    parameter.setType("array");
    parameter.setCollectionFormat("anyOtherValue");
    String param = "toto,tutu,titi";
    MultiMap params = MultiMap.caseInsensitiveMultiMap();
    params.add(name, param);

    Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
    Assert.assertArrayEquals(new String[] { "toto", "tutu", "titi" },
            ((List) result).toArray());
}
 
Example 12
Source File: AbstractSerializableParameterExtractorTest.java    From vertx-swagger with Apache License 2.0 5 votes vote down vote up
@Test()
public void testDefault() {
    String name = "myName";
    SerializableParameter parameter = new QueryParameter();
    parameter.setName("myName");
    parameter.setType("string");
    String param = "toto";
    MultiMap params = MultiMap.caseInsensitiveMultiMap();
    params.add(name, param);

    Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
    Assert.assertEquals("toto", result);
}