Search in sources :

Example 1 with AbstractConfigurationMockBuilder

use of com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder in project junit-servers by mjeanroy.

the class ConfigurationAnnotationHandlerTest method it_should_set_configuration_instance.

@Test
void it_should_set_configuration_instance() {
    final AbstractConfiguration configuration = new AbstractConfigurationMockBuilder().build();
    final TestClassWithAnnotatedField target = new TestClassWithAnnotatedField();
    final Field field = extractConfigurationField();
    final AnnotationHandler handler = newConfigurationAnnotationHandler(configuration);
    verifyBeforeTest(configuration, target, field, handler);
}
Also used : AbstractConfiguration(com.github.mjeanroy.junit.servers.servers.AbstractConfiguration) Field(java.lang.reflect.Field) Fields.getPrivateField(com.github.mjeanroy.junit.servers.utils.commons.Fields.getPrivateField) AbstractConfigurationMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder) ConfigurationAnnotationHandler.newConfigurationAnnotationHandler(com.github.mjeanroy.junit.servers.engine.ConfigurationAnnotationHandler.newConfigurationAnnotationHandler) Test(org.junit.jupiter.api.Test)

Example 2 with AbstractConfigurationMockBuilder

use of com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder in project junit-servers by mjeanroy.

the class ConfigurationAnnotationHandlerTest method it_should_implement_to_string.

@Test
void it_should_implement_to_string() {
    final AbstractConfiguration configuration = new AbstractConfigurationMockBuilder().build();
    final AnnotationHandler handler = newConfigurationAnnotationHandler(configuration);
    assertThat(handler).hasToString("ConfigurationAnnotationHandler{" + "annotationKlass: interface com.github.mjeanroy.junit.servers.annotations.TestServerConfiguration, " + "configuration: MockAbstractConfiguration" + "}");
}
Also used : AbstractConfiguration(com.github.mjeanroy.junit.servers.servers.AbstractConfiguration) AbstractConfigurationMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder) ConfigurationAnnotationHandler.newConfigurationAnnotationHandler(com.github.mjeanroy.junit.servers.engine.ConfigurationAnnotationHandler.newConfigurationAnnotationHandler) Test(org.junit.jupiter.api.Test)

Example 3 with AbstractConfigurationMockBuilder

use of com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder in project junit-servers by mjeanroy.

the class AnnotationsHandlerRunnerTest method it_should_process_handlers.

@Test
void it_should_process_handlers() {
    final AbstractConfiguration configuration = new AbstractConfigurationMockBuilder().build();
    final EmbeddedServer<?> embeddedServer = new EmbeddedServerMockBuilder().build();
    final FixtureClass target = new FixtureClass();
    final AnnotationsHandlerRunner adapter = new AnnotationsHandlerRunner(embeddedServer, configuration);
    verifyBeforeTest(configuration, embeddedServer, target, adapter);
    verifyAfterTest(configuration, embeddedServer, target, adapter);
}
Also used : AbstractConfiguration(com.github.mjeanroy.junit.servers.servers.AbstractConfiguration) AbstractConfigurationMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder) FixtureClass(com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass) EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with AbstractConfigurationMockBuilder

use of com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder in project junit-servers by mjeanroy.

the class ConfigurationAnnotationHandlerTest method it_should_support_server_annotation.

@Test
void it_should_support_server_annotation() {
    final AbstractConfiguration configuration = new AbstractConfigurationMockBuilder().build();
    final AnnotationHandler handler = newConfigurationAnnotationHandler(configuration);
    final Field field = extractConfigurationField();
    final Annotation annotation = readAnnotation(field);
    assertThat(handler.support(annotation)).isTrue();
}
Also used : AbstractConfiguration(com.github.mjeanroy.junit.servers.servers.AbstractConfiguration) Field(java.lang.reflect.Field) Fields.getPrivateField(com.github.mjeanroy.junit.servers.utils.commons.Fields.getPrivateField) AbstractConfigurationMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder) ConfigurationAnnotationHandler.newConfigurationAnnotationHandler(com.github.mjeanroy.junit.servers.engine.ConfigurationAnnotationHandler.newConfigurationAnnotationHandler) Annotation(java.lang.annotation.Annotation) Test(org.junit.jupiter.api.Test)

Example 5 with AbstractConfigurationMockBuilder

use of com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder in project junit-servers by mjeanroy.

the class AnnotationsHandlerRuleTest method it_should_implement_to_string.

@Test
void it_should_implement_to_string() {
    final AbstractConfiguration configuration = new AbstractConfigurationMockBuilder().build();
    final EmbeddedServer<?> embeddedServer = new EmbeddedServerMockBuilder().build();
    final FixtureClass target = new FixtureClass();
    final AnnotationsHandlerRule rule = new AnnotationsHandlerRule(target, embeddedServer, configuration);
    assertThat(rule).hasToString("AnnotationsHandlerRule{" + "target: FixtureClass, " + "annotationHandlers: AnnotationsHandlerRunner{" + "handlers: [" + "ServerAnnotationHandler{" + "annotationKlass: interface com.github.mjeanroy.junit.servers.annotations.TestServer, " + "server: MockEmbeddedServer" + "}, " + "ConfigurationAnnotationHandler{" + "annotationKlass: interface com.github.mjeanroy.junit.servers.annotations.TestServerConfiguration, " + "configuration: MockAbstractConfiguration" + "}, " + "HttpClientAnnotationHandler{" + "annotationKlass: interface com.github.mjeanroy.junit.servers.annotations.TestHttpClient, " + "server: MockEmbeddedServer" + "}" + "]" + "}" + "}");
}
Also used : AbstractConfiguration(com.github.mjeanroy.junit.servers.servers.AbstractConfiguration) AbstractConfigurationMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder) FixtureClass(com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass) EmbeddedServerMockBuilder(com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

AbstractConfiguration (com.github.mjeanroy.junit.servers.servers.AbstractConfiguration)7 AbstractConfigurationMockBuilder (com.github.mjeanroy.junit.servers.utils.builders.AbstractConfigurationMockBuilder)7 Test (org.junit.jupiter.api.Test)7 EmbeddedServerMockBuilder (com.github.mjeanroy.junit.servers.utils.builders.EmbeddedServerMockBuilder)4 ConfigurationAnnotationHandler.newConfigurationAnnotationHandler (com.github.mjeanroy.junit.servers.engine.ConfigurationAnnotationHandler.newConfigurationAnnotationHandler)3 FixtureClass (com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass)3 Fields.getPrivateField (com.github.mjeanroy.junit.servers.utils.commons.Fields.getPrivateField)2 Field (java.lang.reflect.Field)2 Annotation (java.lang.annotation.Annotation)1