forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerObjectArchTest.java
More file actions
46 lines (41 loc) · 1.82 KB
/
Copy pathDockerObjectArchTest.java
File metadata and controls
46 lines (41 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.github.dockerjava.api.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.github.dockerjava.api.async.ResultCallback;
import com.github.dockerjava.api.command.CreateConfigResponse;
import com.github.dockerjava.api.command.DockerCmdExecFactory;
import com.tngtech.archunit.base.DescribedPredicate;
import com.tngtech.archunit.core.domain.JavaClass;
import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.core.importer.ImportOption;
import org.junit.jupiter.api.Test;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
class DockerObjectArchTest {
static JavaClasses CLASSES = new ClassFileImporter()
.withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
.withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_JARS)
.importPackagesOf(
Container.class,
CreateConfigResponse.class
);
@Test
void modelClassMustExtendDockerObject() {
classes()
.that().areNotEnums()
.and().areNotInterfaces()
.and().areNotAnnotatedWith(Deprecated.class)
.and().doNotImplement(ResultCallback.class)
.and().doNotImplement(DockerCmdExecFactory.class)
.and().doNotBelongToAnyOf(DockerObjectAccessor.class)
.and(new DescribedPredicate<JavaClass>("not @JsonCreator-based object") {
@Override
public boolean apply(JavaClass input) {
return input.getAllMethods().stream().noneMatch(method -> {
return method.isAnnotatedWith(JsonCreator.class);
});
}
})
.should().beAssignableTo(DockerObject.class)
.check(CLASSES);
}
}