use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation in project ds3_autogen by SpectraLogic.
the class Ds3ElementUtil_Test method hasWrapperAnnotations_HasWrapper_Test.
@Test
public void hasWrapperAnnotations_HasWrapper_Test() {
final ImmutableList<Ds3AnnotationElement> annotationElements = ImmutableList.of(new Ds3AnnotationElement("CollectionValue", "Nodes", "java.lang.String"), new Ds3AnnotationElement("CollectionValueRenderingMode", "SINGLE_BLOCK_FOR_ALL_ELEMENTS", "com.spectralogic.util.marshal.CustomMarshaledName$CollectionNameRenderingMode"), new Ds3AnnotationElement("Value", "Node", "java.lang.String"));
final ImmutableList<Ds3Annotation> annotations = ImmutableList.of(new Ds3Annotation("com.spectralogic.util.marshal.CustomMarshaledName", annotationElements));
assertThat(hasWrapperAnnotations(annotations), is(true));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation in project ds3_autogen by SpectraLogic.
the class Ds3ElementUtil_Test method hasWrapperAnnotations_NoWrapper_Test.
@Test
public void hasWrapperAnnotations_NoWrapper_Test() {
final ImmutableList<Ds3AnnotationElement> annotationElements = ImmutableList.of(new Ds3AnnotationElement("CollectionValue", "", "java.lang.String"), new Ds3AnnotationElement("CollectionValueRenderingMode", "UNDEFINED", "com.spectralogic.util.marshal.CustomMarshaledName$CollectionNameRenderingMode"), new Ds3AnnotationElement("Value", "object", "java.lang.String"));
final ImmutableList<Ds3Annotation> annotations = ImmutableList.of(new Ds3Annotation("com.spectralogic.util.marshal.CustomMarshaledName", annotationElements));
assertThat(hasWrapperAnnotations(annotations), is(false));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation in project ds3_autogen by SpectraLogic.
the class Ds3ElementUtil_Test method getXmlTagFromAnnotation_CustomName_Test.
@Test
public void getXmlTagFromAnnotation_CustomName_Test() {
final Ds3Annotation annotation = createCustomMarshaledNameAnnotation();
final String result = getXmlTagFromAnnotation(annotation);
assertThat(result, CoreMatchers.is("Error"));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation in project ds3_autogen by SpectraLogic.
the class Ds3ElementUtil method getXmlTagFromAllAnnotations.
/**
* Gets the Xml tag name for an element from its list of Ds3Annotations, if one
* exists. If multiple Xml tag names are found, an exception is thrown.
*/
protected static String getXmlTagFromAllAnnotations(final ImmutableList<Ds3Annotation> annotations, final String elementName) {
if (isEmpty(annotations)) {
return "";
}
final ImmutableList.Builder<String> builder = ImmutableList.builder();
for (final Ds3Annotation annotation : annotations) {
final String curXmlName = getXmlTagFromAnnotation(annotation);
if (hasContent(curXmlName)) {
builder.add(curXmlName);
}
}
final ImmutableList<String> xmlNames = builder.build();
switch(xmlNames.size()) {
case 0:
return "";
case 1:
return xmlNames.get(0);
default:
throw new IllegalArgumentException("There are multiple xml tag names described within the annotations for the element " + elementName + ": " + xmlNames.toString());
}
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation in project ds3_autogen by SpectraLogic.
the class NullableVariableUtil_Test method isNullableElement_OptionalAnnotation_Test.
@Test
public void isNullableElement_OptionalAnnotation_Test() {
final ImmutableList<Ds3Annotation> annotations = ImmutableList.of(new Ds3Annotation("com.spectralogic.util.db.lang.References", null), new Ds3Annotation("com.spectralogic.util.bean.lang.Optional", null));
assertFalse(isNullableElement(null, ImmutableList.of()));
assertFalse(isNullableElement("", ImmutableList.of()));
assertTrue(isNullableElement("MyType", annotations));
assertTrue(isNullableElement("java.lang.Integer", annotations));
}
Aggregations