Skip to content
This repository was archived by the owner on Dec 5, 2023. It is now read-only.

Commit efc12f9

Browse files
authored
Merge pull request #13 from microservices-demo/remove_accounts_reference
Remove reference to accounts
2 parents 6ca5b49 + 12d44d9 commit efc12f9

File tree

3 files changed

+29
-26
lines changed

3 files changed

+29
-26
lines changed

api-spec/cart.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
"application/json;charset=UTF-8",
2020
"text/plain"
2121
],
22-
"produces": [
23-
"application/json;charset=UTF-8",
24-
"text/plain"
25-
26-
],
2722
"paths": {
2823
"/carts/{customerId}": {
2924
"get": {
@@ -53,9 +48,6 @@
5348
"delete": {
5449
"description": "",
5550
"operationId": "Delete cart",
56-
"produces": [
57-
"application/json;charset=UTF-8"
58-
],
5951
"parameters": [
6052
{
6153
"name": "customerId",
@@ -144,7 +136,6 @@
144136
"delete": {
145137
"description": "Delete cart item",
146138
"operationId": "delete",
147-
148139
"parameters": [
149140
{
150141
"name": "itemId",

api-spec/hooks.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ const ObjectID = require('mongodb').ObjectID;
55
let db;
66

77
const address = [
8-
{"_id":ObjectID("579f21ae98684924944651bd"),"_class":"works.weave.socks.accounts.entities.Address","number":"69","street":"Wilson Street","city":"Hartlepool","postcode":"TS26 8JU","country":"United Kingdom"},
9-
{"_id":ObjectID("579f21ae98684924944651c0"),"_class":"works.weave.socks.accounts.entities.Address","number":"122","street":"Radstone WayNet","city":"Northampton","postcode":"NN2 8NT","country":"United Kingdom"},
10-
{"_id":ObjectID("579f21ae98684924944651c3"),"_class":"works.weave.socks.accounts.entities.Address","number":"3","street":"Radstone Way","city":"Northampton","postcode":"NN2 8NT","country":"United Kingdom"}
8+
{"_id":ObjectID("579f21ae98684924944651bd"),"_class":"works.weave.socks.users.entities.Address","number":"69","street":"Wilson Street","city":"Hartlepool","postcode":"TS26 8JU","country":"United Kingdom"},
9+
{"_id":ObjectID("579f21ae98684924944651c0"),"_class":"works.weave.socks.users.entities.Address","number":"122","street":"Radstone WayNet","city":"Northampton","postcode":"NN2 8NT","country":"United Kingdom"},
10+
{"_id":ObjectID("579f21ae98684924944651c3"),"_class":"works.weave.socks.users.entities.Address","number":"3","street":"Radstone Way","city":"Northampton","postcode":"NN2 8NT","country":"United Kingdom"}
1111
];
1212

1313

1414
const card = [
15-
{"_id":ObjectID("579f21ae98684924944651be"),"_class":"works.weave.socks.accounts.entities.Card","longNum":"8575776807334952","expires":"08/19","ccv":"014"},
16-
{"_id":ObjectID("579f21ae98684924944651c1"),"_class":"works.weave.socks.accounts.entities.Card","longNum":"8918468841895184","expires":"08/19","ccv":"597"},
17-
{"_id":ObjectID("579f21ae98684924944651c4"),"_class":"works.weave.socks.accounts.entities.Card","longNum":"6426429851404909","expires":"08/19","ccv":"381"}
15+
{"_id":ObjectID("579f21ae98684924944651be"),"_class":"works.weave.socks.users.entities.Card","longNum":"8575776807334952","expires":"08/19","ccv":"014"},
16+
{"_id":ObjectID("579f21ae98684924944651c1"),"_class":"works.weave.socks.users.entities.Card","longNum":"8918468841895184","expires":"08/19","ccv":"597"},
17+
{"_id":ObjectID("579f21ae98684924944651c4"),"_class":"works.weave.socks.users.entities.Card","longNum":"6426429851404909","expires":"08/19","ccv":"381"}
1818
];
1919

2020
const cart = [
@@ -29,10 +29,10 @@ const item = [
2929

3030

3131
const customer = [
32-
{"_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")}]
32+
{"_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")}]
3333
},
34-
{"_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")}]},
35-
{"_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")}]}
34+
{"_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")}]},
35+
{"_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")}]}
3636
];
3737

3838

@@ -63,7 +63,7 @@ hooks.beforeEach((transaction, done) => {
6363
done();
6464
});
6565
})
66-
66+
6767
});
6868

6969

@@ -80,7 +80,7 @@ hooks.before("/carts/{customerId}/items > POST", function(transaction, done) {
8080
done();
8181
});
8282

83-
// TODO: Can't make POST and PUT work, skipping for now
83+
// TODO: Can't make POST and PUT work, skipping for now
8484

8585
// hooks.before("/carts/{customerId}/items > POST", function(transaction, done) {
8686
// transaction.skip = true;

src/test/java/works/weave/socks/cart/controllers/UnitHealthCheckController.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@
55
import org.springframework.beans.factory.annotation.Autowired;
66
import org.springframework.context.annotation.Bean;
77
import org.springframework.context.annotation.Configuration;
8+
import org.springframework.data.mongodb.core.MongoTemplate;
89
import org.springframework.test.context.ContextConfiguration;
910
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10-
1111
import static org.hamcrest.CoreMatchers.equalTo;
1212
import static org.hamcrest.CoreMatchers.is;
13-
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
14-
import static org.hamcrest.collection.IsEmptyCollection.empty;
15-
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
1613
import static org.junit.Assert.assertThat;
17-
14+
import static org.mockito.Mockito.*;
1815
import works.weave.socks.cart.entities.HealthCheck;
1916

17+
2018
import java.util.ArrayList;
2119
import java.util.Calendar;
2220
import java.util.Date;
@@ -33,7 +31,21 @@ public class UnitHealthCheckController {
3331

3432
@Test
3533
public void shouldGetHealth() {
36-
Map<String, List<HealthCheck>> results = healthCheckController.getHealth();
34+
Map<String, List<HealthCheck>> results = this.healthCheckController.getHealth();
3735
assertThat(results.get("health").size(), is(equalTo(2)));
3836
}
37+
38+
@Configuration
39+
static class HealthCheckControllerTestConfiguration {
40+
@Bean
41+
public HealthCheckController healthCheckController() {
42+
return new HealthCheckController();
43+
}
44+
45+
@Bean
46+
public MongoTemplate mongoTemplate() {
47+
MongoTemplate mongoTemplate = mock(MongoTemplate.class);
48+
return mongoTemplate;
49+
}
50+
}
3951
}

0 commit comments

Comments
 (0)