Search in sources :

Example 26 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 27 with DataExtension

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

the class ExtensionExtractorTest method methodsAreExtracted3.

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

        @Conditional("hasJoined")
        @DoubleProvider(text = "Test")
        public double 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::addDoubleMethod);
    assertEquals(expected, result);
}
Also used : DataExtension(com.djrapitops.plan.extension.DataExtension) DataExtension(com.djrapitops.plan.extension.DataExtension) Test(org.junit.jupiter.api.Test)

Example 28 with DataExtension

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

the class ExtensionExtractorTest method pluginInfoNameOver50Chars.

@Test
void pluginInfoNameOver50Chars() {
    @PluginInfo(name = "five five five five five five five five five five -")
    class Extension implements DataExtension {

        @BooleanProvider(text = "Required Provider")
        public boolean method() {
            return false;
        }
    }
    ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
    assertEquals("Warnings: [Extension PluginInfo 'name' was over 50 characters.]", 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 29 with DataExtension

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

the class ExtensionExtractorTest method methodsAreExtracted5.

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

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

Example 30 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)

Aggregations

DataExtension (com.djrapitops.plan.extension.DataExtension)35 Test (org.junit.jupiter.api.Test)35 PluginInfo (com.djrapitops.plan.extension.annotation.PluginInfo)4 Group (com.djrapitops.plan.extension.Group)1 com.djrapitops.plan.extension.annotation (com.djrapitops.plan.extension.annotation)1 ExtensionDataBuilder (com.djrapitops.plan.extension.builder.ExtensionDataBuilder)1 Table (com.djrapitops.plan.extension.table.Table)1 java.util (java.util)1 BiConsumer (java.util.function.BiConsumer)1 Stream (java.util.stream.Stream)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)1