Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
ge-mange
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
joel.cavat
ge-mange
Commits
115264ce
Commit
115264ce
authored
6 years ago
by
roxanne.grant
Browse files
Options
Downloads
Patches
Plain Diff
created an idService in class http to increment id at each new scenario
parent
00a083d2
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
services/src/main/java/ch/hepia/order/http.java
+16
-9
16 additions, 9 deletions
services/src/main/java/ch/hepia/order/http.java
with
16 additions
and
9 deletions
services/src/main/java/ch/hepia/order/http.java
+
16
−
9
View file @
115264ce
...
...
@@ -19,22 +19,27 @@ public class http {
private
static
OrderService
orderService
;
private
static
AccountService
accountService
;
private
static
StockService
stockService
;
private
static
int
idService
;
public
static
void
main
(
String
[]
args
)
{
http
.
orderService
=
new
OrderService
(
"localhost"
);
http
.
accountService
=
new
AccountService
(
"localhost"
);
http
.
stockService
=
new
StockService
(
"localhost"
);
http
.
idService
=
0
;
SpringApplication
.
run
(
http
.
class
,
args
);
}
public
static
int
getId
()
{
return
http
.
idService
;
}
public
static
void
incrementId
()
{
http
.
idService
++;
}
@RequestMapping
(
"/order"
)
public
Order
order
(
@RequestParam
(
value
=
"idAccount"
,
defaultValue
=
"1"
)
int
idAccount
,
@RequestParam
(
value
=
"idProduct"
,
defaultValue
=
"1"
)
int
idProduct
,
@RequestParam
(
value
=
"quantity"
,
defaultValue
=
"1"
)
int
quantity
)
{
int
idOrder
=
5
;
Order
o
=
new
Order
(
idOrder
,
idAccount
);
http
.
incrementId
()
;
Order
o
=
new
Order
(
http
.
getId
()
,
idAccount
);
o
.
addProduct
(
idProduct
,
quantity
);
Event
oc
=
new
EventOrderCreated
(
o
.
id
(),
"hello"
,
idAccount
,
o
.
getProducts
());
...
...
@@ -45,8 +50,8 @@ public class http {
@RequestMapping
(
"/orderNotExistingProducts"
)
public
Order
orderNotExistingProducts
()
{
int
idAccount
=
1
;
int
idOrder
=
5
;
Order
o
=
new
Order
(
idOrder
,
idAccount
);
http
.
incrementId
()
;
Order
o
=
new
Order
(
http
.
getId
()
,
idAccount
);
o
.
addProduct
(
1
,
4
);
o
.
addProduct
(
999
,
4
);
Event
oc
=
new
EventOrderCreated
(
o
.
id
(),
"hello"
,
idAccount
,
o
.
getProducts
());
...
...
@@ -56,7 +61,8 @@ public class http {
@RequestMapping
(
"/createAccount"
)
public
String
createAccount
(
@RequestParam
(
value
=
"name"
,
defaultValue
=
"Orphée"
)
String
name
)
{
accountService
.
send
(
new
EventCreateAccount
(
1
,
"Creating the account"
,
name
));
http
.
incrementId
();
accountService
.
send
(
new
EventCreateAccount
(
http
.
getId
(),
"Creating the account"
,
name
));
return
name
;
}
...
...
@@ -64,7 +70,8 @@ public class http {
public
String
createAccount
(
@RequestParam
(
value
=
"idAccount"
,
defaultValue
=
"1"
)
int
idAccount
,
@RequestParam
(
value
=
"amount"
,
defaultValue
=
"1"
)
double
amount
)
{
accountService
.
send
(
new
EventCreditAnAccount
(
5
,
"Crediting account"
,
idAccount
,
amount
));
http
.
incrementId
();
accountService
.
send
(
new
EventCreditAnAccount
(
http
.
getId
(),
"Crediting account"
,
idAccount
,
amount
));
return
null
;
}
...
...
@@ -72,8 +79,8 @@ public class http {
@RequestMapping
(
"/createProduct"
)
public
Product
createProduct
(
@RequestParam
(
value
=
"name"
,
defaultValue
=
"poire"
)
String
name
,
@RequestParam
(
value
=
"price"
,
defaultValue
=
"1"
)
double
price
)
{
stockService
.
send
(
new
EventCreateProduct
(
1
,
"Creating the product"
,
name
,
price
));
http
.
incrementId
();
stockService
.
send
(
new
EventCreateProduct
(
http
.
getId
()
,
"Creating the product"
,
name
,
price
));
return
null
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment