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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations