diff --git a/api-spec/cart.json b/api-spec/cart.json index 856eb3248c0079fa8d08b7e7b4e8e4d36ccfcbdd..2d210d2e4ec0d2b21866d81c5a3ea6a04b4bac28 100644 --- a/api-spec/cart.json +++ b/api-spec/cart.json @@ -19,11 +19,6 @@ "application/json;charset=UTF-8", "text/plain" ], - "produces": [ - "application/json;charset=UTF-8", - "text/plain" - - ], "paths": { "/carts/{customerId}": { "get": { @@ -53,9 +48,6 @@ "delete": { "description": "", "operationId": "Delete cart", - "produces": [ - "application/json;charset=UTF-8" - ], "parameters": [ { "name": "customerId", @@ -144,7 +136,6 @@ "delete": { "description": "Delete cart item", "operationId": "delete", - "parameters": [ { "name": "itemId", diff --git a/api-spec/hooks.js b/api-spec/hooks.js index 879c9d1ed37f54bf955de834a6785fe50674bb1b..91e8bcab29ec9ae5bdc7bf99e8a30c35d5336a6d 100644 --- a/api-spec/hooks.js +++ b/api-spec/hooks.js @@ -5,16 +5,16 @@ const ObjectID = require('mongodb').ObjectID; let db; const address = [ - {"_id":ObjectID("579f21ae98684924944651bd"),"_class":"works.weave.socks.accounts.entities.Address","number":"69","street":"Wilson Street","city":"Hartlepool","postcode":"TS26 8JU","country":"United Kingdom"}, - {"_id":ObjectID("579f21ae98684924944651c0"),"_class":"works.weave.socks.accounts.entities.Address","number":"122","street":"Radstone WayNet","city":"Northampton","postcode":"NN2 8NT","country":"United Kingdom"}, - {"_id":ObjectID("579f21ae98684924944651c3"),"_class":"works.weave.socks.accounts.entities.Address","number":"3","street":"Radstone Way","city":"Northampton","postcode":"NN2 8NT","country":"United Kingdom"} + {"_id":ObjectID("579f21ae98684924944651bd"),"_class":"works.weave.socks.users.entities.Address","number":"69","street":"Wilson Street","city":"Hartlepool","postcode":"TS26 8JU","country":"United Kingdom"}, + {"_id":ObjectID("579f21ae98684924944651c0"),"_class":"works.weave.socks.users.entities.Address","number":"122","street":"Radstone WayNet","city":"Northampton","postcode":"NN2 8NT","country":"United Kingdom"}, + {"_id":ObjectID("579f21ae98684924944651c3"),"_class":"works.weave.socks.users.entities.Address","number":"3","street":"Radstone Way","city":"Northampton","postcode":"NN2 8NT","country":"United Kingdom"} ]; const card = [ - {"_id":ObjectID("579f21ae98684924944651be"),"_class":"works.weave.socks.accounts.entities.Card","longNum":"8575776807334952","expires":"08/19","ccv":"014"}, - {"_id":ObjectID("579f21ae98684924944651c1"),"_class":"works.weave.socks.accounts.entities.Card","longNum":"8918468841895184","expires":"08/19","ccv":"597"}, - {"_id":ObjectID("579f21ae98684924944651c4"),"_class":"works.weave.socks.accounts.entities.Card","longNum":"6426429851404909","expires":"08/19","ccv":"381"} + {"_id":ObjectID("579f21ae98684924944651be"),"_class":"works.weave.socks.users.entities.Card","longNum":"8575776807334952","expires":"08/19","ccv":"014"}, + {"_id":ObjectID("579f21ae98684924944651c1"),"_class":"works.weave.socks.users.entities.Card","longNum":"8918468841895184","expires":"08/19","ccv":"597"}, + {"_id":ObjectID("579f21ae98684924944651c4"),"_class":"works.weave.socks.users.entities.Card","longNum":"6426429851404909","expires":"08/19","ccv":"381"} ]; const cart = [ @@ -29,10 +29,10 @@ const item = [ const customer = [ - {"_id":"579f21ae98684924944651bf","_class":"works.weave.socks.accounts.entities.Customer","firstName":"Eve","lastName":"Berger","username":"Eve_Berger","addresses":[{"$ref":"address","$id":ObjectID("579f21ae98684924944651bd")}],"cards":[{"$ref":"card","$id":ObjectID("579f21ae98684924944651be")}] + {"_id":"579f21ae98684924944651bf","_class":"works.weave.socks.users.entities.Customer","firstName":"Eve","lastName":"Berger","username":"Eve_Berger","addresses":[{"$ref":"address","$id":ObjectID("579f21ae98684924944651bd")}],"cards":[{"$ref":"card","$id":ObjectID("579f21ae98684924944651be")}] }, - {"_id":"579f21ae98684924944651c2","_class":"works.weave.socks.accounts.entities.Customer","firstName":"User","lastName":"Name","username":"user","addresses":[{"$ref":"address","$id":ObjectID("579f21ae98684924944651c0")}],"cards":[{"$ref":"card","$id":ObjectID("579f21ae98684924944651c1")}]}, - {"_id":"579f21ae98684924944651c5","_class":"works.weave.socks.accounts.entities.Customer","firstName":"User1","lastName":"Name1","username":"user1","addresses":[{"$ref":"address","$id":ObjectID("579f21ae98684924944651c3")}],"cards":[{"$ref":"card","$id":ObjectID("579f21ae98684924944651c4")}]} + {"_id":"579f21ae98684924944651c2","_class":"works.weave.socks.users.entities.Customer","firstName":"User","lastName":"Name","username":"user","addresses":[{"$ref":"address","$id":ObjectID("579f21ae98684924944651c0")}],"cards":[{"$ref":"card","$id":ObjectID("579f21ae98684924944651c1")}]}, + {"_id":"579f21ae98684924944651c5","_class":"works.weave.socks.users.entities.Customer","firstName":"User1","lastName":"Name1","username":"user1","addresses":[{"$ref":"address","$id":ObjectID("579f21ae98684924944651c3")}],"cards":[{"$ref":"card","$id":ObjectID("579f21ae98684924944651c4")}]} ]; @@ -63,7 +63,7 @@ hooks.beforeEach((transaction, done) => { done(); }); }) - + }); @@ -80,7 +80,7 @@ hooks.before("/carts/{customerId}/items > POST", function(transaction, done) { done(); }); -// TODO: Can't make POST and PUT work, skipping for now +// TODO: Can't make POST and PUT work, skipping for now // hooks.before("/carts/{customerId}/items > POST", function(transaction, done) { // transaction.skip = true; diff --git a/src/test/java/works/weave/socks/cart/controllers/UnitHealthCheckController.java b/src/test/java/works/weave/socks/cart/controllers/UnitHealthCheckController.java index 739113b8d5b99b4ebbf6d5ce813a15c7241c03c2..97b30ff57ef373e00b424aa08d346cdc38edd2a5 100644 --- a/src/test/java/works/weave/socks/cart/controllers/UnitHealthCheckController.java +++ b/src/test/java/works/weave/socks/cart/controllers/UnitHealthCheckController.java @@ -5,18 +5,16 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.collection.IsCollectionWithSize.hasSize; -import static org.hamcrest.collection.IsEmptyCollection.empty; -import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; import static org.junit.Assert.assertThat; - +import static org.mockito.Mockito.*; import works.weave.socks.cart.entities.HealthCheck; + import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -33,7 +31,21 @@ public class UnitHealthCheckController { @Test public void shouldGetHealth() { - Map<String, List<HealthCheck>> results = healthCheckController.getHealth(); + Map<String, List<HealthCheck>> results = this.healthCheckController.getHealth(); assertThat(results.get("health").size(), is(equalTo(2))); } + + @Configuration + static class HealthCheckControllerTestConfiguration { + @Bean + public HealthCheckController healthCheckController() { + return new HealthCheckController(); + } + + @Bean + public MongoTemplate mongoTemplate() { + MongoTemplate mongoTemplate = mock(MongoTemplate.class); + return mongoTemplate; + } + } }