Skip to content

Commit 7e94d97

Browse files
committed
check for import on short on fully qualified class name
1 parent c6a92c9 commit 7e94d97

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

modules/openapi-generator/src/test/java/org/openapitools/codegen/java/assertions/TypeAnnotationsAssert.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,25 @@ public JavaFileAssert toType() {
2323
/**
2424
* assert that the annotation is not specifed in an import.
2525
*
26-
* @param name name of the annotation. For example "Nullable";
26+
* @param name classname of the annotation. For example "Nullable" or a full qualified class name like "java.util.List"
2727
*/
2828
public TypeAnnotationsAssert doesNotImportAnnotation(final String name) {
29-
String pattern = "import\\s+[\\w.]+\\." + Pattern.quote(name) + ";";
29+
String pattern = "import\\s+" +
30+
(name.contains(".")?"" : "[\\w.]+\\.") +
31+
Pattern.quote(name) + ";";
3032
this.toType().fileDoesNotContainPattern(pattern);
3133
return this;
3234
}
3335

3436
/**
3537
* assert that the annotation is imported.
3638
*
37-
* @param name name of the annotation. For example "Nullable";
39+
* @param name clasname of the annotation. For example "Nullable" or a full qualified class name like "java.util.List"
3840
*/
3941
public TypeAnnotationsAssert doesImportAnnotation(final String name) {
40-
String pattern = "import\\s+[\\w.]+\\." + Pattern.quote(name) + ";";
42+
String pattern = "import\\s+" +
43+
(name.contains(".")?"" : "[\\w.]+\\.") +
44+
Pattern.quote(name) + ";";
4145
this.toType().fileContainsPattern(pattern);
4246
return this;
4347
}

0 commit comments

Comments
 (0)