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