Adds maven wrapper ; rework internal a bit ; Adds all tests for core
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.github.gtache.fxml.compiler;
|
||||
|
||||
/**
|
||||
* Base field {@link InjectionType}s
|
||||
*/
|
||||
public enum ControllerFieldInjectionType implements InjectionType {
|
||||
/**
|
||||
* Inject using variable assignment
|
||||
*/
|
||||
ASSIGN,
|
||||
/**
|
||||
* Inject using a factory
|
||||
*/
|
||||
FACTORY,
|
||||
/**
|
||||
* Inject using reflection
|
||||
*/
|
||||
REFLECTION,
|
||||
/**
|
||||
* Inject using setters
|
||||
*/
|
||||
SETTERS
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.github.gtache.fxml.compiler;
|
||||
|
||||
/**
|
||||
* Base controller {@link InjectionType}s
|
||||
*/
|
||||
public enum ControllerInjectionType implements InjectionType {
|
||||
/**
|
||||
* Inject the controller instance
|
||||
*/
|
||||
INSTANCE,
|
||||
/**
|
||||
* Inject a controller factory
|
||||
*/
|
||||
FACTORY
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.github.gtache.fxml.compiler;
|
||||
|
||||
/**
|
||||
* Base methods {@link InjectionType}s
|
||||
*/
|
||||
public enum ControllerMethodsInjectionType implements InjectionType {
|
||||
/**
|
||||
* Inject using visible methods
|
||||
*/
|
||||
REFERENCE,
|
||||
/**
|
||||
* Inject using reflection
|
||||
*/
|
||||
REFLECTION,
|
||||
}
|
||||
@@ -36,26 +36,26 @@ public interface GenerationParameters {
|
||||
*
|
||||
* @return The injection
|
||||
*/
|
||||
InjectionType controllerInjectionType();
|
||||
ControllerInjectionType controllerInjectionType();
|
||||
|
||||
/**
|
||||
* Returns the field injection to use
|
||||
*
|
||||
* @return The injection
|
||||
*/
|
||||
InjectionType fieldInjectionType();
|
||||
ControllerFieldInjectionType fieldInjectionType();
|
||||
|
||||
/**
|
||||
* Returns the method injection to use
|
||||
*
|
||||
* @return The injection
|
||||
*/
|
||||
InjectionType methodInjectionType();
|
||||
ControllerMethodsInjectionType methodInjectionType();
|
||||
|
||||
/**
|
||||
* Returns the resource injection to use
|
||||
*
|
||||
* @return The injection
|
||||
*/
|
||||
InjectionType resourceInjectionType();
|
||||
ResourceBundleInjectionType resourceInjectionType();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.github.gtache.fxml.compiler;
|
||||
|
||||
/**
|
||||
* Base {@link InjectionType}s for resource bundles
|
||||
*/
|
||||
public enum ResourceBundleInjectionType implements InjectionType {
|
||||
/**
|
||||
* Resource bundle is injected in the constructor
|
||||
*/
|
||||
CONSTRUCTOR,
|
||||
/**
|
||||
* Resource bundle is injected as a function in the constructor
|
||||
*/
|
||||
CONSTRUCTOR_FUNCTION,
|
||||
/**
|
||||
* Resource bundle name is injected in the constructor
|
||||
*/
|
||||
CONSTRUCTOR_NAME,
|
||||
/**
|
||||
* Resource bundle is loaded using getBundle
|
||||
*/
|
||||
GET_BUNDLE,
|
||||
/**
|
||||
* Resource bundle is retrieved from controller using getter
|
||||
*/
|
||||
GETTER
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.github.gtache.fxml.compiler;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class TestGenerationException {
|
||||
|
||||
private final String message;
|
||||
private final Throwable throwable;
|
||||
private final String throwableString;
|
||||
|
||||
TestGenerationException(@Mock final Throwable throwable) {
|
||||
this.message = "message";
|
||||
this.throwable = Objects.requireNonNull(throwable);
|
||||
this.throwableString = "throwable";
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
when(throwable.toString()).thenReturn(throwableString);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOnlyMessage() {
|
||||
final var exception = new GenerationException(message);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOnlyCause() {
|
||||
final var exception = new GenerationException(throwable);
|
||||
assertEquals(throwableString, exception.getMessage());
|
||||
assertEquals(throwable, exception.getCause());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMessageAndCause() {
|
||||
final var exception = new GenerationException(message, throwable);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertEquals(throwable, exception.getCause());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.github.gtache.fxml.compiler.parsing;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class TestParseException {
|
||||
|
||||
private final String message;
|
||||
private final Throwable throwable;
|
||||
private final String throwableString;
|
||||
|
||||
TestParseException(@Mock final Throwable throwable) {
|
||||
this.message = "message";
|
||||
this.throwable = Objects.requireNonNull(throwable);
|
||||
this.throwableString = "throwable";
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
when(throwable.toString()).thenReturn(throwableString);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOnlyMessage() {
|
||||
final var exception = new ParseException(message);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOnlyCause() {
|
||||
final var exception = new ParseException(throwable);
|
||||
assertEquals(throwableString, exception.getMessage());
|
||||
assertEquals(throwable, exception.getCause());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMessageAndCause() {
|
||||
final var exception = new ParseException(message, throwable);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertEquals(throwable, exception.getCause());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user