Search in sources :

Example 1 with DataExtension

use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.

the class ExtensionExtractorTest method methodsAreExtracted1.

@Test
void methodsAreExtracted1() throws NoSuchMethodException {
    @PluginInfo(name = "Extension")
    class Extension implements DataExtension {

        @Conditional("hasJoined")
        @BooleanProvider(text = "Test", conditionName = "isBanned")
        public boolean method() {
            return false;
        }
    }
    Extension extension = new Extension();
    ExtensionExtractor underTest = new ExtensionExtractor(extension);
    Map<ExtensionMethod.ParameterType, ExtensionMethods> result = underTest.getMethods();
    Map<ExtensionMethod.ParameterType, ExtensionMethods> expected = buildExpectedExtensionMethodMap(extension, ExtensionMethods::addBooleanMethod);
    assertEquals(expected, result);
}
Also used : DataExtension(com.djrapitops.plan.extension.DataExtension) DataExtension(com.djrapitops.plan.extension.DataExtension) Test(org.junit.jupiter.api.Test)

Example 2 with DataExtension

use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.

the class ExtensionExtractorTest method methodsAreExtracted8.

@Test
void methodsAreExtracted8() throws NoSuchMethodException {
    @PluginInfo(name = "Extension")
    class Extension implements DataExtension {

        @DataBuilderProvider
        public ExtensionDataBuilder method() {
            return null;
        }
    }
    Extension extension = new Extension();
    ExtensionExtractor underTest = new ExtensionExtractor(extension);
    Map<ExtensionMethod.ParameterType, ExtensionMethods> result = underTest.getMethods();
    Map<ExtensionMethod.ParameterType, ExtensionMethods> expected = buildExpectedExtensionMethodMap(extension, ExtensionMethods::addDataBuilderMethod);
    assertEquals(expected, result);
}
Also used : DataExtension(com.djrapitops.plan.extension.DataExtension) DataExtension(com.djrapitops.plan.extension.DataExtension) Test(org.junit.jupiter.api.Test)

Example 3 with DataExtension

use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.

the class ExtensionExtractorTest method percentageProviderMustReturnPrimitiveDouble.

@Test
void percentageProviderMustReturnPrimitiveDouble() {
    @PluginInfo(name = "Extension")
    class Extension implements DataExtension {

        @PercentageProvider(text = "Achievements awarded")
        public Double method(UUID playerUUID) {
            return null;
        }
    }
    ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
    assertEquals("Extension.method has invalid return type. was: java.lang.Double, expected: double", assertThrows(IllegalArgumentException.class, underTest::validateAnnotations).getMessage());
}
Also used : DataExtension(com.djrapitops.plan.extension.DataExtension) DataExtension(com.djrapitops.plan.extension.DataExtension) Test(org.junit.jupiter.api.Test)

Example 4 with DataExtension

use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.

the class ExtensionExtractorTest method booleanProviderMustReturnPrimitiveBoolean.

@Test
void booleanProviderMustReturnPrimitiveBoolean() {
    @PluginInfo(name = "Extension")
    class Extension implements DataExtension {

        @BooleanProvider(text = "Banned")
        public Boolean method(UUID playerUUID) {
            return null;
        }
    }
    ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
    assertEquals("Extension.method has invalid return type. was: java.lang.Boolean, expected: boolean", assertThrows(IllegalArgumentException.class, underTest::validateAnnotations).getMessage());
}
Also used : DataExtension(com.djrapitops.plan.extension.DataExtension) DataExtension(com.djrapitops.plan.extension.DataExtension) Test(org.junit.jupiter.api.Test)

Example 5 with DataExtension

use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.

the class ExtensionExtractorTest method conditionalMethodRequiresProvider.

@Test
void conditionalMethodRequiresProvider() {
    @PluginInfo(name = "Extension")
    class Extension implements DataExtension {

        @Conditional("hasJoined")
        public boolean method(UUID playerUUID) {
            return false;
        }
    }
    ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
    assertEquals("Extension.method did not have any associated Provider for Conditional.", assertThrows(IllegalArgumentException.class, underTest::validateAnnotations).getMessage());
}
Also used : DataExtension(com.djrapitops.plan.extension.DataExtension) DataExtension(com.djrapitops.plan.extension.DataExtension) Test(org.junit.jupiter.api.Test)

Aggregations

DataExtension (com.djrapitops.plan.extension.DataExtension)35 Test (org.junit.jupiter.api.Test)35 PluginInfo (com.djrapitops.plan.extension.annotation.PluginInfo)4