Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
stocks-api-v2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sharma072072
stocks-api-v2
Commits
b7ae168e
Commit
b7ae168e
authored
May 07, 2022
by
sharma072072
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
date change to timestamp
parent
bb1c1495
Pipeline
#2293
failed with stages
in 73 minutes and 7 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
22 deletions
+30
-22
Stocks.java
src/main/java/com/altimetrik/ee/demo/bean/Stocks.java
+5
-4
project1170.mv.db
src/main/resources/project1170.mv.db
+0
-0
StocksControllerTest.java
...va/com/altimetrik/ee/demo/tests/StocksControllerTest.java
+15
-9
StocksRepositoryTest.java
...va/com/altimetrik/ee/demo/tests/StocksRepositoryTest.java
+10
-9
No files found.
src/main/java/com/altimetrik/ee/demo/bean/Stocks.java
View file @
b7ae168e
package
com
.
altimetrik
.
ee
.
demo
.
bean
;
import
java.sql.Timestamp
;
import
java.util.Date
;
import
java.util.Objects
;
...
...
@@ -17,7 +18,7 @@ public class Stocks {
String
companyName
;
@Column
(
name
=
"date"
)
Date
date
;
Timestamp
date
;
@Column
(
name
=
"price"
)
Double
price
;
...
...
@@ -25,7 +26,7 @@ public class Stocks {
@Column
(
name
=
"currency"
)
String
currency
;
public
Stocks
(
String
stockQuote
,
String
companyName
,
Date
date
,
Double
price
,
public
Stocks
(
String
stockQuote
,
String
companyName
,
Timestamp
date
,
Double
price
,
String
currency
)
{
this
.
stockQuote
=
stockQuote
;
this
.
companyName
=
companyName
;
...
...
@@ -45,7 +46,7 @@ public class Stocks {
return
companyName
;
}
public
Date
getDate
()
{
public
Timestamp
getDate
()
{
return
date
;
}
...
...
@@ -65,7 +66,7 @@ public class Stocks {
this
.
companyName
=
companyName
;
}
public
void
setDate
(
Date
date
)
{
public
void
setDate
(
Timestamp
date
)
{
this
.
date
=
date
;
}
...
...
src/main/resources/project1170.mv.db
View file @
b7ae168e
No preview for this file type
src/test/java/com/altimetrik/ee/demo/tests/StocksControllerTest.java
View file @
b7ae168e
...
...
@@ -5,7 +5,9 @@ import static org.mockito.Mockito.when;
import
com.altimetrik.ee.demo.bean.Stocks
;
import
com.altimetrik.ee.demo.controller.StocksController
;
import
com.altimetrik.ee.demo.service.StocksService
;
import
java.sql.Timestamp
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Date
;
...
...
@@ -34,16 +36,20 @@ public class StocksControllerTest {
@Test
public
void
getStocksByName
()
throws
Exception
{
String
s
Date1
=
"31/12/1998
"
;
Date
date1
=
new
SimpleDateFormat
(
"dd/MM/yyyy"
).
parse
(
sDate1
);
String
s
tr
=
"2018-09-01 09:01:15
"
;
Timestamp
timestamp
=
Timestamp
.
valueOf
(
str
);
List
<
Stocks
>
stocksList
=
Arrays
.
asList
(
new
Stocks
(
"HCL"
,
"HCL Tech"
,
date1
,
420.0
,
"INR"
),
new
Stocks
(
"IBM"
,
"IBM Tech"
,
date1
,
520.0
,
"USD"
),
new
Stocks
(
"UPY"
,
"UPY Tech"
,
date1
,
520.0
,
"JPY"
)
new
Stocks
(
"HCL"
,
"HCL Tech"
,
timestamp
,
420.0
,
"INR"
),
new
Stocks
(
"IBM"
,
"IBM Tech"
,
timestamp
,
520.0
,
"USD"
),
new
Stocks
(
"UPY"
,
"UPY Tech"
,
timestamp
,
520.0
,
"JPY"
)
);
when
(
stocksService
.
getStocksByIds
(
any
())).
thenReturn
(
stocksList
);
List
<
String
>
queries
=
new
ArrayList
<>();
queries
.
add
(
"HCL"
);
queries
.
add
(
"IBM"
);
when
(
stocksService
.
getStocksByIds
(
queries
)).
thenReturn
(
stocksList
);
mockMvc
.
perform
(
MockMvcRequestBuilders
.
get
(
"/stocks/stockQuote?symbols=HCL,IBM"
))
...
...
@@ -52,10 +58,10 @@ public class StocksControllerTest {
}
String
JSON_STRING
=
"[{\"stockQuote\":\"HCL\",\"companyName\":\"HCL Tech\","
+
"\"date\":\"
1998-12-30T18:30:00
.000+0000\",\"price\":420.0,\"currency\":\"INR\"},"
+
"{\"stockQuote\":\"IBM\",\"companyName\":\"IBM Tech\",\"date\":\"
1998-12-30T18:30:00
.000+0000\","
+
"\"date\":\"
2018-09-01T03:31:15
.000+0000\",\"price\":420.0,\"currency\":\"INR\"},"
+
"{\"stockQuote\":\"IBM\",\"companyName\":\"IBM Tech\",\"date\":\"
2018-09-01T03:31:15
.000+0000\","
+
"\"price\":520.0,\"currency\":\"USD\"},{\"stockQuote\":\"UPY\",\"companyName\":\"UPY Tech\","
+
"\"date\":\"
1998-12-30T18:30:00
.000+0000\",\"price\":520.0,\"currency\":\"JPY\"}]"
;
+
"\"date\":\"
2018-09-01T03:31:15
.000+0000\",\"price\":520.0,\"currency\":\"JPY\"}]"
;
@Test
public
void
WhenNoParameterIsPassed
()
throws
Exception
{
...
...
src/test/java/com/altimetrik/ee/demo/tests/StocksRepositoryTest.java
View file @
b7ae168e
...
...
@@ -4,6 +4,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import
com.altimetrik.ee.demo.bean.Stocks
;
import
com.altimetrik.ee.demo.repository.StocksRepository
;
import
java.sql.Timestamp
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
...
...
@@ -24,20 +25,20 @@ public class StocksRepositoryTest {
private
StocksRepository
stocksRepository
;
@Test
public
void
shouldCreateNewStock
()
throws
ParseException
{
String
s
Date1
=
"31/12/1998
"
;
Date
date1
=
new
SimpleDateFormat
(
"dd/MM/yyyy"
).
parse
(
sDate1
);
Stocks
s1
=
new
Stocks
(
"HCL-1"
,
"HCL"
,
date1
,
420.0
,
"INR"
);
String
s
tr
=
"2018-09-01 09:01:15
"
;
Timestamp
timestamp
=
Timestamp
.
valueOf
(
str
);
Stocks
s1
=
new
Stocks
(
"HCL-1"
,
"HCL"
,
timestamp
,
420.0
,
"INR"
);
stocksRepository
.
save
(
s1
);
}
@Test
public
void
shouldGetStocksByName
()
throws
ParseException
{
String
s
Date1
=
"31/12/1998
"
;
Date
date1
=
new
SimpleDateFormat
(
"dd/MM/yyyy"
).
parse
(
sDate1
);
Stocks
s1
=
new
Stocks
(
"HCL-1"
,
"HCL"
,
date1
,
420.0
,
"INR"
);
Stocks
s2
=
new
Stocks
(
"HCL-2"
,
"HCL"
,
date1
,
520.0
,
"USD"
);
Stocks
s3
=
new
Stocks
(
"HCL-3"
,
"HCL"
,
date1
,
620.0
,
"JNY"
);
Stocks
s4
=
new
Stocks
(
"HCL-4"
,
"HCL"
,
date1
,
720.0
,
"INR"
);
String
s
tr
=
"2018-09-01 09:01:15
"
;
Timestamp
timestamp
=
Timestamp
.
valueOf
(
str
);
Stocks
s1
=
new
Stocks
(
"HCL-1"
,
"HCL"
,
timestamp
,
420.0
,
"INR"
);
Stocks
s2
=
new
Stocks
(
"HCL-2"
,
"HCL"
,
timestamp
,
520.0
,
"USD"
);
Stocks
s3
=
new
Stocks
(
"HCL-3"
,
"HCL"
,
timestamp
,
620.0
,
"JNY"
);
Stocks
s4
=
new
Stocks
(
"HCL-4"
,
"HCL"
,
timestamp
,
720.0
,
"INR"
);
List
<
Stocks
>
list
=
new
ArrayList
<>();
list
.
add
(
s1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment