findAll(QuerySpec querySpec) {
+ // do your logic here
+ return super.findAll(querySpec);
+ }
+
+ @Override
+ public S save(S entity) {
+ // do your logic here
+ return super.save(entity);
+ }
+
+ @Override
+ public void delete(UUID id) {
+ // do your logic here
+ super.delete(id);
+ }
}
\ No newline at end of file
diff --git a/crnk-example-service/src/main/java/io/crnk/example/service/basic/VoteRepository.java b/crnk-example-service/src/main/java/io/crnk/example/service/basic/VoteRepository.java
index 2664a5a..2616949 100644
--- a/crnk-example-service/src/main/java/io/crnk/example/service/basic/VoteRepository.java
+++ b/crnk-example-service/src/main/java/io/crnk/example/service/basic/VoteRepository.java
@@ -1,55 +1,56 @@
package io.crnk.example.service.basic;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-
import io.crnk.core.queryspec.QuerySpec;
import io.crnk.core.repository.ResourceRepositoryBase;
import io.crnk.core.repository.ResourceRepositoryV2;
import io.crnk.core.resource.list.ResourceList;
import org.springframework.stereotype.Component;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
/**
* Showcases a simple in-memory repository with some artificial slow
* down to simulate expensive requests and show loading indicators
* in the frontend.
+ *
+ * Real-world application may rather make use of the existing InMemoryResourceRepository.
*/
@Component
public class VoteRepository extends ResourceRepositoryBase implements ResourceRepositoryV2 {
- public static Map votes = new ConcurrentHashMap<>();
-
- public VoteRepository() {
- super(Vote.class);
- }
-
- @Override
- public ResourceList findAll(QuerySpec querySpec) {
- slowDown();
- return querySpec.apply(votes.values());
- }
-
- @Override
- public S save(S entity) {
- slowDown();
- votes.put(entity.getId(), entity);
- return null;
- }
-
- @Override
- public void delete(UUID id) {
- slowDown();
- votes.remove(id);
- }
-
- private void slowDown() {
- // artificially slow it down to simulate loading in frontend
- try {
- Thread.sleep(3000);
- }
- catch (InterruptedException e) {
- throw new IllegalStateException(e);
- }
- }
+ public static Map votes = new ConcurrentHashMap<>();
+
+ public VoteRepository() {
+ super(Vote.class);
+ }
+
+ @Override
+ public ResourceList findAll(QuerySpec querySpec) {
+ slowDown();
+ return querySpec.apply(votes.values());
+ }
+
+ @Override
+ public S save(S entity) {
+ slowDown();
+ votes.put(entity.getId(), entity);
+ return null;
+ }
+
+ @Override
+ public void delete(UUID id) {
+ slowDown();
+ votes.remove(id);
+ }
+
+ private void slowDown() {
+ // artificially slow it down to simulate loading in frontend
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+ throw new IllegalStateException(e);
+ }
+ }
}
\ No newline at end of file
diff --git a/crnk-example-service/src/main/java/io/crnk/example/service/decorator/ExampleDecorator.java b/crnk-example-service/src/main/java/io/crnk/example/service/decorator/ExampleDecorator.java
index 42b86c1..2e3c9bc 100644
--- a/crnk-example-service/src/main/java/io/crnk/example/service/decorator/ExampleDecorator.java
+++ b/crnk-example-service/src/main/java/io/crnk/example/service/decorator/ExampleDecorator.java
@@ -3,31 +3,32 @@
import io.crnk.core.queryspec.QuerySpec;
import io.crnk.core.repository.decorate.ResourceRepositoryDecoratorBase;
import io.crnk.core.resource.list.ResourceList;
-import io.crnk.example.service.jpa.ScheduleDto;
+import io.crnk.example.service.jpa.ScheduleEntity;
/**
- * See ExampleDecoratorModule for more information.
+ * The decorator is registered through ExampleDecoratorFactory. It intercepts all calls to
+ * ScheduleRepository and updates the name to upper case.
*/
-public class ExampleDecorator extends ResourceRepositoryDecoratorBase {
+public class ExampleDecorator extends ResourceRepositoryDecoratorBase {
- @Override
- public ResourceList findAll(Iterable ids, QuerySpec querySpec) {
- return decoratedObject.findAll(ids, querySpec);
- }
+ @Override
+ public ResourceList findAll(Iterable ids, QuerySpec querySpec) {
+ return decoratedObject.findAll(ids, querySpec);
+ }
- @Override
- public ScheduleDto findOne(Long id, QuerySpec querySpec) {
- ScheduleDto dto = decoratedObject.findOne(id, querySpec);
- dto.setDecoratedName("decoratedFindOne");
- return dto;
- }
+ @Override
+ public ScheduleEntity findOne(Long id, QuerySpec querySpec) {
+ ScheduleEntity entity = decoratedObject.findOne(id, querySpec);
+ entity.setName(entity.getName().toUpperCase());
+ return entity;
+ }
- @Override
- public ResourceList findAll(QuerySpec querySpec) {
- ResourceList list = decoratedObject.findAll(querySpec);
- for (ScheduleDto dto : list) {
- dto.setDecoratedName("decoratedFindAll");
- }
- return list;
- }
+ @Override
+ public ResourceList findAll(QuerySpec querySpec) {
+ ResourceList list = decoratedObject.findAll(querySpec);
+ for (ScheduleEntity entity : list) {
+ entity.setName(entity.getName().toUpperCase());
+ }
+ return list;
+ }
}
diff --git a/crnk-example-service/src/main/java/io/crnk/example/service/decorator/ExampleDecoratorFactory.java b/crnk-example-service/src/main/java/io/crnk/example/service/decorator/ExampleDecoratorFactory.java
new file mode 100644
index 0000000..e3b7729
--- /dev/null
+++ b/crnk-example-service/src/main/java/io/crnk/example/service/decorator/ExampleDecoratorFactory.java
@@ -0,0 +1,27 @@
+package io.crnk.example.service.decorator;
+
+import io.crnk.core.repository.ResourceRepositoryV2;
+import io.crnk.core.repository.decorate.RepositoryDecoratorFactoryBase;
+import io.crnk.core.repository.decorate.ResourceRepositoryDecorator;
+import io.crnk.example.service.jpa.ScheduleEntity;
+import org.springframework.stereotype.Component;
+
+import java.io.Serializable;
+
+/**
+ * sets up an ExampleDecorator to intercepts and modifies any request for ScheduleEntity.
+ * with a further value. Can be used to intercept and modify
+ * requests in an arbitrary fashion.
+ */
+@Component
+public class ExampleDecoratorFactory extends RepositoryDecoratorFactoryBase {
+
+ @Override
+ public ResourceRepositoryDecorator decorateRepository(
+ ResourceRepositoryV2 repository) {
+ if (repository.getResourceClass() == ScheduleEntity.class) {
+ return (ResourceRepositoryDecorator) new ExampleDecorator();
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/crnk-example-service/src/main/java/io/crnk/example/service/decorator/ExampleDecoratorModule.java b/crnk-example-service/src/main/java/io/crnk/example/service/decorator/ExampleDecoratorModule.java
deleted file mode 100644
index cdf8f01..0000000
--- a/crnk-example-service/src/main/java/io/crnk/example/service/decorator/ExampleDecoratorModule.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package io.crnk.example.service.decorator;
-
-import java.io.Serializable;
-
-import io.crnk.core.module.Module;
-import io.crnk.core.repository.ResourceRepositoryV2;
-import io.crnk.core.repository.decorate.RepositoryDecoratorFactoryBase;
-import io.crnk.core.repository.decorate.ResourceRepositoryDecorator;
-import io.crnk.example.service.jpa.ScheduleDto;
-import org.springframework.stereotype.Component;
-
-/**
- * sets up an ExampleDecorator to enrich ScheduleDto with a further value. Can be used to intercept and modify
- * requests in an arbitrary fashion.
- *
- * TODO implement support to lookup decoratorFactory with Spring without module
- */
-@Component
-public class ExampleDecoratorModule implements Module {
-
- @Override
- public String getModuleName() {
- return "exampleDecorator";
- }
-
- @Override
- public void setupModule(ModuleContext context) {
- context.addRepositoryDecoratorFactory(new RepositoryDecoratorFactoryBase() {
- @Override
- public ResourceRepositoryDecorator decorateRepository(
- ResourceRepositoryV2 repository) {
- if (repository.getResourceClass() == ScheduleDto.class) {
- return (ResourceRepositoryDecorator) new ExampleDecorator();
- }
- return null;
- }
- });
- }
-}
diff --git a/crnk-example-service/src/main/java/io/crnk/example/service/jpa/ExampleJpaModuleConfigurer.java b/crnk-example-service/src/main/java/io/crnk/example/service/jpa/ExampleJpaModuleConfigurer.java
deleted file mode 100644
index 17a566f..0000000
--- a/crnk-example-service/src/main/java/io/crnk/example/service/jpa/ExampleJpaModuleConfigurer.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package io.crnk.example.service.jpa;
-
-
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.Expression;
-import javax.persistence.criteria.From;
-
-import io.crnk.core.queryspec.QuerySpec;
-import io.crnk.jpa.JpaModuleConfig;
-import io.crnk.jpa.JpaRepositoryConfig;
-import io.crnk.jpa.mapping.JpaMapper;
-import io.crnk.jpa.query.Tuple;
-import io.crnk.jpa.query.criteria.JpaCriteriaExpressionFactory;
-import io.crnk.jpa.query.criteria.JpaCriteriaQueryFactory;
-import io.crnk.spring.setup.boot.jpa.JpaModuleConfigurer;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ExampleJpaModuleConfigurer implements JpaModuleConfigurer {
-
- @PersistenceContext
- private EntityManager em;
-
- /**
- * Expose JPA entities as repositories.
- *
- * @return module
- */
-
- @Override
- public void configure(JpaModuleConfig config) {
- // directly expose entity 1:1 as JSON:API resource
- config.addRepository(JpaRepositoryConfig.builder(ScheduleEntity.class).build());
- config.addRepository(JpaRepositoryConfig.builder(MovieEntity.class).build());
- config.addRepository(JpaRepositoryConfig.builder(RoleEntity.class).build());
- config.addRepository(JpaRepositoryConfig.builder(PersonEntity.class).build());
-
- // map ScheduleEntity to a ScheduleDto with ScheduleMapper can do arbitrary mappings.
- config.addRepository(
- JpaRepositoryConfig.builder(ScheduleEntity.class, ScheduleDto.class, new ScheduleMapper()).build());
-
- JpaCriteriaQueryFactory queryFactory = (JpaCriteriaQueryFactory) config.getQueryFactory();
-
- // register a computed a attribute to automatically fill upperName with the upper-cased name
- // => you may consider QueryDSL or generating Criteria query objects to keep type-safety.
- // => you may also create arbitrary complex expressions with subqueries, etc.
- JpaCriteriaExpressionFactory upperNameExpr = (JpaCriteriaExpressionFactory>) (entity, query) -> {
- CriteriaBuilder builder = em.getCriteriaBuilder();
- return builder.upper((Expression) entity.get("name"));
- };
- queryFactory.registerComputedAttribute(ScheduleEntity.class, "upperName", String.class,
- upperNameExpr);
- }
-
-
- class ScheduleMapper implements JpaMapper {
-
- @Override
- public ScheduleDto map(Tuple tuple) {
- ScheduleDto dto = new ScheduleDto();
-
- // first entry in tuple is the queried entity (if not configured otherwise)
- ScheduleEntity entity = tuple.get(0, ScheduleEntity.class);
- dto.setId(entity.getId());
- dto.setName(entity.getName());
-
- // computed attribute available as additional tuple entry
- dto.setComputedUpperName(tuple.get(1, String.class));
- return dto;
- }
-
- @Override
- public ScheduleEntity unmap(ScheduleDto dto) {
- // get entity from database if already there
- ScheduleEntity entity = em.find(ScheduleEntity.class, dto.getId());
- if (entity == null) {
- entity = new ScheduleEntity();
- entity.setId(dto.getId());
- }
- entity.setName(dto.getName());
- return entity;
- }
-
- @Override
- public QuerySpec unmapQuerySpec(QuerySpec dtoQuerySpec) {
- // if the DTOs introduces new naming, querySpec must be updated as well.
- return dtoQuerySpec;
- }
- }
-}
diff --git a/crnk-example-service/src/main/java/io/crnk/example/service/jpa/MovieRepository.java b/crnk-example-service/src/main/java/io/crnk/example/service/jpa/MovieRepository.java
new file mode 100644
index 0000000..f7200ce
--- /dev/null
+++ b/crnk-example-service/src/main/java/io/crnk/example/service/jpa/MovieRepository.java
@@ -0,0 +1,32 @@
+package io.crnk.example.service.jpa;
+
+import io.crnk.jpa.JpaEntityRepositoryBase;
+import org.springframework.stereotype.Component;
+
+import java.util.UUID;
+
+@Component
+public class MovieRepository extends JpaEntityRepositoryBase {
+
+ public MovieRepository() {
+ super(MovieEntity.class);
+ }
+
+ @Override
+ public MovieEntity save(MovieEntity entity) {
+ // add your save logic here
+ return super.save(entity);
+ }
+
+ @Override
+ public MovieEntity create(MovieEntity entity) {
+ // add your create logic here
+ return super.create(entity);
+ }
+
+ @Override
+ public void delete(UUID id) {
+ // add your save logic here
+ super.delete(id);
+ }
+}
diff --git a/crnk-example-service/src/main/java/io/crnk/example/service/jpa/PersonRepository.java b/crnk-example-service/src/main/java/io/crnk/example/service/jpa/PersonRepository.java
new file mode 100644
index 0000000..3cf5843
--- /dev/null
+++ b/crnk-example-service/src/main/java/io/crnk/example/service/jpa/PersonRepository.java
@@ -0,0 +1,32 @@
+package io.crnk.example.service.jpa;
+
+import io.crnk.jpa.JpaEntityRepositoryBase;
+import org.springframework.stereotype.Component;
+
+import java.util.UUID;
+
+@Component
+public class PersonRepository extends JpaEntityRepositoryBase {
+
+ public PersonRepository() {
+ super(PersonEntity.class);
+ }
+
+ @Override
+ public PersonEntity save(PersonEntity entity) {
+ // add your save logic here
+ return super.save(entity);
+ }
+
+ @Override
+ public PersonEntity create(PersonEntity entity) {
+ // add your create logic here
+ return super.create(entity);
+ }
+
+ @Override
+ public void delete(UUID id) {
+ // add your save logic here
+ super.delete(id);
+ }
+}
diff --git a/crnk-example-service/src/main/java/io/crnk/example/service/jpa/RoleRepository.java b/crnk-example-service/src/main/java/io/crnk/example/service/jpa/RoleRepository.java
new file mode 100644
index 0000000..c9a60f2
--- /dev/null
+++ b/crnk-example-service/src/main/java/io/crnk/example/service/jpa/RoleRepository.java
@@ -0,0 +1,14 @@
+package io.crnk.example.service.jpa;
+
+import io.crnk.jpa.JpaEntityRepositoryBase;
+import org.springframework.stereotype.Component;
+
+import java.util.UUID;
+
+@Component
+public class RoleRepository extends JpaEntityRepositoryBase {
+
+ public RoleRepository() {
+ super(RoleEntity.class);
+ }
+}
diff --git a/crnk-example-service/src/main/java/io/crnk/example/service/jpa/ScheduleDto.java b/crnk-example-service/src/main/java/io/crnk/example/service/jpa/ScheduleDto.java
deleted file mode 100644
index d708b11..0000000
--- a/crnk-example-service/src/main/java/io/crnk/example/service/jpa/ScheduleDto.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package io.crnk.example.service.jpa;
-
-import io.crnk.core.resource.annotations.JsonApiId;
-import io.crnk.core.resource.annotations.JsonApiResource;
-
-@JsonApiResource(type = "scheduleDto")
-public class ScheduleDto {
-
- @JsonApiId
- private Long id;
-
- private String name;
-
- /**
- * See ExampleJpaModuleConfigurer how a JPA Criteria expression is used to fill-up this attribute
- */
- private String computedUpperName;
-
- /**
- * See ExampleDecoratorFactory how this attribute is filled-up by a decorator.
- */
- private String decoratedName;
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getComputedUpperName() {
- return computedUpperName;
- }
-
- public void setComputedUpperName(String computedUpperName) {
- this.computedUpperName = computedUpperName;
- }
-
- public String getDecoratedName() {
- return decoratedName;
- }
-
- public void setDecoratedName(String decoratedName) {
- this.decoratedName = decoratedName;
- }
-}
diff --git a/crnk-example-service/src/main/java/io/crnk/example/service/jpa/ScheduleRepository.java b/crnk-example-service/src/main/java/io/crnk/example/service/jpa/ScheduleRepository.java
new file mode 100644
index 0000000..d8009bd
--- /dev/null
+++ b/crnk-example-service/src/main/java/io/crnk/example/service/jpa/ScheduleRepository.java
@@ -0,0 +1,14 @@
+package io.crnk.example.service.jpa;
+
+import io.crnk.jpa.JpaEntityRepositoryBase;
+import org.springframework.stereotype.Component;
+
+import java.util.UUID;
+
+@Component
+public class ScheduleRepository extends JpaEntityRepositoryBase {
+
+ public ScheduleRepository() {
+ super(ScheduleEntity.class);
+ }
+}
diff --git a/crnk-example-service/src/main/java/io/crnk/example/service/relationship/basic/ScreeningLocationRepository.java b/crnk-example-service/src/main/java/io/crnk/example/service/relationship/basic/ScreeningLocationRepository.java
index c3dc277..2a1dd91 100644
--- a/crnk-example-service/src/main/java/io/crnk/example/service/relationship/basic/ScreeningLocationRepository.java
+++ b/crnk-example-service/src/main/java/io/crnk/example/service/relationship/basic/ScreeningLocationRepository.java
@@ -1,7 +1,5 @@
package io.crnk.example.service.relationship.basic;
-import java.util.UUID;
-
import io.crnk.core.queryspec.QuerySpec;
import io.crnk.core.repository.RelationshipRepositoryV2;
import io.crnk.core.resource.list.ResourceList;
@@ -11,58 +9,60 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.util.UUID;
+
/**
* Establishes a relationship between screenings and location.
*/
@Component
public class ScreeningLocationRepository implements RelationshipRepositoryV2 {
- private LocationRepository locationRepository;
+ private LocationRepository locationRepository;
- @Autowired
- public ScreeningLocationRepository(LocationRepository locationRepository) {
- this.locationRepository = locationRepository;
- }
+ @Autowired
+ public ScreeningLocationRepository(LocationRepository locationRepository) {
+ this.locationRepository = locationRepository;
+ }
- @Override
- public Class getSourceResourceClass() {
- return Screening.class;
- }
+ @Override
+ public Class getSourceResourceClass() {
+ return Screening.class;
+ }
- @Override
- public Class getTargetResourceClass() {
- return Location.class;
- }
+ @Override
+ public Class getTargetResourceClass() {
+ return Location.class;
+ }
- @Override
- public Location findOneTarget(UUID sourceId, String fieldName, QuerySpec querySpec) {
- // a real-world implementation would do something more reasonable here...
- Location someLocation = locationRepository.locations.values().iterator().next();
- return someLocation;
- }
+ @Override
+ public Location findOneTarget(UUID sourceId, String fieldName, QuerySpec querySpec) {
+ // a real-world implementation would do something more reasonable here...
+ ResourceList list = locationRepository.findAll(querySpec);
+ return list.isEmpty() ? null : list.get(0);
+ }
- @Override
- public void setRelation(Screening source, String targetId, String fieldName) {
- throw new UnsupportedOperationException();
- }
+ @Override
+ public void setRelation(Screening source, String targetId, String fieldName) {
+ throw new UnsupportedOperationException();
+ }
- @Override
- public void setRelations(Screening source, Iterable targetIds, String fieldName) {
- throw new UnsupportedOperationException();
- }
+ @Override
+ public void setRelations(Screening source, Iterable targetIds, String fieldName) {
+ throw new UnsupportedOperationException();
+ }
- @Override
- public void addRelations(Screening source, Iterable targetIds, String fieldName) {
- throw new UnsupportedOperationException();
- }
+ @Override
+ public void addRelations(Screening source, Iterable targetIds, String fieldName) {
+ throw new UnsupportedOperationException();
+ }
- @Override
- public void removeRelations(Screening source, Iterable targetIds, String fieldName) {
- throw new UnsupportedOperationException();
- }
+ @Override
+ public void removeRelations(Screening source, Iterable targetIds, String fieldName) {
+ throw new UnsupportedOperationException();
+ }
- @Override
- public ResourceList findManyTargets(UUID sourceId, String fieldName, QuerySpec querySpec) {
- throw new UnsupportedOperationException();
- }
+ @Override
+ public ResourceList findManyTargets(UUID sourceId, String fieldName, QuerySpec querySpec) {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/crnk-example-service/src/main/resources/application.yaml b/crnk-example-service/src/main/resources/application.yaml
index a5a6c71..5242265 100644
--- a/crnk-example-service/src/main/resources/application.yaml
+++ b/crnk-example-service/src/main/resources/application.yaml
@@ -8,8 +8,6 @@ management:
crnk:
path-prefix: /api
default-page-limit: 20
- jpa:
- expose-all: false
security:
enabled: ${example.security-enabled}
diff --git a/crnk-example-service/src/main/resources/logback.xml b/crnk-example-service/src/main/resources/logback.xml
index ab3f07a..dbb2f4f 100644
--- a/crnk-example-service/src/main/resources/logback.xml
+++ b/crnk-example-service/src/main/resources/logback.xml
@@ -9,8 +9,11 @@
+
+
+
-
+
diff --git a/crnk-example-service/src/main/resources/static/index.html b/crnk-example-service/src/main/resources/static/index.html
new file mode 100644
index 0000000..fa32405
--- /dev/null
+++ b/crnk-example-service/src/main/resources/static/index.html
@@ -0,0 +1,5 @@
+
+
+Welcome to the Crnk example application. For the endpoint have a look at /api/.
+
+
\ No newline at end of file
diff --git a/crnk-example-service/src/test/java/io/crnk/example/service/simple/ExampleApplicationTest.java b/crnk-example-service/src/test/java/io/crnk/example/service/simple/ExampleApplicationTest.java
index 1a367cc..fa71494 100644
--- a/crnk-example-service/src/test/java/io/crnk/example/service/simple/ExampleApplicationTest.java
+++ b/crnk-example-service/src/test/java/io/crnk/example/service/simple/ExampleApplicationTest.java
@@ -1,99 +1,70 @@
package io.crnk.example.service.simple;
-import static org.springframework.http.HttpStatus.OK;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import javax.security.auth.message.config.AuthConfigFactory;
-
import com.jayway.restassured.RestAssured;
import io.crnk.core.queryspec.QuerySpec;
import io.crnk.core.repository.ResourceRepositoryV2;
import io.crnk.core.resource.list.ResourceList;
import io.crnk.example.service.basic.Screening;
-import io.crnk.example.service.jpa.ScheduleDto;
import io.crnk.example.service.jpa.ScheduleEntity;
import org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import javax.security.auth.message.config.AuthConfigFactory;
+import java.io.Serializable;
+import java.util.Arrays;
+
+import static org.springframework.http.HttpStatus.OK;
+
/**
* Shows two kinds of test cases: RestAssured and CrnkClient.
*/
public class ExampleApplicationTest extends BaseTest {
- @Before
- public void setup() {
- // NPE fix
- if (AuthConfigFactory.getFactory() == null) {
- AuthConfigFactory.setFactory(new AuthConfigFactoryImpl());
- }
- }
-
- @Test
- public void testJpaEntityAccess() {
- ResourceRepositoryV2 entityRepo = client.getRepositoryForType(ScheduleEntity.class);
-
- QuerySpec querySpec = new QuerySpec(ScheduleEntity.class);
- ResourceList list = entityRepo.findAll(querySpec);
- for (ScheduleEntity schedule : list) {
- entityRepo.delete(schedule.getId());
- }
-
- ScheduleEntity schedule = new ScheduleEntity();
- schedule.setId(13L);
- schedule.setName("My Schedule");
- entityRepo.create(schedule);
-
- list = entityRepo.findAll(querySpec);
- Assert.assertEquals(1, list.size());
- }
-
- @Test
- public void testDtoMapping() {
- ResourceRepositoryV2 entityRepo = client.getRepositoryForType(ScheduleDto.class);
-
- QuerySpec querySpec = new QuerySpec(ScheduleDto.class);
- ResourceList list = entityRepo.findAll(querySpec);
- for (ScheduleDto schedule : list) {
- entityRepo.delete(schedule.getId());
- }
-
- ScheduleDto schedule = new ScheduleDto();
- schedule.setId(13L);
- schedule.setName("My Schedule");
- entityRepo.create(schedule);
-
- list = entityRepo.findAll(querySpec);
- Assert.assertEquals(1, list.size());
- schedule = list.get(0);
- Assert.assertEquals(13L, schedule.getId().longValue());
- Assert.assertEquals("My Schedule", schedule.getName());
-
- // a computed attribute!
- Assert.assertEquals("MY SCHEDULE", schedule.getComputedUpperName());
-
- // a decorated attribute!
- Assert.assertEquals("decoratedFindAll", schedule.getDecoratedName());
- }
-
- @Test
- public void testAccessHome() {
- RestAssured.given().contentType("*").when().get("/api/").then()
- .statusCode(OK.value());
- }
-
-
- @Test
- public void testBasicRelationship() {
- QuerySpec querySpec = new QuerySpec(Screening.class);
- querySpec.includeRelation(Arrays.asList("location"));
- ResourceRepositoryV2 repository = client.getRepositoryForType(Screening.class);
- ResourceList list = repository.findAll(querySpec);
- Assert.assertNotEquals(0, list.size());
- for (Screening screening : list) {
- Assert.assertNotNull(screening.getLocation());
- }
- }
+ @Before
+ public void setup() {
+ // NPE fix
+ if (AuthConfigFactory.getFactory() == null) {
+ AuthConfigFactory.setFactory(new AuthConfigFactoryImpl());
+ }
+ }
+
+ @Test
+ public void testJpaEntityAccess() {
+ ResourceRepositoryV2 entityRepo = client.getRepositoryForType(ScheduleEntity.class);
+
+ QuerySpec querySpec = new QuerySpec(ScheduleEntity.class);
+ ResourceList list = entityRepo.findAll(querySpec);
+ for (ScheduleEntity schedule : list) {
+ entityRepo.delete(schedule.getId());
+ }
+
+ ScheduleEntity schedule = new ScheduleEntity();
+ schedule.setId(13L);
+ schedule.setName("My Schedule");
+ entityRepo.create(schedule);
+
+ list = entityRepo.findAll(querySpec);
+ Assert.assertEquals(1, list.size());
+ }
+
+ @Test
+ public void testAccessHome() {
+ RestAssured.given().contentType("*").when().get("/api/").then()
+ .statusCode(OK.value());
+ }
+
+
+ @Test
+ public void testBasicRelationship() {
+ QuerySpec querySpec = new QuerySpec(Screening.class);
+ querySpec.includeRelation(Arrays.asList("location"));
+ ResourceRepositoryV2 repository = client.getRepositoryForType(Screening.class);
+ ResourceList list = repository.findAll(querySpec);
+ Assert.assertNotEquals(0, list.size());
+ for (Screening screening : list) {
+ Assert.assertNotNull(screening.getLocation());
+ }
+ }
}
diff --git a/settings.gradle b/settings.gradle
index 7b3f401..2056b36 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,4 +1,4 @@
-include ':crnk-example-service', 'crnk-example-frontend'
+include ':crnk-example-service'
gradle.beforeProject { Project project ->
project.with {
diff --git a/versions.properties b/versions.properties
index 4782bd0..409f5ee 100644
--- a/versions.properties
+++ b/versions.properties
@@ -1 +1 @@
-crnk.version=2.10.20181129142450
\ No newline at end of file
+crnk.version=2.11.20190113153635
\ No newline at end of file