Search in sources :

Example 1 with ApiVersion

use of com.yahoo.elide.annotation.ApiVersion in project elide by yahoo.

the class NamespacePackageTest method testAnnotations.

@Test
void testAnnotations() throws Exception {
    NamespaceConfig testNamespace = NamespaceConfig.builder().description("A test Namespace").name("Test").build();
    NamespacePackage namespace = new NamespacePackage(testNamespace);
    ReadPermission readPermission = namespace.getDeclaredAnnotation(ReadPermission.class);
    assertEquals("Prefab.Role.All", readPermission.expression());
    Include meta = namespace.getDeclaredAnnotation(Include.class);
    assertEquals("A test Namespace", meta.description());
    assertNull(meta.friendlyName());
    ApiVersion apiVersion = namespace.getDeclaredAnnotation(ApiVersion.class);
    assertEquals("", apiVersion.version());
}
Also used : NamespaceConfig(com.yahoo.elide.modelconfig.model.NamespaceConfig) ApiVersion(com.yahoo.elide.annotation.ApiVersion) Include(com.yahoo.elide.annotation.Include) ReadPermission(com.yahoo.elide.annotation.ReadPermission) Test(org.junit.jupiter.api.Test)

Example 2 with ApiVersion

use of com.yahoo.elide.annotation.ApiVersion in project elide by yahoo.

the class NamespacePackage method buildAnnotations.

private static Map<Class<? extends Annotation>, Annotation> buildAnnotations(NamespaceConfig namespace) {
    Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<>();
    annotations.put(ReadPermission.class, new ReadPermission() {

        @Override
        public Class<? extends Annotation> annotationType() {
            return ReadPermission.class;
        }

        @Override
        public String expression() {
            return namespace.getReadAccess();
        }
    });
    annotations.put(Include.class, new Include() {

        @Override
        public Class<? extends Annotation> annotationType() {
            return Include.class;
        }

        @Override
        public boolean rootLevel() {
            return true;
        }

        @Override
        public String description() {
            return namespace.getDescription();
        }

        @Override
        public String friendlyName() {
            return namespace.getFriendlyName();
        }

        @Override
        public String name() {
            return namespace.getName();
        }
    });
    annotations.put(ApiVersion.class, new ApiVersion() {

        @Override
        public String version() {
            return namespace.getApiVersion();
        }

        @Override
        public Class<? extends Annotation> annotationType() {
            return ApiVersion.class;
        }
    });
    return annotations;
}
Also used : ApiVersion(com.yahoo.elide.annotation.ApiVersion) HashMap(java.util.HashMap) Include(com.yahoo.elide.annotation.Include) ReadPermission(com.yahoo.elide.annotation.ReadPermission) Annotation(java.lang.annotation.Annotation)

Aggregations

ApiVersion (com.yahoo.elide.annotation.ApiVersion)2 Include (com.yahoo.elide.annotation.Include)2 ReadPermission (com.yahoo.elide.annotation.ReadPermission)2 NamespaceConfig (com.yahoo.elide.modelconfig.model.NamespaceConfig)1 Annotation (java.lang.annotation.Annotation)1 HashMap (java.util.HashMap)1 Test (org.junit.jupiter.api.Test)1