diff --git a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/ProjectAnalyzer.java b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/ProjectAnalyzer.java index c2439ba..0d625f8 100644 --- a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/ProjectAnalyzer.java +++ b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/ProjectAnalyzer.java @@ -21,6 +21,7 @@ import com.sebastian_daschner.jaxrs_analyzer.analysis.classes.ContextClassReader; import com.sebastian_daschner.jaxrs_analyzer.analysis.classes.JAXRSClassVisitor; import com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocAnalyzer; +import com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocAnalyzerResults; import com.sebastian_daschner.jaxrs_analyzer.analysis.results.ResultInterpreter; import com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils; import com.sebastian_daschner.jaxrs_analyzer.model.rest.Resources; @@ -104,9 +105,9 @@ public Resources analyze(Set projectClassPaths, Set projectSourcePat bytecodeAnalyzer.analyzeBytecode(classResult); } - javaDocAnalyzer.analyze(projectSourcePaths, classResults); + final JavaDocAnalyzerResults javaDocAnalyzerResults = javaDocAnalyzer.analyze(projectSourcePaths, classResults); - return resultInterpreter.interpret(classResults); + return resultInterpreter.interpret(javaDocAnalyzerResults); } finally { lock.unlock(); } diff --git a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/javadoc/JavaDocAnalyzer.java b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/javadoc/JavaDocAnalyzer.java index 40ae917..b57ab21 100644 --- a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/javadoc/JavaDocAnalyzer.java +++ b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/javadoc/JavaDocAnalyzer.java @@ -17,7 +17,12 @@ import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.stream.Stream; /** @@ -26,10 +31,12 @@ public class JavaDocAnalyzer { private final Map methodComments = new HashMap<>(); + private final JavaDocParserVisitor javaDocParserVisitor = new JavaDocParserVisitor(methodComments); - public void analyze(final Set projectSourcePaths, final Set classResults) { + public JavaDocAnalyzerResults analyze(final Set projectSourcePaths, final Set classResults) { invokeParser(projectSourcePaths); combineResults(classResults); + return new JavaDocAnalyzerResults(classResults, javaDocParserVisitor.getClassComments()); } private void invokeParser(Set projectSourcePaths) { @@ -55,7 +62,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO } }); - files.forEach(path -> parseJavaDoc(path, new JavaDocParserVisitor(methodComments))); + files.forEach(path -> parseJavaDoc(path, javaDocParserVisitor)); } private static void parseJavaDoc(Path path, JavaDocParserVisitor visitor) { diff --git a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/javadoc/JavaDocAnalyzerResults.java b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/javadoc/JavaDocAnalyzerResults.java new file mode 100644 index 0000000..4e2e38b --- /dev/null +++ b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/javadoc/JavaDocAnalyzerResults.java @@ -0,0 +1,37 @@ +package com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc; + +import com.sebastian_daschner.jaxrs_analyzer.model.javadoc.ClassComment; +import com.sebastian_daschner.jaxrs_analyzer.model.results.ClassResult; + +import java.util.Map; +import java.util.Set; + +/** + * @author Tristan Perry + */ +public class JavaDocAnalyzerResults { + + /** + * Contains a range of class-level data, including the JAX-RS 'endpoint' methods which will be invoked when endpoints are hit. + */ + private final Set classResults; + + /** + * Contains JavaDoc comments/messages for classes and their fields. + */ + private final Map classComments; + + public JavaDocAnalyzerResults(Set classResults, Map classComments) { + this.classResults = classResults; + this.classComments = classComments; + } + + public Set getClassResults() { + return classResults; + } + + public Map getClassComments() { + return classComments; + } + +} diff --git a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/javadoc/JavaDocParserVisitor.java b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/javadoc/JavaDocParserVisitor.java index ed0e768..8ee0384 100644 --- a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/javadoc/JavaDocParserVisitor.java +++ b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/javadoc/JavaDocParserVisitor.java @@ -46,6 +46,10 @@ public JavaDocParserVisitor(Map methodComments) this.methodComments = methodComments; } + public Map getClassComments() { + return classComments; + } + @Override public void visit(PackageDeclaration packageDeclaration, Void arg) { packageName = packageDeclaration.getNameAsString(); @@ -99,7 +103,21 @@ private void createFieldComment(Javadoc javadoc, FieldDeclaration field) { classComment = new ClassComment(); classComments.put(className, classComment); } - classComment.getFieldComments().add(createMemberParamTag(javadoc.getDescription(), field.getAnnotations().stream())); + classComment.getFieldComments().add(createMemberParamTag(getFieldName(field), javadoc.getDescription(), field.getAnnotations().stream())); + } + + /** + * Extracts the field name from FieldDeclaration, using the included variables. I have not seen variables have more than one entry, + * so this best effort approach seems to work fine for the required purpose. + * @param field JavaParser field declaration. + * @return the field name, if extracted. + */ + private String getFieldName(FieldDeclaration field) { + if (field.getVariables().isNonEmpty()) { + return field.getVariables().get(0).getName().getIdentifier(); + } + + return null; } @Override @@ -132,15 +150,15 @@ private MemberParameterTag createMethodParameterTag(JavadocBlockTag tag, MethodD .map(NodeList::stream) .orElseGet(Stream::empty); - return createMemberParamTag(tag.getContent(), annotations); + return createMemberParamTag(tag.getName().orElse(null), tag.getContent(), annotations); } - private MemberParameterTag createMemberParamTag(JavadocDescription javadocDescription, Stream annotationStream) { + private MemberParameterTag createMemberParamTag(String name, JavadocDescription javadocDescription, Stream annotationStream) { Map annotations = annotationStream .filter(Expression::isSingleMemberAnnotationExpr) .collect(Collectors.toMap(a -> a.getName().getIdentifier(), this::createMemberParamValue)); - return new MemberParameterTag(javadocDescription.toText(), annotations); + return new MemberParameterTag(name, javadocDescription.toText(), annotations); } private String createMemberParamValue(AnnotationExpr a) { diff --git a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/DynamicTypeAnalyzer.java b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/DynamicTypeAnalyzer.java index 5c058d5..e729eb8 100644 --- a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/DynamicTypeAnalyzer.java +++ b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/DynamicTypeAnalyzer.java @@ -75,7 +75,7 @@ private TypeIdentifier analyzeInternal(final JsonValue jsonValue) { private TypeIdentifier analyzeInternal(final JsonArray jsonArray) { final TypeIdentifier containedIdentifier = jsonArray.isEmpty() ? TypeIdentifier.ofType(Types.OBJECT) : analyzeInternal(jsonArray.get(0)); - final TypeRepresentation containedRepresentation = typeRepresentations.getOrDefault(containedIdentifier, TypeRepresentation.ofConcrete(containedIdentifier)); + final TypeRepresentation containedRepresentation = typeRepresentations.getOrDefault(containedIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(containedIdentifier).build()); final TypeIdentifier existingCollection = findExistingCollection(containedRepresentation); if (existingCollection != null) { @@ -96,7 +96,7 @@ private TypeIdentifier analyzeInternal(final JsonObject jsonObject) { return existing; final TypeIdentifier identifier = TypeIdentifier.ofDynamic(); - typeRepresentations.put(identifier, TypeRepresentation.ofConcrete(identifier, properties)); + typeRepresentations.put(identifier, TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build()); return identifier; } diff --git a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/JavaTypeAnalyzer.java b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/JavaTypeAnalyzer.java index e9fd9a6..d65a9a1 100644 --- a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/JavaTypeAnalyzer.java +++ b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/JavaTypeAnalyzer.java @@ -16,25 +16,47 @@ package com.sebastian_daschner.jaxrs_analyzer.analysis.results; +import static com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils.getAnnotation; +import static com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils.getFieldDescriptor; +import static com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils.getMethodSignature; +import static com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils.getReturnType; +import static com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils.isAnnotationPresent; +import static com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils.isAssignableTo; +import static com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils.loadClassFromType; +import static com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils.toClassName; +import static com.sebastian_daschner.jaxrs_analyzer.model.Types.COLLECTION; + import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreType; import com.sebastian_daschner.jaxrs_analyzer.model.Types; +import com.sebastian_daschner.jaxrs_analyzer.model.javadoc.ClassComment; +import com.sebastian_daschner.jaxrs_analyzer.model.javadoc.MemberParameterTag; import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeIdentifier; import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeRepresentation; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeRepresentation.ConcreteTypeRepresentationBuilder; import com.sebastian_daschner.jaxrs_analyzer.utils.Pair; + import org.objectweb.asm.Type; +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Field; +import java.lang.reflect.Member; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlTransient; -import java.lang.reflect.*; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils.*; -import static com.sebastian_daschner.jaxrs_analyzer.model.Types.COLLECTION; /** * Analyzes a class (usually a POJO) for it's properties and methods. @@ -51,10 +73,12 @@ class JavaTypeAnalyzer { * The type representation storage where all analyzed types have to be added. This will be created by the caller. */ private final Map typeRepresentations; + private final Map classComments; private final Set analyzedTypes; - JavaTypeAnalyzer(final Map typeRepresentations) { + JavaTypeAnalyzer(final Map typeRepresentations, final Map classComments) { this.typeRepresentations = typeRepresentations; + this.classComments = classComments; analyzedTypes = new HashSet<>(); } @@ -93,10 +117,28 @@ private TypeRepresentation analyzeInternal(final TypeIdentifier identifier, fina if (loadedClass != null && loadedClass.isEnum()) return TypeRepresentation.ofEnum(identifier, Stream.of(loadedClass.getEnumConstants()).map(o -> (Enum) o).map(Enum::name).toArray(String[]::new)); - return TypeRepresentation.ofConcrete(identifier, analyzeClass(type, loadedClass)); + final Map> classResults = analyzeClass(type, loadedClass); + + final Map properties = classResults.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e-> e.getValue().getRight())); + final Map propertyDescriptions = classResults.entrySet().stream().filter(e -> e.getValue().getLeft() != null) + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().getLeft())); + + // build up the concrete type response + final ConcreteTypeRepresentationBuilder builder = TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties); + + if (!propertyDescriptions.isEmpty()) { + builder.propertyDescriptions(propertyDescriptions); + } + + if (classComments.containsKey(toClassName(type))) { + final ClassComment comment = classComments.get(toClassName(type)); + builder.description(comment.getComment()); + } + + return builder.build(); } - private Map analyzeClass(final String type, final Class clazz) { + private Map> analyzeClass(final String type, final Class clazz) { if (clazz == null || isJDKType(type)) return Collections.emptyMap(); @@ -107,20 +149,35 @@ private Map analyzeClass(final String type, final Class< final List relevantFields = Stream.of(clazz.getDeclaredFields()).filter(f -> isRelevant(f, value)).collect(Collectors.toList()); final List relevantGetters = Stream.of(clazz.getDeclaredMethods()).filter(m -> isRelevant(m, value)).collect(Collectors.toList()); - final Map properties = new HashMap<>(); + final Map> properties = new HashMap<>(); final Stream> allSuperTypes = Stream.concat(Stream.of(clazz.getInterfaces()), Stream.of(clazz.getSuperclass())); allSuperTypes.filter(Objects::nonNull).map(Type::getDescriptor).map(t -> analyzeClass(t, loadClassFromType(t))).forEach(properties::putAll); Stream.concat(relevantFields.stream().map(f -> mapField(f, type)), relevantGetters.stream().map(g -> mapGetter(g, type))) .filter(Objects::nonNull).forEach(p -> { - properties.put(p.getLeft(), TypeIdentifier.ofType(p.getRight())); + properties.put(p.getLeft(), Pair.of(getDescription(type, p.getLeft()), TypeIdentifier.ofType(p.getRight()))); analyze(p.getRight()); }); return properties; } + private String getDescription(String parentClass, String subFieldName) { + final String className = toClassName(parentClass); + if (classComments.containsKey(className)) { + // look through classComments (obtained from JavaDocAnalyzer, using JavaParser) and see if we have a matching field for this class/type + return classComments.get(className).getFieldComments() + .stream() + .filter(memberParameterTag -> memberParameterTag.getName().equals(subFieldName)) + .map(MemberParameterTag::getComment) + .findAny() + .orElse(null); + } + + return null; + } + private XmlAccessType getXmlAccessType(final Class clazz) { Class current = clazz; diff --git a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/ResultInterpreter.java b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/ResultInterpreter.java index 1f4df3a..5edca26 100644 --- a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/ResultInterpreter.java +++ b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/ResultInterpreter.java @@ -16,6 +16,7 @@ package com.sebastian_daschner.jaxrs_analyzer.analysis.results; +import com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocAnalyzerResults; import com.sebastian_daschner.jaxrs_analyzer.model.JavaUtils; import com.sebastian_daschner.jaxrs_analyzer.model.elements.HttpResponse; import com.sebastian_daschner.jaxrs_analyzer.model.javadoc.ClassComment; @@ -51,15 +52,15 @@ public class ResultInterpreter { * * @return All REST resources */ - public Resources interpret(final Set classResults) { + public Resources interpret(final JavaDocAnalyzerResults javaDocAnalyzerResults) { resources = new Resources(); - resources.setBasePath(PathNormalizer.getApplicationPath(classResults)); + resources.setBasePath(PathNormalizer.getApplicationPath(javaDocAnalyzerResults.getClassResults())); - javaTypeAnalyzer = new JavaTypeAnalyzer(resources.getTypeRepresentations()); + javaTypeAnalyzer = new JavaTypeAnalyzer(resources.getTypeRepresentations(), javaDocAnalyzerResults.getClassComments()); dynamicTypeAnalyzer = new DynamicTypeAnalyzer(resources.getTypeRepresentations()); stringParameterResolver = new StringParameterResolver(resources.getTypeRepresentations(), javaTypeAnalyzer); - classResults.stream().filter(c -> c.getResourcePath() != null).forEach(this::interpretClassResult); + javaDocAnalyzerResults.getClassResults().stream().filter(c -> c.getResourcePath() != null).forEach(this::interpretClassResult); resources.consolidateMultiplePaths(); return resources; diff --git a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/backend/swagger/SchemaBuilder.java b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/backend/swagger/SchemaBuilder.java index 6cad6f4..b09de59 100644 --- a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/backend/swagger/SchemaBuilder.java +++ b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/backend/swagger/SchemaBuilder.java @@ -16,20 +16,25 @@ package com.sebastian_daschner.jaxrs_analyzer.backend.swagger; +import static com.sebastian_daschner.jaxrs_analyzer.backend.ComparatorUtils.mapKeyComparator; +import static com.sebastian_daschner.jaxrs_analyzer.model.Types.BOOLEAN; +import static com.sebastian_daschner.jaxrs_analyzer.model.Types.DOUBLE_TYPES; +import static com.sebastian_daschner.jaxrs_analyzer.model.Types.INTEGER_TYPES; +import static com.sebastian_daschner.jaxrs_analyzer.model.Types.PRIMITIVE_BOOLEAN; +import static com.sebastian_daschner.jaxrs_analyzer.model.Types.STRING; + import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeIdentifier; import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeRepresentation; import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeRepresentationVisitor; import com.sebastian_daschner.jaxrs_analyzer.utils.Pair; +import java.util.HashMap; +import java.util.Map; + import javax.json.Json; import javax.json.JsonArrayBuilder; import javax.json.JsonObject; import javax.json.JsonObjectBuilder; -import java.util.HashMap; -import java.util.Map; - -import static com.sebastian_daschner.jaxrs_analyzer.backend.ComparatorUtils.mapKeyComparator; -import static com.sebastian_daschner.jaxrs_analyzer.model.Types.*; /** * Creates Swagger schema type definitions. @@ -61,6 +66,18 @@ class SchemaBuilder { * @return The schema JSON object builder with the needed properties */ JsonObjectBuilder build(final TypeIdentifier identifier) { + return this.build(identifier, null); + } + + /** + * Creates the schema object builder for the identifier. + * The actual definitions are retrieved via {@link SchemaBuilder#getDefinitions} after all types have been declared. + * + * @param identifier The identifier + * @param description A description for this field, for example a JavaDoc. + * @return The schema JSON object builder with the needed properties + */ + JsonObjectBuilder build(final TypeIdentifier identifier, final String description) { final SwaggerType type = toSwaggerType(identifier.getType()); switch (type) { case BOOLEAN: @@ -70,6 +87,7 @@ JsonObjectBuilder build(final TypeIdentifier identifier) { case STRING: final JsonObjectBuilder builder = Json.createObjectBuilder(); addPrimitive(builder, type); + addDescriptionIfAvailable(builder, description); return builder; } @@ -118,10 +136,13 @@ public void visit(final TypeRepresentation.EnumTypeRepresentation representation }; final TypeRepresentation representation = typeRepresentations.get(identifier); - if (representation == null) + if (representation == null) { builder.add("type", "object"); - else + } + else { representation.accept(visitor); + } + addDescriptionIfAvailable(builder, description); return builder; } @@ -148,10 +169,13 @@ private void add(final JsonObjectBuilder builder, final TypeRepresentation.Concr return; } - addObject(builder, representation.getIdentifier(), representation.getProperties()); + addObject(builder, representation, representation.getProperties(), representation.getPropertyDescriptions()); } - private void addObject(final JsonObjectBuilder builder, final TypeIdentifier identifier, final Map properties) { + private void addObject(final JsonObjectBuilder builder, final TypeRepresentation representation, final Map properties, + final Map propertyDescriptions) { + + final TypeIdentifier identifier = representation.getIdentifier(); final String definition = definitionNameBuilder.buildDefinitionName(identifier.getName(), jsonDefinitions); if (jsonDefinitions.containsKey(definition)) { @@ -160,12 +184,24 @@ private void addObject(final JsonObjectBuilder builder, final TypeIdentifier ide } // reserve definition - jsonDefinitions.put(definition, Pair.of(identifier.getName(), Json.createObjectBuilder().build())); + final JsonObjectBuilder objectBuilder = Json.createObjectBuilder(); + jsonDefinitions.put(definition, Pair.of(identifier.getName(), objectBuilder.build())); + + // if we have a comment/description, include this + representation.getDescription().ifPresent(desc -> objectBuilder.add("description", desc)); + // build - and include - the inner properties (e.g. the class' fields) final JsonObjectBuilder nestedBuilder = Json.createObjectBuilder(); + properties.entrySet().stream().sorted(mapKeyComparator()).forEach(e -> { + if (propertyDescriptions.containsKey(e.getKey())) { + nestedBuilder.add(e.getKey(), build(e.getValue(), propertyDescriptions.get(e.getKey()))); + } else { + nestedBuilder.add(e.getKey(), build(e.getValue())); + } + }); + objectBuilder.add("properties", nestedBuilder); - properties.entrySet().stream().sorted(mapKeyComparator()).forEach(e -> nestedBuilder.add(e.getKey(), build(e.getValue()))); - jsonDefinitions.put(definition, Pair.of(identifier.getName(), Json.createObjectBuilder().add("properties", nestedBuilder).build())); + jsonDefinitions.put(definition, Pair.of(identifier.getName(), objectBuilder.build())); builder.add("$ref", "#/definitions/" + definition); } @@ -174,6 +210,12 @@ private void addPrimitive(final JsonObjectBuilder builder, final SwaggerType typ builder.add("type", type.toString()); } + private void addDescriptionIfAvailable(JsonObjectBuilder builder, String description) { + if (description != null && !description.isEmpty()) { + builder.add("description", description); + } + } + /** * Converts the given Java type to the Swagger JSON type. * diff --git a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/model/javadoc/MemberParameterTag.java b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/model/javadoc/MemberParameterTag.java index b4ea732..0d6f8a8 100644 --- a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/model/javadoc/MemberParameterTag.java +++ b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/model/javadoc/MemberParameterTag.java @@ -12,6 +12,7 @@ */ public class MemberParameterTag { + private final String name; private final String comment; /** @@ -19,11 +20,16 @@ public class MemberParameterTag { */ private final Map annotations; - public MemberParameterTag(String comment, Map annotations) { + public MemberParameterTag(String name, String comment, Map annotations) { + this.name = name; this.comment = comment; this.annotations = Collections.unmodifiableMap(annotations); } + public String getName() { + return name; + } + public String getComment() { return comment; } @@ -32,4 +38,9 @@ public Map getAnnotations() { return annotations; } + @Override + public String toString() { + return "MemberParameterTag{" + "name='" + name + '\'' + ", comment='" + comment + '\'' + ", annotations=" + annotations + '}'; + } + } diff --git a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/model/rest/TypeRepresentation.java b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/model/rest/TypeRepresentation.java index 30ca7ba..23faafd 100644 --- a/src/main/java/com/sebastian_daschner/jaxrs_analyzer/model/rest/TypeRepresentation.java +++ b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/model/rest/TypeRepresentation.java @@ -18,7 +18,12 @@ import com.sebastian_daschner.jaxrs_analyzer.model.Types; -import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Optional; +import java.util.Set; /** * Represents a request/response body type including the properties which actually will be serialized (e.g. depending on the JAXB mapping). @@ -47,6 +52,14 @@ public TypeIdentifier getIdentifier() { */ public abstract TypeIdentifier getComponentType(); + /** + * The comment/description (e.g. from a JavaDoc), if available. + * @return (optional) the description. + */ + public Optional getDescription() { + return Optional.empty(); + } + @Override public boolean equals(final Object o) { if (this == o) return true; @@ -62,25 +75,13 @@ public int hashCode() { } /** - * Creates a type representation of a concrete type (i.e. a Java type, not a programmatically created type) without actual properties. - * This is used for JDK internal types (like {@link String}, {@link Object}) where no property analysis is desired. - * - * @param identifier The type identifier - * @return The type representation + * Returns a builder so that a a type representation of a concrete type (i.e. a Java type, not a programmatically created type) can be created. + * Might just include identifier (no properties), used for JKD internal types (like {@link String}, {@link Object}) where no property analysis is desired. + * Might have identifier and other fields (such as properties), used for extended/custom types. + * @return ConcreteTypeRepresentation builder. */ - public static TypeRepresentation ofConcrete(final TypeIdentifier identifier) { - return new ConcreteTypeRepresentation(identifier, Collections.emptyMap()); - } - - /** - * Creates a type representation of a concrete type (i.e. a Java type, not a programmatically created type) plus the actual properties. - * - * @param identifier The type identifier - * @param properties The type (POJO) description - * @return The type representation - */ - public static TypeRepresentation ofConcrete(final TypeIdentifier identifier, final Map properties) { - return new ConcreteTypeRepresentation(identifier, properties); + public static ConcreteTypeRepresentationBuilder ofConcreteBuilder() { + return new ConcreteTypeRepresentationBuilder(); } /** @@ -107,19 +108,67 @@ public static TypeRepresentation ofEnum(final TypeIdentifier identifier, final S return new EnumTypeRepresentation(identifier, new HashSet<>(Arrays.asList(enumValues))); } + public static class ConcreteTypeRepresentationBuilder { + private TypeIdentifier identifier; + private Map properties = Collections.emptyMap(); // property types + private Map propertyDescriptions = Collections.emptyMap(); // property descriptions, e.g. from JavaDocs + private String description; // parent description, e.g. the JavaDoc of the overall class. + + public ConcreteTypeRepresentationBuilder() { + } + + public ConcreteTypeRepresentationBuilder identifier(TypeIdentifier identifier) { + this.identifier = identifier; + return this; + } + + public ConcreteTypeRepresentationBuilder properties(Map properties) { + this.properties = properties; + return this; + } + + public ConcreteTypeRepresentationBuilder propertyDescriptions(Map propertyDescriptions) { + this.propertyDescriptions = propertyDescriptions; + return this; + } + + public ConcreteTypeRepresentationBuilder description(String description) { + this.description = description; + return this; + } + + public ConcreteTypeRepresentation build() { + return new ConcreteTypeRepresentation(identifier, properties, propertyDescriptions, description); + } + } + public static class ConcreteTypeRepresentation extends TypeRepresentation { - private final Map properties; + private final Map properties; // property types + private final Map propertyDescriptions; // property descriptions, e.g. from JavaDocs + private final String description; // parent description, e.g. the JavaDoc of the overall class. - private ConcreteTypeRepresentation(final TypeIdentifier identifier, final Map properties) { + private ConcreteTypeRepresentation(final TypeIdentifier identifier, final Map properties, + final Map propertyDescriptions, final String description) { super(identifier); this.properties = properties; + this.propertyDescriptions = propertyDescriptions; + this.description = description; } public Map getProperties() { return properties; } + public Map getPropertyDescriptions() { + return propertyDescriptions; + } + + @Override + public Optional getDescription() { + return Optional.ofNullable(description); + } + @Override public TypeIdentifier getComponentType() { return getIdentifier(); diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/ProjectAnalyzerTest.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/ProjectAnalyzerTest.java index f16897a..69bda2d 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/ProjectAnalyzerTest.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/ProjectAnalyzerTest.java @@ -16,29 +16,44 @@ package com.sebastian_daschner.jaxrs_analyzer.analysis; +import static java.util.Collections.singleton; +import static java.util.Collections.singletonList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import com.sebastian_daschner.jaxrs_analyzer.LogProvider; import com.sebastian_daschner.jaxrs_analyzer.builder.ResourceMethodBuilder; import com.sebastian_daschner.jaxrs_analyzer.builder.ResponseBuilder; import com.sebastian_daschner.jaxrs_analyzer.model.Types; -import com.sebastian_daschner.jaxrs_analyzer.model.rest.*; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.HttpMethod; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.ResourceMethod; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.Resources; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.Response; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeIdentifier; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeRepresentation; + import org.junit.Before; import org.junit.Test; -import javax.tools.JavaCompiler; -import javax.tools.JavaFileObject; -import javax.tools.StandardJavaFileManager; -import javax.tools.ToolProvider; import java.io.File; import java.net.MalformedURLException; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static org.junit.Assert.*; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; public class ProjectAnalyzerTest { @@ -158,13 +173,14 @@ private static Resources getResources() { properties.put("id", TypeIdentifier.ofType(Types.PRIMITIVE_LONG)); properties.put("name", stringIdentifier); final TypeIdentifier modelIdentifier = TypeIdentifier.ofType("Lcom/sebastian_daschner/jaxrs_test/Model;"); - final TypeRepresentation modelRepresentation = TypeRepresentation.ofConcrete(modelIdentifier, properties); + final TypeRepresentation modelRepresentation = TypeRepresentation.ofConcreteBuilder().identifier(modelIdentifier).properties(properties).build(); resources.getTypeRepresentations().put(modelIdentifier, modelRepresentation); final TypeIdentifier modelListIdentifier = TypeIdentifier.ofType("Ljava/util/List<+Lcom/sebastian_daschner/jaxrs_test/Model;>;"); resources.getTypeRepresentations().put(modelListIdentifier, TypeRepresentation.ofCollection(modelListIdentifier, modelRepresentation)); final TypeIdentifier stringArrayListIdentifier = TypeIdentifier.ofType("Ljava/util/ArrayList;"); - resources.getTypeRepresentations().put(stringArrayListIdentifier, TypeRepresentation.ofCollection(stringArrayListIdentifier, TypeRepresentation.ofConcrete(stringIdentifier))); + resources.getTypeRepresentations().put(stringArrayListIdentifier, + TypeRepresentation.ofCollection(stringArrayListIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(stringIdentifier).build())); resources.setBasePath("rest"); @@ -292,17 +308,17 @@ private static Resources getResources() { properties.put("key", stringIdentifier); // All numbers are treat as double (JSON type number) properties.put("duke", TypeIdentifier.ofType(Types.DOUBLE)); - resources.getTypeRepresentations().put(firstIdentifier, TypeRepresentation.ofConcrete(firstIdentifier, properties)); + resources.getTypeRepresentations().put(firstIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(firstIdentifier).properties(properties).build()); ResourceMethod twelfthGet = ResourceMethodBuilder.withMethod(HttpMethod.GET).andResponse(200, ResponseBuilder.withResponseBody(firstIdentifier).build()).build(); final TypeIdentifier secondIdentifier = TypeIdentifier.ofDynamic(); properties = new HashMap<>(); properties.put("key", stringIdentifier); - resources.getTypeRepresentations().put(secondIdentifier, TypeRepresentation.ofConcrete(secondIdentifier, properties)); + resources.getTypeRepresentations().put(secondIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(secondIdentifier).properties(properties).build()); // TODO type should be Object because JsonArray is interpreted as collection type final TypeIdentifier thirdIdentifier = TypeIdentifier.ofDynamic(); - resources.getTypeRepresentations().put(thirdIdentifier, TypeRepresentation.ofCollection(thirdIdentifier, TypeRepresentation.ofConcrete(stringIdentifier))); + resources.getTypeRepresentations().put(thirdIdentifier, TypeRepresentation.ofCollection(thirdIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(stringIdentifier).build())); ResourceMethod fifthPost = ResourceMethodBuilder.withMethod(HttpMethod.POST) .andResponse(202, ResponseBuilder.withResponseBody(secondIdentifier).build()) .andResponse(500, ResponseBuilder.newBuilder().build()) @@ -316,7 +332,7 @@ private static Resources getResources() { properties.put("key", stringIdentifier); properties.put("duke", stringIdentifier); properties.put("hello", stringIdentifier); - resources.getTypeRepresentations().put(fourthIdentifier, TypeRepresentation.ofConcrete(fourthIdentifier, properties)); + resources.getTypeRepresentations().put(fourthIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(fourthIdentifier).properties(properties).build()); ResourceMethod thirteenthGet = ResourceMethodBuilder.withMethod(HttpMethod.GET).andResponse(200, ResponseBuilder.withResponseBody(fourthIdentifier).build()) .build(); addMethods(resources, "json_tests/info", thirteenthGet); diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/DynamicTypeAnalyzerTest.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/DynamicTypeAnalyzerTest.java index 4c31047..5af8a38 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/DynamicTypeAnalyzerTest.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/DynamicTypeAnalyzerTest.java @@ -117,10 +117,10 @@ public void testArraysAndObjectsNestedTypes() { @Test public void testEqualTypes() { // should be ignored - typeRepresentations.put(STRING_LIST_IDENTIFIER, TypeRepresentation.ofCollection(STRING_LIST_IDENTIFIER, TypeRepresentation.ofConcrete(STRING_IDENTIFIER))); + typeRepresentations.put(STRING_LIST_IDENTIFIER, TypeRepresentation.ofCollection(STRING_LIST_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(STRING_IDENTIFIER).build())); final TypeIdentifier modelIdentifier = TypeIdentifier.ofType("com.sebastian_daschner.test.Model"); final Map modelProperties = Collections.singletonMap("string", TypeUtils.STRING_IDENTIFIER); - typeRepresentations.put(modelIdentifier, TypeRepresentation.ofConcrete(modelIdentifier, modelProperties)); + typeRepresentations.put(modelIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(modelIdentifier).properties(modelProperties).build()); TypeIdentifier identifier = cut.analyze(Json.createArrayBuilder().add("foobar").build()); final String firstName = identifier.getName(); diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/JavaTypeAnalyzerTest.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/JavaTypeAnalyzerTest.java index d0c5317..99be1f8 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/JavaTypeAnalyzerTest.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/JavaTypeAnalyzerTest.java @@ -48,7 +48,7 @@ public JavaTypeAnalyzerTest(final String testClassSimpleName, final String testC this.testClassName = testClassName; this.expectedIdentifier = expectedIdentifier; this.expectedRepresentations = expectedRepresentations; - this.classUnderTest = new JavaTypeAnalyzer(actualTypeRepresentations); + this.classUnderTest = new JavaTypeAnalyzer(actualTypeRepresentations, new HashMap<>()); } @Parameterized.Parameters(name = "{0}") diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/ResultInterpreterTest.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/ResultInterpreterTest.java index c2eec1e..ebbe033 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/ResultInterpreterTest.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/ResultInterpreterTest.java @@ -16,24 +16,36 @@ package com.sebastian_daschner.jaxrs_analyzer.analysis.results; -import com.sebastian_daschner.jaxrs_analyzer.builder.*; +import static com.sebastian_daschner.jaxrs_analyzer.analysis.results.TypeUtils.STRING_IDENTIFIER; +import static org.junit.Assert.assertEquals; + +import com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocAnalyzerResults; +import com.sebastian_daschner.jaxrs_analyzer.builder.ClassResultBuilder; +import com.sebastian_daschner.jaxrs_analyzer.builder.HttpResponseBuilder; +import com.sebastian_daschner.jaxrs_analyzer.builder.MethodResultBuilder; +import com.sebastian_daschner.jaxrs_analyzer.builder.ResourceMethodBuilder; +import com.sebastian_daschner.jaxrs_analyzer.builder.ResponseBuilder; import com.sebastian_daschner.jaxrs_analyzer.model.Types; import com.sebastian_daschner.jaxrs_analyzer.model.javadoc.MethodComment; -import com.sebastian_daschner.jaxrs_analyzer.model.rest.*; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.HttpMethod; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.ResourceMethod; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.Resources; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeIdentifier; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeRepresentation; import com.sebastian_daschner.jaxrs_analyzer.model.results.ClassResult; import com.sebastian_daschner.jaxrs_analyzer.model.results.MethodResult; + import org.junit.Before; import org.junit.Test; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Set; -import static com.sebastian_daschner.jaxrs_analyzer.analysis.results.TypeUtils.STRING_IDENTIFIER; -import static org.junit.Assert.assertEquals; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; public class ResultInterpreterTest { @@ -60,7 +72,7 @@ public void testStandard() { final Set results = new HashSet<>(Arrays.asList(appPathResult, resClassResult)); - final Resources actualResult = classUnderTest.interpret(results); + final Resources actualResult = classUnderTest.interpret(new JavaDocAnalyzerResults(results, new HashMap<>())); // TODO assertEquals(expectedResult, actualResult); } @@ -87,7 +99,7 @@ public void testSubResource() { final Set results = new HashSet<>(Arrays.asList(appPathResult, resClassResult)); - final Resources actualResult = classUnderTest.interpret(results); + final Resources actualResult = classUnderTest.interpret(new JavaDocAnalyzerResults(results, new HashMap<>())); // TODO assertEquals(expectedResult, actualResult); } @@ -106,7 +118,7 @@ public void testRootResource() { final Set results = new HashSet<>(Arrays.asList(appPathResult, resClassResult)); - final Resources actualResult = classUnderTest.interpret(results); + final Resources actualResult = classUnderTest.interpret(new JavaDocAnalyzerResults(results, new HashMap<>())); // TODO assertEquals(expectedResult, actualResult); } @@ -129,7 +141,7 @@ public void testNormalizeGenericEntityNoCollection() { final Set results = new HashSet<>(Arrays.asList(appPathResult, resClassResult)); - final Resources actualResult = classUnderTest.interpret(results); + final Resources actualResult = classUnderTest.interpret(new JavaDocAnalyzerResults(results, new HashMap<>())); // TODO assertEquals(expectedResult, actualResult); } @@ -150,7 +162,7 @@ public void testContentTypes() { final Set results = new HashSet<>(Arrays.asList(appPathResult, resClassResult)); - final Resources actualResult = classUnderTest.interpret(results); + final Resources actualResult = classUnderTest.interpret(new JavaDocAnalyzerResults(results, new HashMap<>())); // TODO assertEquals(expectedResult, actualResult); } @@ -172,7 +184,7 @@ public void testOverrideAnnotationContentType() { final Set results = new HashSet<>(Arrays.asList(appPathResult, resClassResult)); - final Resources actualResult = classUnderTest.interpret(results); + final Resources actualResult = classUnderTest.interpret(new JavaDocAnalyzerResults(results, new HashMap<>())); // TODO assertEquals(expectedResult, actualResult); } @@ -193,7 +205,7 @@ public void testNestedBasePath() { final Set results = new HashSet<>(Arrays.asList(appPathResult, resClassResult)); - final Resources actualResult = classUnderTest.interpret(results); + final Resources actualResult = classUnderTest.interpret(new JavaDocAnalyzerResults(results, new HashMap<>())); // TODO assertEquals(expectedResult, actualResult); } @@ -219,7 +231,7 @@ public void testDefaultStatusCodes() { final Set results = new HashSet<>(Arrays.asList(appPathResult, resClassResult)); - final Resources actualResult = classUnderTest.interpret(results); + final Resources actualResult = classUnderTest.interpret(new JavaDocAnalyzerResults(results, new HashMap<>())); // TODO assertEquals(expectedResult, actualResult); } @@ -230,7 +242,7 @@ public void testNormalize() { expectedResult.setBasePath("path"); final TypeIdentifier stringListIdentifier = TypeIdentifier.ofType("Ljava/util/List;"); - final TypeRepresentation stringList = TypeRepresentation.ofCollection(stringListIdentifier, TypeRepresentation.ofConcrete(STRING_IDENTIFIER)); + final TypeRepresentation stringList = TypeRepresentation.ofCollection(stringListIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(STRING_IDENTIFIER).build()); expectedResult.getTypeRepresentations().put(stringListIdentifier, stringList); final ResourceMethod resourceGetMethod = ResourceMethodBuilder.withMethod(HttpMethod.GET) @@ -246,7 +258,7 @@ public void testNormalize() { final Set results = new HashSet<>(Arrays.asList(appPathResult, resClassResult)); - final Resources actualResult = classUnderTest.interpret(results); + final Resources actualResult = classUnderTest.interpret(new JavaDocAnalyzerResults(results, new HashMap<>())); // TODO assertEquals(expectedResult, actualResult); } @@ -258,8 +270,8 @@ public void testAmbiguousEntityTypes() { final Resources expectedResult = new Resources(); expectedResult.setBasePath("path"); final TypeIdentifier identifier = TypeIdentifier.ofType(configurationType); - expectedResult.getTypeRepresentations().put(identifier, TypeRepresentation.ofConcrete(identifier, - Collections.singletonMap("name", STRING_IDENTIFIER))); + expectedResult.getTypeRepresentations().put(identifier, + TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(Collections.singletonMap("name", STRING_IDENTIFIER)).build()); final ResourceMethod resourceGetMethod = ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()) @@ -276,7 +288,7 @@ public void testAmbiguousEntityTypes() { final Set results = new HashSet<>(Arrays.asList(appPathResult, resClassResult)); - final Resources actualResult = classUnderTest.interpret(results); + final Resources actualResult = classUnderTest.interpret(new JavaDocAnalyzerResults(results, new HashMap<>())); // TODO assertEquals(expectedResult, actualResult); } @@ -302,7 +314,7 @@ public void testDescriptions() { final Set results = new HashSet<>(Arrays.asList(appPathResult, resClassResult)); - final Resources actualResult = classUnderTest.interpret(results); + final Resources actualResult = classUnderTest.interpret(new JavaDocAnalyzerResults(results, new HashMap<>())); // TODO assertEquals(expectedResult, actualResult); } diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass1.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass1.java index 6f4275a..831e3ac 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass1.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass1.java @@ -57,7 +57,7 @@ public static Set expectedTypeRepresentations() { properties.put("test", TypeUtils.STRING_IDENTIFIER); properties.put("int", TypeIdentifier.ofType(Types.PRIMITIVE_INT)); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass10.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass10.java index 92654c3..cb5f976 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass10.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass10.java @@ -49,7 +49,7 @@ public static Set expectedTypeRepresentations() { properties.put("second", TypeIdentifier.ofType("Ljava/util/Map;")); properties.put("third", TypeIdentifier.ofType("Ljava/util/Map;")); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass11.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass11.java index 924a5ee..6af90eb 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass11.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass11.java @@ -42,7 +42,7 @@ public static Set expectedTypeRepresentations() { properties.put("second", TypeIdentifier.ofType(Types.PRIMITIVE_INT)); properties.put("child", identifier); - return Collections.singleton(TypeRepresentation.ofConcrete(identifier, properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass12.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass12.java index f0b13fc..f8e6bc2 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass12.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass12.java @@ -44,13 +44,13 @@ public static Set expectedTypeRepresentations() { properties.put("child", innerTestIdentifier); final TypeIdentifier testClass12Identifier = expectedIdentifier(); - final TypeRepresentation testClass12 = TypeRepresentation.ofConcrete(testClass12Identifier, properties); + final TypeRepresentation testClass12 = TypeRepresentation.ofConcreteBuilder().identifier(testClass12Identifier).properties(properties).build(); final Map innerProperties = new HashMap<>(); innerProperties.put("second", TypeIdentifier.ofType(Types.PRIMITIVE_INT)); innerProperties.put("child", testClass12Identifier); - final TypeRepresentation innerTestClass = TypeRepresentation.ofConcrete(innerTestIdentifier, innerProperties); + final TypeRepresentation innerTestClass = TypeRepresentation.ofConcreteBuilder().identifier(innerTestIdentifier).properties(innerProperties).build(); return new HashSet<>(Arrays.asList(testClass12, innerTestClass)); } diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass13.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass13.java index 80f2b14..4db5525 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass13.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass13.java @@ -69,24 +69,24 @@ public static Set expectedTypeRepresentations() { properties.put("longAndString", longStringIdentifier); properties.put("stringAndLong", stringLongIdentifier); - final TypeRepresentation testClass13 = TypeRepresentation.ofConcrete(expectedIdentifier(), properties); + final TypeRepresentation testClass13 = TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build(); final TypeIdentifier listStringIdentifier = TypeIdentifier.ofType("Ljava/util/List;"); - final TypeRepresentation listString = TypeRepresentation.ofCollection(listStringIdentifier, TypeRepresentation.ofConcrete(stringIdentifier)); + final TypeRepresentation listString = TypeRepresentation.ofCollection(listStringIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(stringIdentifier).build()); final TypeIdentifier listLongIdentifier = TypeIdentifier.ofType("Ljava/util/List;"); - final TypeRepresentation listLong = TypeRepresentation.ofCollection(listLongIdentifier, TypeRepresentation.ofConcrete(longIdentifier)); + final TypeRepresentation listLong = TypeRepresentation.ofCollection(listLongIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(longIdentifier).build()); final Map longStringProperties = new HashMap<>(); longStringProperties.put("a", longIdentifier); longStringProperties.put("b", stringIdentifier); longStringProperties.put("listA", listLongIdentifier); - final TypeRepresentation longString = TypeRepresentation.ofConcrete(longStringIdentifier, longStringProperties); + final TypeRepresentation longString = TypeRepresentation.ofConcreteBuilder().identifier(longStringIdentifier).properties(longStringProperties).build(); final Map stringLongProperties = new HashMap<>(); stringLongProperties.put("a", stringIdentifier); stringLongProperties.put("b", longIdentifier); stringLongProperties.put("listA", listStringIdentifier); - final TypeRepresentation stringLong = TypeRepresentation.ofConcrete(stringLongIdentifier, stringLongProperties); + final TypeRepresentation stringLong = TypeRepresentation.ofConcreteBuilder().identifier(stringLongIdentifier).properties(stringLongProperties).build(); return new HashSet<>(Arrays.asList(testClass13, longString, stringLong, listLong, listString)); } diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass14.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass14.java index a6085d9..d16b823 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass14.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass14.java @@ -73,24 +73,24 @@ public static Set expectedTypeRepresentations() { properties.put("longAndString", longStringIdentifier); properties.put("stringAndLong", stringLongIdentifier); - final TypeRepresentation testClass13 = TypeRepresentation.ofConcrete(expectedIdentifier(), properties); + final TypeRepresentation testClass13 = TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build(); final TypeIdentifier listStringIdentifier = TypeIdentifier.ofType("Ljava/util/List;"); - final TypeRepresentation listString = TypeRepresentation.ofCollection(listStringIdentifier, TypeRepresentation.ofConcrete(stringIdentifier)); + final TypeRepresentation listString = TypeRepresentation.ofCollection(listStringIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(stringIdentifier).build()); final TypeIdentifier listLongIdentifier = TypeIdentifier.ofType("Ljava/util/List;"); - final TypeRepresentation listLong = TypeRepresentation.ofCollection(listLongIdentifier, TypeRepresentation.ofConcrete(longIdentifier)); + final TypeRepresentation listLong = TypeRepresentation.ofCollection(listLongIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(longIdentifier).build()); final Map longStringProperties = new HashMap<>(); longStringProperties.put("a", longIdentifier); longStringProperties.put("b", stringIdentifier); longStringProperties.put("listA", listLongIdentifier); - final TypeRepresentation longString = TypeRepresentation.ofConcrete(longStringIdentifier, longStringProperties); + final TypeRepresentation longString = TypeRepresentation.ofConcreteBuilder().identifier(longStringIdentifier).properties(longStringProperties).build(); final Map stringLongProperties = new HashMap<>(); stringLongProperties.put("a", stringIdentifier); stringLongProperties.put("b", longIdentifier); stringLongProperties.put("listA", listStringIdentifier); - final TypeRepresentation stringLong = TypeRepresentation.ofConcrete(stringLongIdentifier, stringLongProperties); + final TypeRepresentation stringLong = TypeRepresentation.ofConcreteBuilder().identifier(stringLongIdentifier).properties(stringLongProperties).build(); return new HashSet<>(Arrays.asList(testClass13, longString, stringLong, listLong, listString)); } diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass15.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass15.java index 21ae856..49dceff 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass15.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass15.java @@ -27,7 +27,7 @@ public static Set expectedTypeRepresentations() { properties.put("foobar", TypeUtils.STRING_IDENTIFIER); properties.put("test", TypeUtils.STRING_IDENTIFIER); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass16.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass16.java index 4f22398..cb6fc2c 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass16.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass16.java @@ -22,8 +22,8 @@ public static Set expectedTypeRepresentations() { properties.put("world", stringIdentifier); properties.put("partner", superTestClass2); - return new HashSet<>(Arrays.asList(TypeRepresentation.ofConcrete(expectedIdentifier(), properties), - TypeRepresentation.ofConcrete(superTestClass2, Collections.singletonMap("hello", stringIdentifier)))); + return new HashSet<>(Arrays.asList(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build(), + TypeRepresentation.ofConcreteBuilder().identifier(superTestClass2).properties(Collections.singletonMap("hello", stringIdentifier)).build())); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass17.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass17.java index 05227f9..381e014 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass17.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass17.java @@ -36,8 +36,8 @@ public static Set expectedTypeRepresentations() { properties.put("world", stringIdentifier); properties.put("partner", superTestClass3); - return new HashSet<>(Arrays.asList(TypeRepresentation.ofConcrete(expectedIdentifier(), properties), - TypeRepresentation.ofConcrete(superTestClass3, Collections.singletonMap("hello", stringIdentifier)))); + return new HashSet<>(Arrays.asList(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build(), + TypeRepresentation.ofConcreteBuilder().identifier(superTestClass3).properties(Collections.singletonMap("hello", stringIdentifier)).build())); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass18.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass18.java index 4e0511a..afa28f8 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass18.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass18.java @@ -26,7 +26,7 @@ public static Set expectedTypeRepresentations() { properties.put("test", TypeUtils.STRING_IDENTIFIER); properties.put("partner", identifier); - return Collections.singleton(TypeRepresentation.ofConcrete(identifier, properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass19.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass19.java index 82700b7..806546b 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass19.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass19.java @@ -29,7 +29,7 @@ public static Set expectedTypeRepresentations() { properties.put("hello", TypeUtils.STRING_IDENTIFIER); properties.put("overidden", TypeUtils.STRING_IDENTIFIER); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass2.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass2.java index a7b9515..7146988 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass2.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass2.java @@ -20,10 +20,11 @@ import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeIdentifier; import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeRepresentation; -import javax.xml.bind.annotation.XmlTransient; import java.util.Collections; import java.util.Set; +import javax.xml.bind.annotation.XmlTransient; + public class TestClass2 { private String first; @@ -44,7 +45,9 @@ public String getSecond() { } public static Set expectedTypeRepresentations() { - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), Collections.singletonMap("second", TypeUtils.STRING_IDENTIFIER))); + return Collections.singleton( + TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(Collections.singletonMap("second", TypeUtils.STRING_IDENTIFIER)) + .build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass20.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass20.java index b690c5a..5e199cd 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass20.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass20.java @@ -30,7 +30,7 @@ public static Set expectedTypeRepresentations() { properties.put("test3", TypeUtils.STRING_IDENTIFIER); properties.put("test4", TypeUtils.STRING_IDENTIFIER); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass21.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass21.java index 23d83ff..b71c655 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass21.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass21.java @@ -44,7 +44,7 @@ public static Set expectedTypeRepresentations() { final TypeIdentifier inner = TypeIdentifier.ofType("Lcom/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass21$InnerTestClass21;"); properties.put("inner", inner); - return new HashSet<>(asList(TypeRepresentation.ofConcrete(expectedIdentifier(), properties), TypeRepresentation.ofEnum(inner, "FIRST", "SECOND"))); + return new HashSet<>(asList(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build(), TypeRepresentation.ofEnum(inner, "FIRST", "SECOND"))); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass22.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass22.java index 706d518..a857d64 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass22.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass22.java @@ -63,7 +63,7 @@ public static Set expectedTypeRepresentations() { properties.put("test", TypeUtils.STRING_IDENTIFIER); properties.put("int", TypeIdentifier.ofType(Types.PRIMITIVE_INT)); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass23.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass23.java index f970959..a4c5164 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass23.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass23.java @@ -47,7 +47,7 @@ public static Set expectedTypeRepresentations() { properties.put("second", TypeIdentifier.ofType(Types.PRIMITIVE_INT)); //properties.put("child", identifier); @JsonIgnore - return Collections.singleton(TypeRepresentation.ofConcrete(identifier, properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass24.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass24.java index dfe324f..2f290d3 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass24.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass24.java @@ -46,7 +46,7 @@ public static Set expectedTypeRepresentations() { properties.put("first", TypeIdentifier.ofType(Types.PRIMITIVE_INT)); final TypeIdentifier testClass24Identifier = expectedIdentifier(); - final TypeRepresentation testClass24 = TypeRepresentation.ofConcrete(testClass24Identifier, properties); + final TypeRepresentation testClass24 = TypeRepresentation.ofConcreteBuilder().identifier(testClass24Identifier).properties(properties).build(); return new HashSet<>(Arrays.asList(testClass24)); diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass25.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass25.java index d8d5bf0..3121ce8 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass25.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass25.java @@ -63,7 +63,7 @@ public static Set expectedTypeRepresentations() { properties.put("publicField", TypeUtils.STRING_IDENTIFIER); properties.put("int", TypeIdentifier.ofType(Types.PRIMITIVE_INT)); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass26.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass26.java index 33bbb19..5cc021a 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass26.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass26.java @@ -30,7 +30,7 @@ public static Set expectedTypeRepresentations() { properties.put("foobar", TypeUtils.STRING_IDENTIFIER); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass27.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass27.java index e23e3a7..dd78f86 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass27.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass27.java @@ -34,7 +34,7 @@ public static Set expectedTypeRepresentations() { properties.put("foobar", TypeUtils.STRING_IDENTIFIER); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass28.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass28.java index 8939e4d..d3a8892 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass28.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass28.java @@ -30,7 +30,7 @@ public static Set expectedTypeRepresentations() { properties.put("foobar", TypeUtils.STRING_IDENTIFIER); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass29.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass29.java index 81253e1..9959f94 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass29.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass29.java @@ -64,7 +64,7 @@ public static Set expectedTypeRepresentations() { properties.put("publicField", TypeUtils.STRING_IDENTIFIER); properties.put("int", TypeIdentifier.ofType(Types.PRIMITIVE_INT)); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass3.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass3.java index bbde20f..5461d89 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass3.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass3.java @@ -20,10 +20,16 @@ import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeIdentifier; import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeRepresentation; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; -import java.util.*; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) @@ -54,9 +60,10 @@ public static Set expectedTypeRepresentations() { properties.put("second", typeIdentifier); properties.put("third", anotherInnerIdentifier); - final TypeRepresentation testClass3 = TypeRepresentation.ofConcrete(expectedIdentifier(), properties); - final TypeRepresentation innerClass = TypeRepresentation.ofConcrete(innerClassIdentifier, Collections.singletonMap("name", TypeUtils.STRING_IDENTIFIER)); - final TypeRepresentation anotherInner = TypeRepresentation.ofConcrete(anotherInnerIdentifier); + final TypeRepresentation testClass3 = TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build(); + final TypeRepresentation innerClass = TypeRepresentation.ofConcreteBuilder().identifier(innerClassIdentifier) + .properties(Collections.singletonMap("name", TypeUtils.STRING_IDENTIFIER)).build(); + final TypeRepresentation anotherInner = TypeRepresentation.ofConcreteBuilder().identifier(anotherInnerIdentifier).build(); final TypeRepresentation type = TypeRepresentation.ofEnum(typeIdentifier, "ONE", "TWO", "THREE"); return new HashSet<>(Arrays.asList(testClass3, innerClass, anotherInner, type)); diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass30.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass30.java index 1092e1d..3443ef2 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass30.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass30.java @@ -70,7 +70,7 @@ public static Set expectedTypeRepresentations() { properties.put("int", TypeIdentifier.ofType(Types.PRIMITIVE_INT)); properties.put("testname", TypeIdentifier.ofType(Types.PRIMITIVE_BOOLEAN)); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass4.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass4.java index 0fd4471..7d443e4 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass4.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass4.java @@ -43,7 +43,7 @@ public static Set expectedTypeRepresentations() { properties.put("first", TypeIdentifier.ofType("Ljava/time/LocalDate;")); properties.put("second", TypeIdentifier.ofType(Types.DATE)); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass5.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass5.java index 4bcc780..cf5c635 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass5.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass5.java @@ -50,8 +50,8 @@ public static Set expectedTypeRepresentations() { properties.put("first", listIdentifier); properties.put("second", setIdentifier); - final TypeRepresentation testClass5 = TypeRepresentation.ofConcrete(expectedIdentifier(), properties); - final TypeRepresentation string = TypeRepresentation.ofConcrete(TypeUtils.STRING_IDENTIFIER); + final TypeRepresentation testClass5 = TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build(); + final TypeRepresentation string = TypeRepresentation.ofConcreteBuilder().identifier(TypeUtils.STRING_IDENTIFIER).build(); final TypeRepresentation listString = TypeRepresentation.ofCollection(listIdentifier, string); final TypeRepresentation setString = TypeRepresentation.ofCollection(setIdentifier, string); diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass6.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass6.java index 4f0c66f..010606f 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass6.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass6.java @@ -60,7 +60,7 @@ public static Set expectedTypeRepresentations() { properties.put("second", TypeUtils.STRING_IDENTIFIER); properties.put("third", TypeUtils.STRING_IDENTIFIER); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass7.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass7.java index 20f4bd5..c16a205 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass7.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass7.java @@ -54,7 +54,7 @@ public static Set expectedTypeRepresentations() { properties.put("second", TypeUtils.STRING_IDENTIFIER); properties.put("third", TypeUtils.STRING_IDENTIFIER); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass8.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass8.java index d685bcb..c6ec797 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass8.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/testclasses/typeanalyzer/TestClass8.java @@ -51,7 +51,7 @@ public static Set expectedTypeRepresentations() { properties.put("third", TypeUtils.STRING_IDENTIFIER); - return Collections.singleton(TypeRepresentation.ofConcrete(expectedIdentifier(), properties)); + return Collections.singleton(TypeRepresentation.ofConcreteBuilder().identifier(expectedIdentifier()).properties(properties).build()); } public static TypeIdentifier expectedIdentifier() { diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/JsonRepresentationAppenderTest.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/JsonRepresentationAppenderTest.java index 36b17d4..21cc19c 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/JsonRepresentationAppenderTest.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/JsonRepresentationAppenderTest.java @@ -32,13 +32,13 @@ public void setup() { @Test public void testVisitPrimitive() { - TypeRepresentation.ofConcrete(TypeIdentifier.ofType(Types.STRING)).accept(cut); + TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofType(Types.STRING)).build().accept(cut); assertThat(builder.toString(), is("\"string\"")); } @Test public void testMissingRepresentation() { - TypeRepresentation.ofCollection(STRING_LIST_IDENTIFIER, TypeRepresentation.ofConcrete(STRING_IDENTIFIER)).accept(cut); + TypeRepresentation.ofCollection(STRING_LIST_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(STRING_IDENTIFIER).build()).accept(cut); assertThat(builder.toString(), is("[\"string\"]")); } @@ -56,7 +56,7 @@ public void testEnumEmpty() { @Test public void testVisitSimpleList() { - final TypeRepresentation stringRepresentation = TypeRepresentation.ofConcrete(STRING_IDENTIFIER); + final TypeRepresentation stringRepresentation = TypeRepresentation.ofConcreteBuilder().identifier(STRING_IDENTIFIER).build(); final TypeRepresentation listRepresentation = TypeRepresentation.ofCollection(STRING_LIST_IDENTIFIER, stringRepresentation); representations.put(STRING_LIST_IDENTIFIER, listRepresentation); @@ -80,7 +80,7 @@ public void testVisitSimpleList() { public void testVisitMultipleList() { final TypeIdentifier identifier = TypeIdentifier.ofType("java.util.List>"); final TypeRepresentation representation = TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofCollection(STRING_LIST_IDENTIFIER, - TypeRepresentation.ofConcrete(STRING_IDENTIFIER))); + TypeRepresentation.ofConcreteBuilder().identifier(STRING_IDENTIFIER).build())); representations.put(identifier, representation); representation.accept(cut); @@ -97,11 +97,11 @@ public void testVisitMultipleList() { @Test public void testVisitDynamic() { - TypeRepresentation.ofConcrete(TypeIdentifier.ofDynamic()).accept(cut); + TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofDynamic()).build().accept(cut); assertThat(builder.toString(), is("{}")); clear(builder); - TypeRepresentation.ofCollection(TypeIdentifier.ofDynamic(), TypeRepresentation.ofConcrete(TypeIdentifier.ofDynamic())).accept(cut); + TypeRepresentation.ofCollection(TypeIdentifier.ofDynamic(), TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofDynamic()).build()).accept(cut); assertThat(builder.toString(), is("[{}]")); } @@ -114,7 +114,7 @@ public void testVisitConcrete() { properties.put("hello", STRING_IDENTIFIER); properties.put("abc", STRING_IDENTIFIER); properties.put("enumeration", enumIdentifier); - final TypeRepresentation representation = TypeRepresentation.ofConcrete(identifier, properties); + final TypeRepresentation representation = TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build(); final TypeRepresentation enumRepresentation = TypeRepresentation.ofEnum(identifier, "FOO", "BAR", "BAZ"); representations.put(identifier, representation); @@ -131,7 +131,7 @@ public void testVisitConcreteWithNested() { properties.put("hello", STRING_IDENTIFIER); properties.put("abc", STRING_IDENTIFIER); properties.put("model", identifier); - final TypeRepresentation representation = TypeRepresentation.ofConcrete(identifier, properties); + final TypeRepresentation representation = TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build(); representations.put(identifier, representation); representation.accept(cut); @@ -148,7 +148,7 @@ public void testVisitConcreteWithNestedPreventSuppression() { properties.put("world", INT_IDENTIFIER); properties.put("abc", STRING_IDENTIFIER); properties.put("model", modelIdentifier); - final TypeRepresentation dateRepresentation = TypeRepresentation.ofConcrete(dateIdentifier, properties); + final TypeRepresentation dateRepresentation = TypeRepresentation.ofConcreteBuilder().identifier(dateIdentifier).properties(properties).build(); representations.put(dateIdentifier, dateRepresentation); properties = new HashMap<>(); @@ -156,7 +156,7 @@ public void testVisitConcreteWithNestedPreventSuppression() { properties.put("hello", STRING_IDENTIFIER); properties.put("abc", STRING_IDENTIFIER); properties.put("model", modelIdentifier); - final TypeRepresentation objectRepresentation = TypeRepresentation.ofConcrete(objectIdentifier, properties); + final TypeRepresentation objectRepresentation = TypeRepresentation.ofConcreteBuilder().identifier(objectIdentifier).properties(properties).build(); representations.put(objectIdentifier, objectRepresentation); properties = new HashMap<>(); @@ -165,7 +165,7 @@ public void testVisitConcreteWithNestedPreventSuppression() { properties.put("abc", STRING_IDENTIFIER); properties.put("date", dateIdentifier); properties.put("object", objectIdentifier); - final TypeRepresentation modelRepresentation = TypeRepresentation.ofConcrete(modelIdentifier, properties); + final TypeRepresentation modelRepresentation = TypeRepresentation.ofConcreteBuilder().identifier(modelIdentifier).properties(properties).build(); representations.put(modelIdentifier, modelRepresentation); // date @@ -208,7 +208,7 @@ public void testVisitRecursiveType() { properties.put("hello", STRING_IDENTIFIER); properties.put("abc", STRING_IDENTIFIER); properties.put("model", modelIdentifier); - final TypeRepresentation modelRepresentation = TypeRepresentation.ofConcrete(modelIdentifier, properties); + final TypeRepresentation modelRepresentation = TypeRepresentation.ofConcreteBuilder().identifier(modelIdentifier).properties(properties).build(); representations.put(modelIdentifier, modelRepresentation); modelRepresentation.accept(cut); @@ -228,13 +228,13 @@ public void testVisitCyclicRecursiveType() { Map properties = new HashMap<>(); properties.put("world", INT_IDENTIFIER); properties.put("model", secondModelIdentifier); - final TypeRepresentation firstModelRepresentation = TypeRepresentation.ofConcrete(firstModelIdentifier, properties); + final TypeRepresentation firstModelRepresentation = TypeRepresentation.ofConcreteBuilder().identifier(firstModelIdentifier).properties(properties).build(); representations.put(firstModelIdentifier, firstModelRepresentation); properties = new HashMap<>(); properties.put("hello", STRING_IDENTIFIER); properties.put("model", firstModelIdentifier); - final TypeRepresentation secondModelRepresentation = TypeRepresentation.ofConcrete(secondModelIdentifier, properties); + final TypeRepresentation secondModelRepresentation = TypeRepresentation.ofConcreteBuilder().identifier(secondModelIdentifier).properties(properties).build(); representations.put(secondModelIdentifier, secondModelRepresentation); firstModelRepresentation.accept(cut); diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/asciidoc/AsciiDocBackendTest.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/asciidoc/AsciiDocBackendTest.java index ac8c9ac..3ddd47d 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/asciidoc/AsciiDocBackendTest.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/asciidoc/AsciiDocBackendTest.java @@ -1,11 +1,22 @@ package com.sebastian_daschner.jaxrs_analyzer.backend.asciidoc; +import static com.sebastian_daschner.jaxrs_analyzer.analysis.results.TypeUtils.ENUM_IDENTIFIER; +import static com.sebastian_daschner.jaxrs_analyzer.analysis.results.TypeUtils.MODEL_IDENTIFIER; +import static com.sebastian_daschner.jaxrs_analyzer.backend.StringBackend.INLINE_PRETTIFY; +import static java.util.Collections.singletonMap; +import static org.junit.Assert.assertEquals; + import com.sebastian_daschner.jaxrs_analyzer.backend.Backend; import com.sebastian_daschner.jaxrs_analyzer.builder.ResourceMethodBuilder; import com.sebastian_daschner.jaxrs_analyzer.builder.ResourcesBuilder; import com.sebastian_daschner.jaxrs_analyzer.builder.ResponseBuilder; import com.sebastian_daschner.jaxrs_analyzer.model.Types; -import com.sebastian_daschner.jaxrs_analyzer.model.rest.*; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.HttpMethod; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.Project; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.Resources; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeIdentifier; +import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeRepresentation; + import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -15,12 +26,6 @@ import java.util.LinkedList; import java.util.Map; -import static com.sebastian_daschner.jaxrs_analyzer.analysis.results.TypeUtils.ENUM_IDENTIFIER; -import static com.sebastian_daschner.jaxrs_analyzer.analysis.results.TypeUtils.MODEL_IDENTIFIER; -import static com.sebastian_daschner.jaxrs_analyzer.backend.StringBackend.INLINE_PRETTIFY; -import static java.util.Collections.singletonMap; -import static org.junit.Assert.assertEquals; - @RunWith(Parameterized.class) public class AsciiDocBackendTest { @@ -106,7 +111,7 @@ public static Collection data() { properties.put("another", intIdentifier); final Resources getRestRes1Json = ResourcesBuilder.withBase("rest") .andTypeRepresentation(identifier, - TypeRepresentation.ofConcrete(identifier, properties)) + TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build()) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody( @@ -145,8 +150,8 @@ public static Collection data() { properties = new HashMap<>(); properties.put("key", stringIdentifier); properties.put("another", intIdentifier); - add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(TypeIdentifier.ofDynamic(), properties))) + add(data, ResourcesBuilder.withBase("rest").andTypeRepresentation(identifier, TypeRepresentation + .ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofDynamic()).properties(properties).build())) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "= REST resources of project name\n" + @@ -164,7 +169,7 @@ public static Collection data() { identifier = TypeIdentifier.ofDynamic(); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(stringIdentifier))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(stringIdentifier).build())) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "= REST resources of project name\n" + @@ -185,8 +190,8 @@ public static Collection data() { identifier = TypeIdentifier.ofDynamic(); properties = new HashMap<>(); properties.put("key", stringIdentifier); - add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(TypeIdentifier.ofDynamic(), properties))) + add(data, ResourcesBuilder.withBase("rest").andTypeRepresentation(identifier, TypeRepresentation + .ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofDynamic()).properties(properties).build())) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "= REST resources of project name\n" + @@ -208,7 +213,7 @@ public static Collection data() { properties.put("name", stringIdentifier); properties.put("value", intIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(MODEL_IDENTIFIER, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties)) + .andTypeRepresentation(MODEL_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build()) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(MODEL_IDENTIFIER).build()).build()).build(), "= REST resources of project name\n" + @@ -230,8 +235,8 @@ public static Collection data() { properties = new HashMap<>(); properties.put("name", stringIdentifier); properties.put("value", intIdentifier); - add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties))) + add(data, ResourcesBuilder.withBase("rest").andTypeRepresentation(identifier, + TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build())) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "= REST resources of project name\n" + @@ -273,8 +278,8 @@ public static Collection data() { properties = new HashMap<>(); properties.put("name", stringIdentifier); properties.put("value", intIdentifier); - add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties))) + add(data, ResourcesBuilder.withBase("rest").andTypeRepresentation(identifier, + TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build())) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.POST).andRequestBodyType(identifier).andFormParam("form", MODEL_IDENTIFIER.getType()) .andAcceptMediaTypes("application/json").andResponse(201, ResponseBuilder.newBuilder().andHeaders("Location").build()).build()).build(), "= REST resources of project name\n" + @@ -294,8 +299,8 @@ public static Collection data() { "==== `201 Created`\n" + "*Header*: `Location` + \n\n", false); - add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties))) + add(data, ResourcesBuilder.withBase("rest").andTypeRepresentation(identifier, + TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build())) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.POST).andRequestBodyType(identifier).andQueryParam("query", Types.PRIMITIVE_INT) .andAcceptMediaTypes("application/json").andResponse(201, ResponseBuilder.newBuilder().andHeaders("Location").build()).build()) .andResource("res2", ResourceMethodBuilder.withMethod(HttpMethod.GET).andResponse(200, ResponseBuilder.newBuilder().build()).build()).build(), diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/markdown/MarkdownBackendTest.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/markdown/MarkdownBackendTest.java index bb7a675..5ae6b56 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/markdown/MarkdownBackendTest.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/markdown/MarkdownBackendTest.java @@ -113,7 +113,7 @@ public static Collection data() { properties.put("another", intIdentifier); final Resources getRestRes1Json = ResourcesBuilder.withBase("rest") .andTypeRepresentation(identifier, - TypeRepresentation.ofConcrete(identifier, properties)) + TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build()) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody( @@ -153,7 +153,7 @@ public static Collection data() { properties.put("key", stringIdentifier); properties.put("another", intIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(TypeIdentifier.ofDynamic(), properties))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofDynamic()).properties(properties).build())) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "# REST resources of project name\n\n" + @@ -171,7 +171,7 @@ public static Collection data() { identifier = TypeIdentifier.ofDynamic(); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(stringIdentifier))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(stringIdentifier).build())) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "# REST resources of project name\n\n" + @@ -193,7 +193,7 @@ public static Collection data() { properties = new HashMap<>(); properties.put("key", stringIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(TypeIdentifier.ofDynamic(), properties))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofDynamic()).properties(properties).build())) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "# REST resources of project name\n\n" + @@ -215,7 +215,7 @@ public static Collection data() { properties.put("name", stringIdentifier); properties.put("value", intIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(MODEL_IDENTIFIER, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties)) + .andTypeRepresentation(MODEL_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build()) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(MODEL_IDENTIFIER).build()).build()).build(), "# REST resources of project name\n\n" + @@ -238,7 +238,7 @@ public static Collection data() { properties.put("name", stringIdentifier); properties.put("value", intIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build())) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "# REST resources of project name\n\n" + @@ -257,7 +257,7 @@ public static Collection data() { "```javascript\n" + "[{\"name\":\"string\",\"value\":0}]\n" + "```\n\n\n\n", false); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build())) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.POST).andRequestBodyType(identifier).andFormParam("form", MODEL_IDENTIFIER.getType()) .andAcceptMediaTypes("application/json").andResponse(201, ResponseBuilder.newBuilder().andHeaders("Location").build()).build()).build(), "# REST resources of project name\n\n" + @@ -278,7 +278,7 @@ public static Collection data() { "*Header*: `Location` + \n\n", false); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build())) .andResource("res1", ResourceMethodBuilder.withMethod(HttpMethod.POST).andRequestBodyType(identifier).andQueryParam("query", Types.PRIMITIVE_INT) .andAcceptMediaTypes("application/json").andResponse(201, ResponseBuilder.newBuilder().andHeaders("Location").build()).build()) .andResource("res2", ResourceMethodBuilder.withMethod(HttpMethod.GET).andResponse(200, ResponseBuilder.newBuilder().build()).build()).build(), diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/plaintext/PlainTextBackendTest.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/plaintext/PlainTextBackendTest.java index d360af1..bbe0c01 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/plaintext/PlainTextBackendTest.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/plaintext/PlainTextBackendTest.java @@ -77,7 +77,7 @@ public static Collection data() { properties.put("key", stringIdentifier); properties.put("another", intIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofConcrete(identifier, properties)) + .andTypeRepresentation(identifier, TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build()) .andResource("res2", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "REST resources of project name:\n" + @@ -98,7 +98,7 @@ public static Collection data() { properties.put("key", stringIdentifier); properties.put("another", intIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(TypeIdentifier.ofDynamic(), properties))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofDynamic()).properties(properties).build())) .andResource("res3", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "REST resources of project name:\n" + @@ -116,7 +116,7 @@ public static Collection data() { identifier = TypeIdentifier.ofDynamic(); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(stringIdentifier))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(stringIdentifier).build())) .andResource("res4", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "REST resources of project name:\n" + @@ -136,7 +136,7 @@ public static Collection data() { properties = new HashMap<>(); properties.put("key", stringIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(TypeIdentifier.ofDynamic(), properties))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofDynamic()).properties(properties).build())) .andResource("res5", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "REST resources of project name:\n" + @@ -156,7 +156,7 @@ public static Collection data() { properties.put("name", stringIdentifier); properties.put("value", intIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(MODEL_IDENTIFIER, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties)) + .andTypeRepresentation(MODEL_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build()) .andResource("res6", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(MODEL_IDENTIFIER).build()).build()).build(), "REST resources of project name:\n" + @@ -177,7 +177,7 @@ public static Collection data() { properties.put("name", stringIdentifier); properties.put("value", intIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build())) .andResource("res7", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "REST resources of project name:\n" + @@ -194,7 +194,7 @@ public static Collection data() { " [{\"name\":\"string\",\"value\":0}]\n\n\n"); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build())) .andResource("res8", ResourceMethodBuilder.withMethod(HttpMethod.POST).andRequestBodyType(identifier).andFormParam("form", MODEL_IDENTIFIER.getType()) .andAcceptMediaTypes("application/json").andResponse(201, ResponseBuilder.newBuilder().andHeaders("Location").build()).build()).build(), "REST resources of project name:\n" + @@ -213,7 +213,7 @@ public static Collection data() { " Header: Location\n\n\n"); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build())) .andResource("res9", ResourceMethodBuilder.withMethod(HttpMethod.POST).andRequestBodyType(identifier).andQueryParam("query", Types.PRIMITIVE_INT) .andAcceptMediaTypes("application/json").andResponse(201, ResponseBuilder.newBuilder().andHeaders("Location").build()).build()) .andResource("res10", ResourceMethodBuilder.withMethod(HttpMethod.GET).andResponse(200, ResponseBuilder.newBuilder().build()).build()).build(), diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/swagger/SchemaBuilderTest.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/swagger/SchemaBuilderTest.java index 059eff9..3bfd547 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/swagger/SchemaBuilderTest.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/swagger/SchemaBuilderTest.java @@ -1,20 +1,25 @@ package com.sebastian_daschner.jaxrs_analyzer.backend.swagger; +import static com.sebastian_daschner.jaxrs_analyzer.analysis.results.TypeUtils.INT_IDENTIFIER; +import static com.sebastian_daschner.jaxrs_analyzer.analysis.results.TypeUtils.MODEL_IDENTIFIER; +import static com.sebastian_daschner.jaxrs_analyzer.analysis.results.TypeUtils.OBJECT_IDENTIFIER; +import static com.sebastian_daschner.jaxrs_analyzer.analysis.results.TypeUtils.STRING_IDENTIFIER; +import static com.sebastian_daschner.jaxrs_analyzer.backend.swagger.TypeIdentifierTestSupport.resetTypeIdentifierCounter; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + import com.sebastian_daschner.jaxrs_analyzer.model.Types; import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeIdentifier; import com.sebastian_daschner.jaxrs_analyzer.model.rest.TypeRepresentation; + import org.junit.Before; import org.junit.Test; -import javax.json.Json; -import javax.json.JsonObject; import java.util.HashMap; import java.util.Map; -import static com.sebastian_daschner.jaxrs_analyzer.analysis.results.TypeUtils.*; -import static com.sebastian_daschner.jaxrs_analyzer.backend.swagger.TypeIdentifierTestSupport.resetTypeIdentifierCounter; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; +import javax.json.Json; +import javax.json.JsonObject; public class SchemaBuilderTest { @@ -32,7 +37,7 @@ public void resetRepresentations() { @Test public void testSimpleDefinitions() { - representations.put(INT_LIST_IDENTIFIER, TypeRepresentation.ofCollection(INTEGER_IDENTIFIER, TypeRepresentation.ofConcrete(INTEGER_IDENTIFIER))); + representations.put(INT_LIST_IDENTIFIER, TypeRepresentation.ofCollection(INTEGER_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(INTEGER_IDENTIFIER).build())); final TypeIdentifier modelIdentifier = MODEL_IDENTIFIER; final Map modelProperties = new HashMap<>(); @@ -41,7 +46,15 @@ public void testSimpleDefinitions() { modelProperties.put("hello1", STRING_IDENTIFIER); modelProperties.put("array1", INT_LIST_IDENTIFIER); - representations.put(modelIdentifier, TypeRepresentation.ofConcrete(modelIdentifier, modelProperties)); + final Map modelPropertyComments = new HashMap<>(); + + modelPropertyComments.put("test1", "This is a description for test1"); + modelPropertyComments.put("hello1", "Some other description"); + modelPropertyComments.put("array1", "This is an array"); + + representations.put(modelIdentifier, + TypeRepresentation.ofConcreteBuilder().identifier(modelIdentifier).description("Our overall model").properties(modelProperties) + .propertyDescriptions(modelPropertyComments).build()); final Map dynamicProperties = new HashMap<>(); @@ -55,8 +68,8 @@ public void testSimpleDefinitions() { dynamicProperties.put("object2", nestedDynamicIdentifier); - representations.put(nestedDynamicIdentifier, TypeRepresentation.ofConcrete(nestedDynamicIdentifier, nestedDynamicProperties)); - representations.put(OBJECT_IDENTIFIER, TypeRepresentation.ofConcrete(OBJECT_IDENTIFIER, dynamicProperties)); + representations.put(nestedDynamicIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(nestedDynamicIdentifier).properties(nestedDynamicProperties).build()); + representations.put(OBJECT_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(OBJECT_IDENTIFIER).properties(dynamicProperties).build()); cut = new SchemaBuilder(representations); assertThat(cut.build(modelIdentifier).build(), is(Json.createObjectBuilder().add("$ref", "#/definitions/Model").build())); @@ -64,10 +77,10 @@ public void testSimpleDefinitions() { final JsonObject definitions = cut.getDefinitions(); assertThat(definitions, is(Json.createObjectBuilder() - .add("Model", Json.createObjectBuilder().add("properties", Json.createObjectBuilder() - .add("array1", Json.createObjectBuilder().add("type", "array").add("items", type("integer"))) - .add("hello1", type("string")) - .add("test1", type("integer")))) + .add("Model", Json.createObjectBuilder().add("description", "Our overall model").add("properties", Json.createObjectBuilder() + .add("array1", Json.createObjectBuilder().add("type", "array").add("items", type("integer")).add("description", "This is an array")) + .add("hello1", typeWithDesc("string", "Some other description")) + .add("test1", typeWithDesc("integer", "This is a description for test1")))) .add("JsonObject", Json.createObjectBuilder().add("properties", Json.createObjectBuilder().add("test", type("integer")))) .add("Object", Json.createObjectBuilder().add("properties", Json.createObjectBuilder() .add("array2", Json.createObjectBuilder().add("type", "array").add("items", type("integer"))) @@ -92,9 +105,9 @@ public void testMultipleDefinitionsNameCollisions() { anotherLockProperties.put("hello1", STRING_IDENTIFIER); anotherLockProperties.put("array1", INT_LIST_IDENTIFIER); - representations.put(INT_LIST_IDENTIFIER, TypeRepresentation.ofCollection(INTEGER_IDENTIFIER, TypeRepresentation.ofConcrete(INTEGER_IDENTIFIER))); - representations.put(lockIdentifier, TypeRepresentation.ofConcrete(lockIdentifier, lockProperties)); - representations.put(anotherLockIdentifier, TypeRepresentation.ofConcrete(anotherLockIdentifier, anotherLockProperties)); + representations.put(INT_LIST_IDENTIFIER, TypeRepresentation.ofCollection(INTEGER_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(INTEGER_IDENTIFIER).build())); + representations.put(lockIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(lockIdentifier).properties(lockProperties).build()); + representations.put(anotherLockIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(anotherLockIdentifier).properties(anotherLockProperties).build()); cut = new SchemaBuilder(representations); @@ -124,7 +137,7 @@ public void testSingleDynamicDefinitionMissingNestedType() { // unknown type identifier properties.put("array1", INT_LIST_IDENTIFIER); - representations.put(identifier, TypeRepresentation.ofConcrete(identifier, properties)); + representations.put(identifier, TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build()); cut = new SchemaBuilder(representations); @@ -139,6 +152,40 @@ public void testSingleDynamicDefinitionMissingNestedType() { .build())); } + @Test + public void testSimpleDefinitionSomeMissingComments() { + representations.put(INT_LIST_IDENTIFIER, TypeRepresentation.ofCollection(INTEGER_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(INTEGER_IDENTIFIER).build())); + + final TypeIdentifier modelIdentifier = MODEL_IDENTIFIER; + final Map modelProperties = new HashMap<>(); + + modelProperties.put("test1", INT_IDENTIFIER); + modelProperties.put("hello1", STRING_IDENTIFIER); + modelProperties.put("hello2", STRING_IDENTIFIER); + modelProperties.put("array1", INT_LIST_IDENTIFIER); + + final Map modelPropertyComments = new HashMap<>(); + + modelPropertyComments.put("test1", "This is a description for test1"); + modelPropertyComments.put("hello2", "This is a description for hello2"); + + representations.put(modelIdentifier, + TypeRepresentation.ofConcreteBuilder().identifier(modelIdentifier).description("Our overall model").properties(modelProperties) + .propertyDescriptions(modelPropertyComments).build()); + + cut = new SchemaBuilder(representations); + assertThat(cut.build(modelIdentifier).build(), is(Json.createObjectBuilder().add("$ref", "#/definitions/Model").build())); + + final JsonObject definitions = cut.getDefinitions(); + assertThat(definitions, is(Json.createObjectBuilder() + .add("Model", Json.createObjectBuilder().add("description", "Our overall model").add("properties", Json.createObjectBuilder() + .add("array1", Json.createObjectBuilder().add("type", "array").add("items", type("integer"))) + .add("hello1", type("string")) + .add("hello2", typeWithDesc("string", "This is a description for hello2")) + .add("test1", typeWithDesc("integer", "This is a description for test1")))) + .build())); + } + @Test public void testMultipleDifferentDefinitions() { final Map properties = new HashMap<>(); @@ -147,8 +194,8 @@ public void testMultipleDifferentDefinitions() { properties.put("hello1", STRING_IDENTIFIER); properties.put("array1", INT_LIST_IDENTIFIER); - representations.put(MODEL_IDENTIFIER, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties)); - representations.put(INT_LIST_IDENTIFIER, TypeRepresentation.ofCollection(INTEGER_IDENTIFIER, TypeRepresentation.ofConcrete(INTEGER_IDENTIFIER))); + representations.put(MODEL_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build()); + representations.put(INT_LIST_IDENTIFIER, TypeRepresentation.ofCollection(INTEGER_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(INTEGER_IDENTIFIER).build())); cut = new SchemaBuilder(representations); @@ -180,9 +227,9 @@ public void testSameDynamicDefinitions() { final Map secondProperties = new HashMap<>(); secondProperties.put("nested", firstIdentifier); - representations.put(INT_LIST_IDENTIFIER, TypeRepresentation.ofCollection(INTEGER_IDENTIFIER, TypeRepresentation.ofConcrete(INTEGER_IDENTIFIER))); - representations.put(firstIdentifier, TypeRepresentation.ofConcrete(firstIdentifier, firstProperties)); - representations.put(secondIdentifier, TypeRepresentation.ofConcrete(secondIdentifier, secondProperties)); + representations.put(INT_LIST_IDENTIFIER, TypeRepresentation.ofCollection(INTEGER_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(INTEGER_IDENTIFIER).build())); + representations.put(firstIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(firstIdentifier).properties(firstProperties).build()); + representations.put(secondIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(secondIdentifier).properties(secondProperties).build()); cut = new SchemaBuilder(representations); @@ -217,9 +264,9 @@ public void testDifferentDynamicDefinitions() { final Map thirdProperties = new HashMap<>(); thirdProperties.put("href", STRING_IDENTIFIER); - representations.put(firstIdentifier, TypeRepresentation.ofConcrete(firstIdentifier, firstProperties)); - representations.put(secondIdentifier, TypeRepresentation.ofConcrete(secondIdentifier, secondProperties)); - representations.put(thirdIdentifier, TypeRepresentation.ofConcrete(thirdIdentifier, thirdProperties)); + representations.put(firstIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(firstIdentifier).properties(firstProperties).build()); + representations.put(secondIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(secondIdentifier).properties(secondProperties).build()); + representations.put(thirdIdentifier, TypeRepresentation.ofConcreteBuilder().identifier(thirdIdentifier).properties(thirdProperties).build()); cut = new SchemaBuilder(representations); @@ -241,12 +288,17 @@ public void testDifferentDynamicDefinitions() { @Test public void testEnumDefinitions() { final TypeIdentifier enumIdentifier = TypeIdentifier.ofType("Lcom/sebastian_daschner/test/Enumeration;"); - final Map modelProperties = new HashMap<>(); + final Map modelProperties = new HashMap<>(); modelProperties.put("foobar", enumIdentifier); modelProperties.put("hello1", STRING_IDENTIFIER); - representations.put(MODEL_IDENTIFIER, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, modelProperties)); + final Map propertyDescriptions = new HashMap<>(); + propertyDescriptions.put("foobar", "foobar is important, so here is its JavaDoc-type comment."); + propertyDescriptions.put("hello1", "Another comment here."); + + representations.put(MODEL_IDENTIFIER, + TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(modelProperties).propertyDescriptions(propertyDescriptions).build()); representations.put(enumIdentifier, TypeRepresentation.ofEnum(enumIdentifier, "THIRD", "FIRST", "SECOND")); cut = new SchemaBuilder(representations); @@ -257,9 +309,10 @@ public void testEnumDefinitions() { final JsonObject definitions = cut.getDefinitions(); assertThat(definitions, is(Json.createObjectBuilder() - .add("Model", Json.createObjectBuilder().add("properties", Json.createObjectBuilder() - .add("foobar", Json.createObjectBuilder().add("type", "string").add("enum", Json.createArrayBuilder().add("FIRST").add("SECOND").add("THIRD"))) - .add("hello1", type("string")))) + .add("Model", Json.createObjectBuilder().add("properties", Json.createObjectBuilder().add("foobar", + Json.createObjectBuilder().add("type", "string").add("enum", Json.createArrayBuilder().add("FIRST").add("SECOND").add("THIRD")) + .add("description", "foobar is important, so here is its JavaDoc-type comment.")) + .add("hello1", typeWithDesc("string", "Another comment here.")))) .build())); } @@ -267,4 +320,8 @@ private static JsonObject type(final String type) { return Json.createObjectBuilder().add("type", type).build(); } + private static JsonObject typeWithDesc(final String type, final String description) { + return Json.createObjectBuilder().add("type", type).add("description", description).build(); + } + } \ No newline at end of file diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/swagger/SwaggerBackendTest.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/swagger/SwaggerBackendTest.java index 09a89d0..b6c2663 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/swagger/SwaggerBackendTest.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/backend/swagger/SwaggerBackendTest.java @@ -101,7 +101,7 @@ public static Collection data() { identifier = TypeIdentifier.ofDynamic(); properties.put("key", stringIdentifier); properties.put("another", intIdentifier); - add(data, ResourcesBuilder.withBase("rest").andTypeRepresentation(identifier, TypeRepresentation.ofConcrete(identifier, properties)) + add(data, ResourcesBuilder.withBase("rest").andTypeRepresentation(identifier, TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build()) .andResource("res2", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "{\"swagger\":\"2.0\",\"info\":{\"version\":\"1.0\",\"title\":\"project name\"},\"host\":\"example.com\",\"basePath\":\"/rest\",\"schemes\":[\"http\"],\"paths\":{\"/res2\":{\"get\":{\"consumes\":[],\"produces\":[],\"parameters\":[],\"responses\":{\"200\":{\"description\":\"OK\",\"headers\":{},\"schema\":{\"$ref\":\"#/definitions/JsonObject\"}}}}}},\"definitions\":{\"JsonObject\":{\"properties\":{\"another\":{\"type\":\"integer\"},\"key\":{\"type\":\"string\"}}}}}"); @@ -112,7 +112,7 @@ public static Collection data() { properties.put("key", stringIdentifier); properties.put("another", intIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(TypeIdentifier.ofDynamic(), properties))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofDynamic()).properties(properties).build())) .andResource("res3", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "{\"swagger\":\"2.0\",\"info\":{\"version\":\"1.0\",\"title\":\"project name\"},\"host\":\"example.com\",\"basePath\":\"/rest\",\"schemes\":[\"http\"],\"paths\":{\"/res3\":{\"get\":{\"consumes\":[],\"produces\":[],\"parameters\":[],\"responses\":{\"200\":{\"description\":\"OK\",\"headers\":{},\"schema\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/JsonObject_2\"}}}}}}},\"definitions\":{\"JsonObject_2\":{\"properties\":{\"another\":{\"type\":\"integer\"},\"key\":{\"type\":\"string\"}}}}}"); @@ -120,7 +120,7 @@ public static Collection data() { resetTypeIdentifierCounter(); identifier = TypeIdentifier.ofDynamic(); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(stringIdentifier))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(stringIdentifier).build())) .andResource("res4", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "{\"swagger\":\"2.0\",\"info\":{\"version\":\"1.0\",\"title\":\"project name\"},\"host\":\"example.com\",\"basePath\":\"/rest\",\"schemes\":[\"http\"],\"paths\":{\"/res4\":{\"get\":{\"consumes\":[],\"produces\":[],\"parameters\":[],\"responses\":{\"200\":{\"description\":\"OK\",\"headers\":{},\"schema\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}}}}}},\"definitions\":{}}"); @@ -130,7 +130,7 @@ public static Collection data() { properties = new HashMap<>(); properties.put("key", stringIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(identifier, properties))) + .andTypeRepresentation(identifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build())) .andResource("res5", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "{\"swagger\":\"2.0\",\"info\":{\"version\":\"1.0\",\"title\":\"project name\"},\"host\":\"example.com\",\"basePath\":\"/rest\",\"schemes\":[\"http\"],\"paths\":{\"/res5\":{\"get\":{\"consumes\":[],\"produces\":[],\"parameters\":[],\"responses\":{\"200\":{\"description\":\"OK\",\"headers\":{},\"schema\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/JsonObject\"}}}}}}},\"definitions\":{\"JsonObject\":{\"properties\":{\"key\":{\"type\":\"string\"}}}}}"); @@ -139,14 +139,14 @@ public static Collection data() { properties.put("name", stringIdentifier); properties.put("value", intIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(MODEL_IDENTIFIER, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties)) + .andTypeRepresentation(MODEL_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build()) .andResource("res6", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(MODEL_IDENTIFIER).build()).build()).build(), "{\"swagger\":\"2.0\",\"info\":{\"version\":\"1.0\",\"title\":\"project name\"},\"host\":\"example.com\",\"basePath\":\"/rest\",\"schemes\":[\"http\"],\"paths\":{\"/res6\":{\"get\":{\"consumes\":[],\"produces\":[],\"parameters\":[],\"responses\":{\"200\":{\"description\":\"OK\",\"headers\":{},\"schema\":{\"$ref\":\"#/definitions/Model\"}}}}}},\"definitions\":{\"Model\":{\"properties\":{\"name\":{\"type\":\"string\"},\"value\":{\"type\":\"integer\"}}}}}"); identifier = TypeIdentifier.ofType("Ljavax/ws/rs/core/StreamingOutput;"); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(identifier, TypeRepresentation.ofConcrete(identifier)) + .andTypeRepresentation(identifier, TypeRepresentation.ofConcreteBuilder().identifier(identifier).build()) .andResource("res7", ResourceMethodBuilder.withMethod(HttpMethod.GET) .andResponse(200, ResponseBuilder.withResponseBody(identifier).build()).build()).build(), "{\"swagger\":\"2.0\",\"info\":{\"version\":\"1.0\",\"title\":\"project name\"},\"host\":\"example.com\",\"basePath\":\"/rest\",\"schemes\":[\"http\"],\"paths\":{\"/res7\":{\"get\":{\"consumes\":[],\"produces\":[],\"parameters\":[],\"responses\":{\"200\":{\"description\":\"OK\",\"headers\":{},\"schema\":{\"$ref\":\"#/definitions/StreamingOutput\"}}}}}},\"definitions\":{\"StreamingOutput\":{\"properties\":{}}}}"); @@ -156,7 +156,7 @@ public static Collection data() { properties.put("name", stringIdentifier); properties.put("value", intIdentifier); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(dynamicIdentifier, TypeRepresentation.ofCollection(MODEL_IDENTIFIER, TypeRepresentation.ofConcrete(MODEL_IDENTIFIER, properties))) + .andTypeRepresentation(dynamicIdentifier, TypeRepresentation.ofCollection(MODEL_IDENTIFIER, TypeRepresentation.ofConcreteBuilder().identifier(MODEL_IDENTIFIER).properties(properties).build())) .andResource("res8", ResourceMethodBuilder.withMethod(HttpMethod.POST).andRequestBodyType(dynamicIdentifier).andAcceptMediaTypes("application/json") .andResponse(201, ResponseBuilder.newBuilder().andHeaders("Location").build()).build()).build(), "{\"swagger\":\"2.0\",\"info\":{\"version\":\"1.0\",\"title\":\"project name\"},\"host\":\"example.com\",\"basePath\":\"/rest\",\"schemes\":[\"http\"],\"paths\":{\"/res8\":{\"post\":{\"consumes\":[\"application/json\"],\"produces\":[],\"parameters\":[{\"name\":\"body\",\"in\":\"body\",\"required\":true,\"schema\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/Model\"}}}],\"responses\":{\"201\":{\"description\":\"Created\",\"headers\":{\"Location\":{\"type\":\"string\"}}}}}}},\"definitions\":{\"Model\":{\"properties\":{\"name\":{\"type\":\"string\"},\"value\":{\"type\":\"integer\"}}}}}"); @@ -210,19 +210,19 @@ public static Collection data() { // query parameter tests add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(dynamicIdentifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(identifier, properties))) + .andTypeRepresentation(dynamicIdentifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build())) .andResource("res15", ResourceMethodBuilder.withMethod(HttpMethod.GET).andQueryParam("value", "Ljava/lang/Integer;").andAcceptMediaTypes("application/json") .andResponse(200, ResponseBuilder.withResponseBody(TypeIdentifier.ofType(Types.STRING)).andHeaders("Location").build()).build()).build(), "{\"swagger\":\"2.0\",\"info\":{\"version\":\"1.0\",\"title\":\"project name\"},\"host\":\"example.com\",\"basePath\":\"/rest\",\"schemes\":[\"http\"],\"paths\":{\"/res15\":{\"get\":{\"consumes\":[\"application/json\"],\"produces\":[],\"parameters\":[{\"type\":\"integer\",\"name\":\"value\",\"in\":\"query\",\"required\":true}],\"responses\":{\"200\":{\"description\":\"OK\",\"headers\":{\"Location\":{\"type\":\"string\"}},\"schema\":{\"type\":\"string\"}}}}}},\"definitions\":{}}"); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(dynamicIdentifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(identifier, properties))) + .andTypeRepresentation(dynamicIdentifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build())) .andResource("res16", ResourceMethodBuilder.withMethod(HttpMethod.GET).andQueryParam("value", "Ljava/lang/Integer;", "test").andAcceptMediaTypes("application/json") .andResponse(200, ResponseBuilder.withResponseBody(TypeIdentifier.ofType(Types.STRING)).andHeaders("Location").build()).build()).build(), "{\"swagger\":\"2.0\",\"info\":{\"version\":\"1.0\",\"title\":\"project name\"},\"host\":\"example.com\",\"basePath\":\"/rest\",\"schemes\":[\"http\"],\"paths\":{\"/res16\":{\"get\":{\"consumes\":[\"application/json\"],\"produces\":[],\"parameters\":[{\"type\":\"integer\",\"name\":\"value\",\"in\":\"query\",\"required\":false,\"default\":\"test\"}],\"responses\":{\"200\":{\"description\":\"OK\",\"headers\":{\"Location\":{\"type\":\"string\"}},\"schema\":{\"type\":\"string\"}}}}}},\"definitions\":{}}"); add(data, ResourcesBuilder.withBase("rest") - .andTypeRepresentation(dynamicIdentifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcrete(identifier, properties))) + .andTypeRepresentation(dynamicIdentifier, TypeRepresentation.ofCollection(identifier, TypeRepresentation.ofConcreteBuilder().identifier(identifier).properties(properties).build())) .andResource("res17", ResourceMethodBuilder.withMethod(HttpMethod.GET).andQueryParam("value", "Ljava/lang/Integer;").andQueryParam("name", "Ljava/lang/String;", "foobar").andAcceptMediaTypes("application/json") .andResponse(200, ResponseBuilder.withResponseBody(TypeIdentifier.ofType(Types.STRING)).andHeaders("Location").build()).build()).build(), "{\"swagger\":\"2.0\",\"info\":{\"version\":\"1.0\",\"title\":\"project name\"},\"host\":\"example.com\",\"basePath\":\"/rest\",\"schemes\":[\"http\"],\"paths\":{\"/res17\":{\"get\":{\"consumes\":[\"application/json\"],\"produces\":[],\"parameters\":[{\"type\":\"string\",\"name\":\"name\",\"in\":\"query\",\"required\":false,\"default\":\"foobar\"},{\"type\":\"integer\",\"name\":\"value\",\"in\":\"query\",\"required\":true}],\"responses\":{\"200\":{\"description\":\"OK\",\"headers\":{\"Location\":{\"type\":\"string\"}},\"schema\":{\"type\":\"string\"}}}}}},\"definitions\":{}}"); diff --git a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/model/rest/CollectionTypeRepresentationTest.java b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/model/rest/CollectionTypeRepresentationTest.java index 1584bbc..39c6d03 100644 --- a/src/test/java/com/sebastian_daschner/jaxrs_analyzer/model/rest/CollectionTypeRepresentationTest.java +++ b/src/test/java/com/sebastian_daschner/jaxrs_analyzer/model/rest/CollectionTypeRepresentationTest.java @@ -15,15 +15,15 @@ public class CollectionTypeRepresentationTest { @Test public void testContentEqualsConcrete() { - final TypeRepresentation.ConcreteTypeRepresentation stringRepresentation = (TypeRepresentation.ConcreteTypeRepresentation) TypeRepresentation.ofConcrete(TypeIdentifier.ofType(Types.STRING)); - final TypeRepresentation.ConcreteTypeRepresentation objectRepresentation = (TypeRepresentation.ConcreteTypeRepresentation) TypeRepresentation.ofConcrete(TypeIdentifier.ofType(Types.OBJECT)); + final TypeRepresentation.ConcreteTypeRepresentation stringRepresentation = (TypeRepresentation.ConcreteTypeRepresentation) TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofType(Types.STRING)).build(); + final TypeRepresentation.ConcreteTypeRepresentation objectRepresentation = (TypeRepresentation.ConcreteTypeRepresentation) TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofType(Types.OBJECT)).build(); assertTrue(stringRepresentation.contentEquals(objectRepresentation.getProperties())); final Map firstProperties = new HashMap<>(); firstProperties.put("hello", STRING_IDENTIFIER); firstProperties.put("world", INT_IDENTIFIER); - final TypeRepresentation.ConcreteTypeRepresentation firstRepresentation = (TypeRepresentation.ConcreteTypeRepresentation) TypeRepresentation.ofConcrete(OBJECT_IDENTIFIER, firstProperties); + final TypeRepresentation.ConcreteTypeRepresentation firstRepresentation = (TypeRepresentation.ConcreteTypeRepresentation) TypeRepresentation.ofConcreteBuilder().identifier(OBJECT_IDENTIFIER).properties(firstProperties).build(); final Map secondProperties = new HashMap<>(); secondProperties.put("hello", STRING_IDENTIFIER); @@ -38,10 +38,10 @@ public void testContentEqualsCollection() { firstProperties.put("hello", STRING_IDENTIFIER); firstProperties.put("world", INT_IDENTIFIER); - final TypeRepresentation firstRepresentation = TypeRepresentation.ofConcrete(OBJECT_IDENTIFIER, firstProperties); - final TypeRepresentation secondRepresentation = TypeRepresentation.ofConcrete(OBJECT_IDENTIFIER, Collections.emptyMap()); - final TypeRepresentation thirdRepresentation = TypeRepresentation.ofConcrete(TypeIdentifier.ofDynamic(), new HashMap<>(firstProperties)); - final TypeRepresentation fourthRepresentation = TypeRepresentation.ofConcrete(TypeIdentifier.ofDynamic(), new HashMap<>(firstProperties)); + final TypeRepresentation firstRepresentation = TypeRepresentation.ofConcreteBuilder().identifier(OBJECT_IDENTIFIER).properties(firstProperties).build(); + final TypeRepresentation secondRepresentation = TypeRepresentation.ofConcreteBuilder().identifier(OBJECT_IDENTIFIER).properties(Collections.emptyMap()).build(); + final TypeRepresentation thirdRepresentation = TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofDynamic()).properties(new HashMap<>(firstProperties)).build(); + final TypeRepresentation fourthRepresentation = TypeRepresentation.ofConcreteBuilder().identifier(TypeIdentifier.ofDynamic()).properties(new HashMap<>(firstProperties)).build(); final TypeRepresentation.CollectionTypeRepresentation firstCollection = (TypeRepresentation.CollectionTypeRepresentation) TypeRepresentation.ofCollection(TypeIdentifier.ofDynamic(), firstRepresentation); final TypeRepresentation.CollectionTypeRepresentation secondCollection = (TypeRepresentation.CollectionTypeRepresentation) TypeRepresentation.ofCollection(TypeIdentifier.ofDynamic(), secondRepresentation);