Skip to content

Commit

Permalink
Extract graphql-jpa-query-web module from starter (#74)
Browse files Browse the repository at this point in the history
* fix: Extract graphql-jpa-query-web module from starter

* fix: (git) add .classpath to .gitignore

* fix: add  GraphQLControllerAutoConfigurationTest
  • Loading branch information
igdianov authored Feb 3, 2019
1 parent b0839ca commit 8d72bbe
Show file tree
Hide file tree
Showing 19 changed files with 141 additions and 29 deletions.
12 changes: 1 addition & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Eclipse
#.classpath
.project/
.settings/
build/
Expand All @@ -21,13 +20,4 @@ target/
# Eclipse
.project
.springBeans



graphql-jpa-query-schema/\.classpath

graphql-jpa-query-annotations/\.classpath

graphql-jpa-query-example/\.classpath

graphql-jpa-query-boot-starter/\.classpath
.classpath
5 changes: 5 additions & 0 deletions graphql-jpa-query-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
</dependency>

<dependency>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import com.introproventures.graphql.jpa.query.boot.autoconfigure.GraphQLJpaQueryAutoConfiguration.DefaultGraphQLJpaQueryConfiguration;
import com.introproventures.graphql.jpa.query.boot.autoconfigure.GraphQLJpaQueryAutoConfiguration.GraphQLJpaQuerySchemaConfigurer;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;

import com.introproventures.graphql.jpa.query.boot.autoconfigure.GraphQLJpaQueryAutoConfiguration.DefaultActivitiGraphQLJpaConfiguration;

@Documented
@Retention( RUNTIME )
@Target( TYPE )
@Import(DefaultActivitiGraphQLJpaConfiguration.class)
@Import({DefaultGraphQLJpaQueryConfiguration.class, GraphQLJpaQuerySchemaConfigurer.class})
@PropertySource("classpath:/com/introproventures/graphql/jpa/query/boot/autoconfigure/default.properties")
public @interface EnableGraphQLJpaQuery {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder;
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
import com.introproventures.graphql.jpa.query.web.GraphQLController;
import graphql.GraphQL;
import graphql.schema.GraphQLSchema;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -33,7 +32,6 @@
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportAware;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.type.AnnotationMetadata;
Expand Down Expand Up @@ -62,9 +60,8 @@ public void configure(GraphQLShemaRegistration registry) {
}

@Configuration
@Import(GraphQLController.class)
@EnableConfigurationProperties(GraphQLJpaQueryProperties.class)
public static class DefaultActivitiGraphQLJpaConfiguration implements ImportAware {
public static class DefaultGraphQLJpaQueryConfiguration implements ImportAware {

@Autowired
GraphQLJpaQueryProperties properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder;
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
import com.introproventures.graphql.jpa.query.web.model.Author;
import com.introproventures.graphql.jpa.query.starter.model.Author;

@RunWith(SpringRunner.class)
@SpringBootTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder;
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
import com.introproventures.graphql.jpa.query.web.model.Author;
import com.introproventures.graphql.jpa.query.starter.model.Author;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.introproventures.graphql.jpa.query.web;
package com.introproventures.graphql.jpa.query.starter;

import java.io.IOException;
import java.util.HashMap;
Expand Down Expand Up @@ -41,7 +41,7 @@

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class GraphQLControllerIT {
public class GraphQLJpaQueryStarterIT {
private static final String WAR_AND_PEACE = "War and Peace";

@SpringBootApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.introproventures.graphql.jpa.query.web.model;
package com.introproventures.graphql.jpa.query.starter.model;

import java.util.Collection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.introproventures.graphql.jpa.query.web.model;
package com.introproventures.graphql.jpa.query.starter.model;

import javax.persistence.Entity;
import javax.persistence.EnumType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.introproventures.graphql.jpa.query.web.model;
package com.introproventures.graphql.jpa.query.starter.model;

public enum Genre {
NOVEL, PLAY
Expand Down
5 changes: 5 additions & 0 deletions graphql-jpa-query-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-web</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
24 changes: 24 additions & 0 deletions graphql-jpa-query-web/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.3.13-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>
<artifactId>graphql-jpa-query-web</artifactId>

<dependencies>
<dependency>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-schema</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
import graphql.ExecutionResult;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -43,8 +41,6 @@
*
*/
@RestController
@ConditionalOnWebApplication
@ConditionalOnClass(GraphQLExecutor.class)
public class GraphQLController {

private static final String PATH = "${spring.graphql.jpa.query.path:/graphql}";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.introproventures.graphql.jpa.query.web.autoconfigure;

import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
import com.introproventures.graphql.jpa.query.web.GraphQLController;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@ConditionalOnWebApplication
@ConditionalOnClass(GraphQLExecutor.class)
public class GraphQLControllerAutoConfiguration {

@Import(GraphQLController.class)
public static class DefaultGraphQLControllerConfiguration {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.introproventures.graphql.jpa.query.web.autoconfigure.GraphQLControllerAutoConfiguration
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.introproventures.graphql.jpa.query.web.autoconfigure;

import static org.assertj.core.api.Assertions.assertThat;

import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
import com.introproventures.graphql.jpa.query.web.GraphQLController;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)
public class GraphQLControllerAutoConfigurationTest {

@MockBean
private GraphQLExecutor graphQLExecutor;

@Autowired
private GraphQLController graphQLController;

@SpringBootApplication
static class Application {

}

@Test
public void contextLoads() {
assertThat(graphQLController).isNotNull();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.introproventures.graphql.jpa.query.web.autoconfigure;

import static org.assertj.core.api.Assertions.assertThat;

import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
import com.introproventures.graphql.jpa.query.web.GraphQLController;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvironment.NONE)
public class GraphQLControllerAutoConfigurationWebNoneTest {

@MockBean
private GraphQLExecutor graphQLExecutor;

@Autowired(required=false)
private GraphQLController graphQLController;

@SpringBootApplication
static class Application {

}

@Test
public void contextLoads() {
assertThat(graphQLController).isNull();
}

}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<module>graphql-jpa-query-dependencies</module>
<module>graphql-jpa-query-build</module>
<module>graphql-jpa-query-autoconfigure</module>
<module>graphql-jpa-query-web</module>
</modules>

<distributionManagement>
Expand Down

0 comments on commit 8d72bbe

Please sign in to comment.