Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename module #121

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ services:
before_script:
- psql -c 'create database frameworkeventstore;' -U postgres
- psql -c 'create database frameworkviewstore;' -U postgres
- psql -c 'create database frameworkfilestore;' -U postgres
- psql -c 'create database fileservice;' -U postgres
- psql -c 'create database frameworksystem;' -U postgres
- psql -c "CREATE USER framework WITH PASSWORD 'framework';" -U postgres
- psql -c "CREATE USER fileservice WITH PASSWORD 'fileservice';" -U postgres
addons:
postgresql: '9.5'
sonarcloud:
Expand Down
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to
[Semantic Versioning](http://semver.org/).

## [Unreleased]
### Changed
- Provide capability to deploy in local dev environment
- Reorganise modules and move them to root level

## [17.0.1] - 2023-12-13
### Changed
Expand Down Expand Up @@ -89,7 +92,7 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to
- Update json-schema-catalog to 1.7.4

### Changed
- Use a single event-source.yaml in example-event-source module
- Use a single event-source.yaml in cakeshop-event-source module

## [2.0.0-M3] - 2019-05-09

Expand Down Expand Up @@ -165,6 +168,6 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to
## [1.0.0] - 2018-11-09

### Added
- Extracted project from example app in Microservices Framework 5.0.0-M1: https://github.com/CJSCommonPlatform/microservice_framework
- Extracted project from cakeshop app in Microservices Framework 5.0.0-M1: https://github.com/CJSCommonPlatform/microservice_framework


4 changes: 2 additions & 2 deletions Licence.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This licence does not affect your freedom under fair dealing or fair use or any
You are free to:
copy, publish, distribute and transmit the Information;
adapt the Information;
exploit the Information commercially and non-commercially for example, by combining it with other Information, or by including it in your own product or application.
exploit the Information commercially and non-commercially for cakeshop, by combining it with other Information, or by including it in your own product or application.


You must (where you do any of the above):
Expand Down Expand Up @@ -56,7 +56,7 @@ Definitions

In this licence, the terms below have the following meanings:

'Information' means information protected by copyright or by database right (for example, literary and artistic works, content, data and source code) offered for use under the terms of this licence.
'Information' means information protected by copyright or by database right (for cakeshop, literary and artistic works, content, data and source code) offered for use under the terms of this licence.

'Information Provider' means the person or organisation providing the Information under this licence.

Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,21 @@


# cake-shop

## How deployment works?
Unlike other contexts, this cakeshop project uses a different approach as this belong to framework (github). Integration tests of this component gets executed in CI pipeline which runs
in travis. So, to get this working in travis pipeline this component gets deployed to embedded wildfly using maven plugin and then ITs are executed against embedded wildfly instance.
All this is setup through integration-test module's pom.xml. Artemis runs as embedded broker in wildfly. Spinning up embedded wildfly uses random ports approach i.e. free ports are selected by maven plugin
and then those ports are used to spin up required services and this is necessary to avoid port clash with local dev environment, so that there is no requirement to shutdown local dev environment
before running build on this component. There is a separate version of standalone.xml file in integration-test module that is used for embedded wildfly instance

By running `mvn clean install` basically it builds the project and deploys service war file to embedded wildfly instance and then runs all Integration tests. While running

One issue with above approach is, it's bit hard to debug any integration tests from IDE (it's not impossible but requires little bit of tweaks to setup process). In order to support
debugging ITs this application can also be deployed to local dev environment using this [script](runIntegrationTests.sh). This script builds application without any tests and deploys service war file to
local dev environment. Until other contexts this script is not going to run any integration tests. Once application is deployed any IT can be run from intellij as normal.

Port selection switching logic is incorporated in on the test helper class, so that when a test is run from IDE it returns local dev environment ports, but when tests are run through mvn command
it returns random ports that are selected by maven plugin for running the application using embedded wildfly.


Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>example-command</artifactId>
<groupId>uk.gov.justice.services.example</groupId>
<artifactId>cakeshop-command</artifactId>
<groupId>uk.gov.justice.services.cakeshop</groupId>
<version>17.0.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>example-command-api</artifactId>
<artifactId>cakeshop-command-api</artifactId>
<packaging>war</packaging>

<properties>
Expand Down Expand Up @@ -114,8 +114,8 @@
</executions>
<dependencies>
<dependency>
<groupId>uk.gov.justice.services.example</groupId>
<artifactId>example-command-handler</artifactId>
<groupId>uk.gov.justice.services.cakeshop</groupId>
<artifactId>cakeshop-command-handler</artifactId>
<version>${project.version}</version>
<classifier>raml</classifier>
</dependency>
Expand All @@ -124,6 +124,11 @@
<artifactId>messaging-client-generator</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.justice.services.example.cakeshop.command.api;
package uk.gov.justice.services.cakeshop.cakeshop.command.api;

import static javax.json.Json.createObjectBuilder;
import static uk.gov.justice.services.core.annotation.Component.COMMAND_API;
Expand All @@ -19,17 +19,17 @@ public class MakeCakeCommandApi {
@Inject
Sender sender;

@Handles("example.make-cake")
@Handles("cakeshop.make-cake")
public Envelope<JsonObject> handle(final JsonEnvelope envelope) {
sender.send(envelop(envelope.payloadAsJsonObject())
.withName("example.command.make-cake")
.withName("cakeshop.command.make-cake")
.withMetadataFrom(envelope));

return envelop(
createObjectBuilder()
.add("status", "Making Cake")
.build())
.withName("example.command.make-cake-status")
.withName("cakeshop.command.make-cake-status")
.withMetadataFrom(envelope);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.justice.services.example.cakeshop.command.api;
package uk.gov.justice.services.cakeshop.cakeshop.command.api;

import static uk.gov.justice.services.core.annotation.Component.COMMAND_API;
import static uk.gov.justice.services.core.enveloper.Enveloper.envelop;
Expand All @@ -16,11 +16,11 @@ public class OrderCakeCommandApi {
@Inject
Sender sender;

@Handles("example.order-cake")
@Handles("cakeshop.order-cake")
public void orderCake(final JsonEnvelope envelope) {
sender.send(
envelop(envelope.payloadAsJsonObject())
.withName("example.command.order-cake")
.withName("cakeshop.command.order-cake")
.withMetadataFrom(envelope));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.justice.services.example.cakeshop.command.api;
package uk.gov.justice.services.cakeshop.cakeshop.command.api;

import static uk.gov.justice.services.core.annotation.Component.COMMAND_API;
import static uk.gov.justice.services.core.enveloper.Enveloper.envelop;
Expand All @@ -22,41 +22,41 @@ public class RecipeCommandApi {
@Inject
Logger logger;

@Handles("example.add-recipe")
@Handles("cakeshop.add-recipe")
public void addRecipe(final JsonEnvelope envelope) {
sender.send(
envelop(envelope.payloadAsJsonObject())
.withName("example.command.add-recipe")
.withName("cakeshop.command.add-recipe")
.withMetadataFrom(envelope));
}

@Handles("example.add-recipe-v2")
@Handles("cakeshop.add-recipe-v2")
@FeatureControl("recipes-have-allergens-specified")
public void addRecipeWithAllergenSupport(final JsonEnvelope envelope) {
logger.warn("Call to in progress method. Feature 'recipes-have-allergens-specified' is enabled");
}

@Handles("example.rename-recipe")
@Handles("cakeshop.rename-recipe")
public void renameRecipe(final JsonEnvelope envelope) {
sender.send(
envelop(envelope.payloadAsJsonObject())
.withName("example.command.rename-recipe")
.withName("cakeshop.command.rename-recipe")
.withMetadataFrom(envelope));
}

@Handles("example.remove-recipe")
@Handles("cakeshop.remove-recipe")
public void removeRecipe(final JsonEnvelope envelope) {
sender.send(
envelop(envelope.payloadAsJsonObject())
.withName("example.command.remove-recipe")
.withName("cakeshop.command.remove-recipe")
.withMetadataFrom(envelope));
}

@Handles("example.upload-photograph")
@Handles("cakeshop.upload-photograph")
public void uploadPhotograph(final JsonEnvelope envelope) {
sender.send(
envelop(envelope.payloadAsJsonObject())
.withName("example.command.upload-photograph")
.withName("cakeshop.command.upload-photograph")
.withMetadataFrom(envelope));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.justice.services.example.pojo;
package uk.gov.justice.services.cakeshop.pojo;

public class CakeOrder {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.justice.services.example.provider;
package uk.gov.justice.services.cakeshop.provider;

import static uk.gov.justice.services.core.annotation.Component.COMMAND_API;

Expand All @@ -10,11 +10,11 @@
import java.util.ArrayList;
import java.util.List;

public class ExampleCommandApiInterceptorChainProvider implements InterceptorChainEntryProvider {
public class CakeshopCommandApiInterceptorChainProvider implements InterceptorChainEntryProvider {

final List<InterceptorChainEntry> interceptorChainEntries = new ArrayList<>();

public ExampleCommandApiInterceptorChainProvider() {
public CakeshopCommandApiInterceptorChainProvider() {
interceptorChainEntries.add(new InterceptorChainEntry(7000, InputStreamFileInterceptor.class));
interceptorChainEntries.add(new InterceptorChainEntry(8000, FeatureControlInterceptor.class));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#%RAML 0.8
title: Cakeshop Command API
baseUri: http://localhost:8080/cakeshop-command-api/command/api/rest/cakeshop
version: v0.1
mediaType: application/json
protocols: [ HTTP, HTTPS ]

/recipes/{recipeId}:
description: |
Add a new recipe
post:
description: |
...
(mapping):
requestType: application/vnd.cakeshop.add-recipe+json
name: cakeshop.add-recipe
(mapping):
requestType: application/vnd.cakeshop.add-recipe-v2+json
name: cakeshop.add-recipe-v2
(mapping):
requestType: application/vnd.cakeshop.remove-recipe+json
name: cakeshop.remove-recipe
...

body:
application/vnd.cakeshop.add-recipe+json:
schema: !include json/schema/cakeshop.add-recipe.json
example: !include json/add-recipe.json

application/vnd.cakeshop.add-recipe-v2+json:
schema: !include json/schema/cakeshop.add-recipe.json
example: !include json/add-recipe.json

application/vnd.cakeshop.remove-recipe+json: !!null

put:
description: |
...
(mapping):
requestType: application/vnd.cakeshop.rename-recipe+json
name: cakeshop.rename-recipe
...

body:
application/vnd.cakeshop.rename-recipe+json:
schema: !include json/schema/cakeshop.rename-recipe.json
example: !include json/rename-recipe.json


/recipes/{recipeId}/cakes/{cakeId}:
description: |
Make a cake from id in json
post:
description: |
...
(mapping):
requestType: application/vnd.cakeshop.make-cake+json
name: cakeshop.make-cake
...
body:
application/vnd.cakeshop.make-cake+json:
schema: !include json/schema/cakeshop.make-cake.json
example: !include json/make-cake.json
responses:
202:
body:
application/vnd.cakeshop.make-cake-status+json:
schema: !include json/schema/cakeshop.make-cake-status.json
example: !include json/make-cake-status.json

/orders/{orderId}:
description: |
Order a cake
post:
description: |
...
(mapping):
requestType: application/vnd.cakeshop.order-cake+json
name: cakeshop.order-cake
...
body:
application/vnd.cakeshop.order-cake+json:
schema: !include json/schema/cakeshop.order-cake.json
example: !include json/order-cake.json

/recipes/{recipeId}/photograph:
post:
description: |
Upload recipe photograph
...
(mapping):
requestType: multipart/form-data
name: cakeshop.upload-photograph
...
body:
multipart/form-data:
formParameters:
photoId:
description: Photo of recipe
type: file
responses:
202:
description: Request accepted
400:
description: Bad Request
500:
description: Internal Server Error
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://justice.gov.uk/example/command/api/example.add-recipe-file.json",
"id": "http://justice.gov.uk/cakeshop/command/api/cakeshop.add-recipe-file.json",
"type": "object",
"properties": {
"fileName": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://justice.gov.uk/example/command/api/example.add-recipe-v2.json",
"id": "http://justice.gov.uk/cakeshop/command/api/cakeshop.add-recipe-v2.json",
"type": "object",
"properties": {
"name": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://justice.gov.uk/example/command/api/example.add-recipe.json",
"id": "http://justice.gov.uk/cakeshop/command/api/cakeshop.add-recipe.json",
"type": "object",
"properties": {
"name": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://justice.gov.uk/example/command/api/example.make-cake-status.json",
"id": "http://justice.gov.uk/cakeshop/command/api/cakeshop.make-cake-status.json",
"type": "object",
"properties": {
"status": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://justice.gov.uk/example/command/api/example.make-cake.json",
"id": "http://justice.gov.uk/cakeshop/command/api/cakeshop.make-cake.json",
"type": "object",
"properties": {
}
Expand Down
Loading