use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ExtensionExtractorTest method tabsAreExtracted.
@Test
void tabsAreExtracted() throws NoSuchMethodException {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@Tab("Tab name")
@DataBuilderProvider
public ExtensionDataBuilder method() {
return null;
}
}
Extension extension = new Extension();
ExtensionExtractor underTest = new ExtensionExtractor(extension);
Collection<Tab> expected = Collections.singletonList(extension.getClass().getMethod("method").getAnnotation(Tab.class));
Collection<Tab> result = underTest.getTabAnnotations();
assertEquals(expected, result);
}
use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ClassValuePairOrderTest method booleansWithConditionsComeFirst.
@Test
void booleansWithConditionsComeFirst() throws NoSuchMethodException {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@Conditional("condition")
@StringProvider(text = "a")
public String value() {
return "";
}
@Conditional("condition2")
@StringProvider(text = "a")
public String value2() {
return "";
}
}
ExtDataBuilder builder = new ExtDataBuilder(new Extension());
DataValue<Boolean> first = builder.valueBuilder("test").buildBooleanProvidingCondition(false, "condition");
DataValue<Boolean> second = builder.valueBuilder("test").conditional(Extension.class.getMethod("value").getAnnotation(Conditional.class)).buildBooleanProvidingCondition(false, "condition2");
DataValue<String> third = builder.valueBuilder("test").conditional(Extension.class.getMethod("value2").getAnnotation(Conditional.class)).buildString("e");
builder.addValue(String.class, third);
builder.addValue(String.class, third);
builder.addValue(String.class, third);
builder.addValue(Boolean.class, second);
builder.addValue(Boolean.class, first);
List<ExtDataBuilder.ClassValuePair> expected = Arrays.asList(new ExtDataBuilder.ClassValuePair(Boolean.class, first), new ExtDataBuilder.ClassValuePair(Boolean.class, second), new ExtDataBuilder.ClassValuePair(String.class, third), new ExtDataBuilder.ClassValuePair(String.class, third), new ExtDataBuilder.ClassValuePair(String.class, third));
List<ExtDataBuilder.ClassValuePair> result = builder.getValues();
assertEquals(expected, result);
}
use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ClassValuePairOrderTest method booleansWithConditionsComeFirst2.
@Test
void booleansWithConditionsComeFirst2() throws NoSuchMethodException {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@Conditional("condition")
@StringProvider(text = "a")
public String value() {
return "";
}
@Conditional("condition2")
@StringProvider(text = "a")
public String value2() {
return "";
}
}
ExtDataBuilder builder = new ExtDataBuilder(new Extension());
DataValue<Boolean> first = builder.valueBuilder("test").buildBooleanProvidingCondition(false, "condition");
DataValue<Boolean> second = builder.valueBuilder("test").conditional(Extension.class.getMethod("value").getAnnotation(Conditional.class)).buildBooleanProvidingCondition(false, "condition2");
DataValue<String> third = builder.valueBuilder("test").conditional(Extension.class.getMethod("value2").getAnnotation(Conditional.class)).buildString("e");
builder.addValue(String.class, third);
builder.addValue(String.class, third);
builder.addValue(Boolean.class, first);
builder.addValue(Boolean.class, second);
builder.addValue(String.class, third);
List<ExtDataBuilder.ClassValuePair> expected = Arrays.asList(new ExtDataBuilder.ClassValuePair(Boolean.class, first), new ExtDataBuilder.ClassValuePair(Boolean.class, second), new ExtDataBuilder.ClassValuePair(String.class, third), new ExtDataBuilder.ClassValuePair(String.class, third), new ExtDataBuilder.ClassValuePair(String.class, third));
List<ExtDataBuilder.ClassValuePair> result = builder.getValues();
assertEquals(expected, result);
}
use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ClassValuePairOrderTest method booleansComeFirst.
@Test
void booleansComeFirst() throws NoSuchMethodException {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@Conditional("condition")
@StringProvider(text = "a")
public String value() {
return "";
}
}
ExtDataBuilder builder = new ExtDataBuilder(new Extension());
DataValue<Boolean> first = builder.valueBuilder("test").buildBooleanProvidingCondition(false, "condition");
DataValue<String> second = builder.valueBuilder("test").conditional(Extension.class.getMethod("value").getAnnotation(Conditional.class)).buildString("e");
builder.addValue(String.class, second);
builder.addValue(String.class, second);
builder.addValue(String.class, second);
builder.addValue(Boolean.class, first);
List<ExtDataBuilder.ClassValuePair> expected = Arrays.asList(new ExtDataBuilder.ClassValuePair(Boolean.class, first), new ExtDataBuilder.ClassValuePair(String.class, second), new ExtDataBuilder.ClassValuePair(String.class, second), new ExtDataBuilder.ClassValuePair(String.class, second));
List<ExtDataBuilder.ClassValuePair> result = builder.getValues();
assertEquals(expected, result);
}
use of com.djrapitops.plan.extension.DataExtension in project Plan by plan-player-analytics.
the class ExtensionExtractorTest method publicProviderMethodsAreRequired.
@Test
void publicProviderMethodsAreRequired() {
@PluginInfo(name = "Extension")
class Extension implements DataExtension {
@BooleanProvider(text = "Banned")
private boolean method(UUID playerUUID) {
return false;
}
}
ExtensionExtractor underTest = new ExtensionExtractor(new Extension());
assertEquals("Extension class had no methods annotated with a Provider annotation", assertThrows(IllegalArgumentException.class, underTest::validateAnnotations).getMessage());
}
Aggregations