Search in sources :

Example 21 with DataExtension

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

the class ExtensionExtractorTest method pluginInfoIsRequired.

@Test
void pluginInfoIsRequired() {
    class Extension implements DataExtension {
    }
    ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
    assertEquals("Given class had no PluginInfo annotation", 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 22 with DataExtension

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

the class ExtensionExtractorTest method numberProviderMustReturnPrimitiveLong.

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

        @NumberProvider(text = "Achievements")
        public Long method(UUID playerUUID) {
            return null;
        }
    }
    ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
    assertEquals("Extension.method has invalid return type. was: java.lang.Long, expected: long", 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 23 with DataExtension

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

the class ExtensionExtractorTest method doubleProviderMustReturnPrimitiveDouble.

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

        @DoubleProvider(text = "Money")
        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 24 with DataExtension

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

the class ExtensionExtractorTest method groupProviderMustGroupArray.

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

        @GroupProvider
        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: [Ljava.lang.String; (an array)", 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 25 with DataExtension

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

the class ExtensionExtractorTest method methodsAreExtracted2.

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

        @Conditional("hasJoined")
        @NumberProvider(text = "Test")
        public long method() {
            return 0;
        }
    }
    Extension extension = new Extension();
    ExtensionExtractor underTest = new ExtensionExtractor(extension);
    Map<ExtensionMethod.ParameterType, ExtensionMethods> result = underTest.getMethods();
    Map<ExtensionMethod.ParameterType, ExtensionMethods> expected = buildExpectedExtensionMethodMap(extension, ExtensionMethods::addNumberMethod);
    assertEquals(expected, result);
}
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