Search in sources :

Example 1 with EnumConstant

use of com.spectralogic.ds3autogen.java.models.EnumConstant in project ds3_autogen by SpectraLogic.

the class BaseTypeGenerator_Test method toEnumConstantList_FullList_Test.

@Test
public void toEnumConstantList_FullList_Test() {
    final ImmutableList<Ds3EnumConstant> ds3EnumConstants = ImmutableList.of(new Ds3EnumConstant("Name1", null), new Ds3EnumConstant("Name2", null));
    final ImmutableList<EnumConstant> result = generator.toEnumConstantList(ds3EnumConstants);
    assertThat(result.size(), is(2));
    assertThat(result.get(0).getName(), is("Name1"));
    assertThat(result.get(1).getName(), is("Name2"));
}
Also used : Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) EnumConstant(com.spectralogic.ds3autogen.java.models.EnumConstant) Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) Test(org.junit.Test)

Example 2 with EnumConstant

use of com.spectralogic.ds3autogen.java.models.EnumConstant in project ds3_autogen by SpectraLogic.

the class BaseTypeGenerator_Test method toEnumConstant_Test.

@Test
public void toEnumConstant_Test() {
    final Ds3EnumConstant ds3EnumConstant = new Ds3EnumConstant("Name", null);
    final EnumConstant result = toEnumConstant(ds3EnumConstant);
    assertThat(result.getName(), is("Name"));
}
Also used : Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) EnumConstant(com.spectralogic.ds3autogen.java.models.EnumConstant) Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) Test(org.junit.Test)

Example 3 with EnumConstant

use of com.spectralogic.ds3autogen.java.models.EnumConstant in project ds3_autogen by SpectraLogic.

the class ChecksumTypeGenerator_Test method toEnumConstantList_FullList_Test.

@Test
public void toEnumConstantList_FullList_Test() {
    final ImmutableList<Ds3EnumConstant> enumConstants = ImmutableList.of(new Ds3EnumConstant("CRC_32", null), new Ds3EnumConstant("CRC_32C", null), new Ds3EnumConstant("MD5", null), new Ds3EnumConstant("SHA_256", null), new Ds3EnumConstant("SHA_512", null));
    final ImmutableList<EnumConstant> result = generator.toEnumConstantList(enumConstants);
    assertThat(result.size(), is(6));
    assertThat(result.get(0).getName(), is("CRC_32"));
    assertThat(result.get(1).getName(), is("CRC_32C"));
    assertThat(result.get(2).getName(), is("MD5"));
    assertThat(result.get(3).getName(), is("SHA_256"));
    assertThat(result.get(4).getName(), is("SHA_512"));
    assertThat(result.get(5).getName(), is("NONE"));
}
Also used : Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) EnumConstant(com.spectralogic.ds3autogen.java.models.EnumConstant) Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) Test(org.junit.Test)

Example 4 with EnumConstant

use of com.spectralogic.ds3autogen.java.models.EnumConstant in project ds3_autogen by SpectraLogic.

the class JavaHelper_Test method getEnumValues_FullList_Test.

@Test
public void getEnumValues_FullList_Test() {
    final String expectedResult = "    DELETE,\n" + "    GET,\n" + "    HEAD,\n" + "    POST,\n" + "    PUT";
    final ImmutableList<EnumConstant> enumConstants = ImmutableList.of(new EnumConstant("DELETE"), new EnumConstant("GET"), new EnumConstant("HEAD"), new EnumConstant("POST"), new EnumConstant("PUT"));
    final String result = getEnumValues(enumConstants, 1);
    assertThat(result, is(expectedResult));
    assertThat(getEnumValues(ImmutableList.of(), 1), is(""));
    assertThat(getEnumValues(null, 1), is(""));
}
Also used : EnumConstant(com.spectralogic.ds3autogen.java.models.EnumConstant) Test(org.junit.Test)

Example 5 with EnumConstant

use of com.spectralogic.ds3autogen.java.models.EnumConstant in project ds3_autogen by SpectraLogic.

the class ChecksumTypeGenerator method toEnumConstantList.

/**
     * Converts a list of Ds3EnumConstants into a list of EnumConstant models
     * @param ds3EnumConstants A list of Ds3EnumConstants
     * @return A list of EnumConstant models
     */
@Override
public ImmutableList<EnumConstant> toEnumConstantList(final ImmutableList<Ds3EnumConstant> ds3EnumConstants) {
    if (isEmpty(ds3EnumConstants)) {
        return ImmutableList.of();
    }
    final ImmutableList.Builder<EnumConstant> builder = ImmutableList.builder();
    for (final Ds3EnumConstant ds3EnumConstant : ds3EnumConstants) {
        builder.add(toEnumConstant(ds3EnumConstant));
    }
    builder.add(new EnumConstant("NONE"));
    return builder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) EnumConstant(com.spectralogic.ds3autogen.java.models.EnumConstant) Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant)

Aggregations

EnumConstant (com.spectralogic.ds3autogen.java.models.EnumConstant)5 Ds3EnumConstant (com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant)4 Test (org.junit.Test)4 ImmutableList (com.google.common.collect.ImmutableList)1