Databases Reference
In-Depth Information
public
abstract
class
AbstractAnalyticsTest
extends
Assert
{
def
jedis
static
topologyStarted
=
false
static
sync
=
new
Object
()
private
void
reconnect
()
{
jedis
=
new
Jedis
(
TopologyStarter
.
REDIS_HOST
,
TopologyStarter
.
REDIS_PORT
)
}
@Before
public
void
startTopology
(){
synchronized
(
sync
){
reconnect
()
if
(!
topologyStarted
){
jedis
.
flushAll
()
populateProducts
()
TopologyStarter
.
testing
=
true
TopologyStarter
.
main
(
null
)
topologyStarted
=
true
sleep
1000
}
}
}
...
public
void
populateProducts
()
{
def
testProducts
=
[
[
id:
0
,
title:
"Dvd player with surround sound system"
,
category:
"Players"
,
price:
100
],
[
id:
1
,
title:
"Full HD Bluray and DVD player"
,
category:
"Players"
,
price:
130
],
[
id:
2
,
title:
"Media player with USB 2.0 input"
,
category:
"Players"
,
price:
70
],
...
[
id:
21
,
title:
"TV Wall mount bracket 50-55 Inches"
,
category:
"Mounts"
,
price:
80
]
]
testProducts
.
each
()
{
product
->
def
val
=
"{ \"title\": \"${product.title}\" , \"category\": \"${product.category}\","
+
" \"price\": ${product.price}, \"id\": ${product.id} }"
println
val
jedis
.
set
(
product
.
id
.
toString
(),
val
.
toString
())
}
}
...
}
Implement a method called navigate in the AbstractAnalyticsTest class.
In or-
der for the different tests to have a way to emulate the behavior of a user navigating the
website, this step inserts navigation entries in the Redis server navigation queue.
public
abstract
class
AbstractAnalyticsTest
extends
Assert
{
...