Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beamline
Framework
Commits
7b26f183
Commit
7b26f183
authored
3 years ago
by
Andrea Burattin
Browse files
Options
Downloads
Patches
Plain Diff
Missing actual tests
parent
7b4af2e2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/beamline/tests/EventTest.java
+104
-0
104 additions, 0 deletions
src/test/java/beamline/tests/EventTest.java
with
104 additions
and
0 deletions
src/test/java/beamline/tests/EventTest.java
0 → 100644
+
104
−
0
View file @
7b26f183
package
beamline.tests
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertThrows
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
java.util.Date
;
import
java.util.Set
;
import
java.util.UUID
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.deckfour.xes.model.impl.XAttributeBooleanImpl
;
import
org.deckfour.xes.model.impl.XAttributeContinuousImpl
;
import
org.deckfour.xes.model.impl.XAttributeDiscreteImpl
;
import
org.deckfour.xes.model.impl.XAttributeLiteralImpl
;
import
org.deckfour.xes.model.impl.XAttributeTimestampImpl
;
import
org.junit.jupiter.api.Test
;
import
beamline.events.BEvent
;
import
beamline.exceptions.EventException
;
public
class
EventTest
{
String
processName
=
UUID
.
randomUUID
().
toString
();
String
traceName
=
UUID
.
randomUUID
().
toString
();
String
eventName
=
UUID
.
randomUUID
().
toString
();
Date
eventDate
=
new
Date
();
@Test
public
void
event_creation
()
throws
EventException
{
assertThrows
(
EventException
.
class
,
()
->
BEvent
.
create
(
""
,
""
,
null
));
assertThrows
(
EventException
.
class
,
()
->
BEvent
.
create
(
""
,
null
,
""
));
assertThrows
(
EventException
.
class
,
()
->
BEvent
.
create
(
null
,
""
,
""
));
BEvent
e
=
BEvent
.
create
(
processName
,
traceName
,
eventName
,
eventDate
,
Set
.
of
(
Pair
.
of
(
"a1"
,
"v1"
)));
assertEquals
(
e
.
getEventAttributes
().
get
(
"a1"
),
"v1"
);
}
@Test
public
void
event_names
()
throws
EventException
{
BEvent
e
=
BEvent
.
create
(
processName
,
traceName
,
eventName
);
assertEquals
(
processName
,
e
.
getProcessName
());
assertEquals
(
traceName
,
e
.
getTraceName
());
assertEquals
(
eventName
,
e
.
getEventName
());
Date
eventDate
=
new
Date
();
BEvent
e2
=
BEvent
.
create
(
processName
,
traceName
,
eventName
,
eventDate
);
assertEquals
(
eventDate
,
e2
.
getEventTime
());
}
@Test
public
void
test_equals
()
throws
EventException
{
BEvent
e
=
BEvent
.
create
(
processName
,
traceName
,
eventName
);
e
.
setTimestamp
(
null
);
BEvent
e2
=
BEvent
.
create
(
processName
,
traceName
,
eventName
,
eventDate
);
BEvent
e3
=
BEvent
.
create
(
processName
,
traceName
,
eventName
,
eventDate
);
assertEquals
(
e2
,
e3
);
assertThat
(
e2
).
hasSameHashCodeAs
(
e3
);
assertEquals
(
0
,
e2
.
compareTo
(
e3
));
assertEquals
(
0
,
e
.
compareTo
(
e3
));
assertThat
(
e
).
isEqualTo
(
e
).
isNotEqualTo
(
null
).
isNotEqualTo
(
eventDate
);
}
@Test
public
void
event_attributes
()
throws
EventException
{
BEvent
e
=
BEvent
.
create
(
processName
,
traceName
,
eventName
);
e
.
setProcessAttribute
(
"pa"
,
"v1"
);
e
.
setTraceAttribute
(
"ta"
,
"v2"
);
e
.
setEventAttribute
(
"ea"
,
"v3"
);
assertEquals
(
"v1"
,
e
.
getProcessAttributes
().
get
(
"pa"
));
assertEquals
(
"v2"
,
e
.
getTraceAttributes
().
get
(
"ta"
));
assertEquals
(
"v3"
,
e
.
getEventAttributes
().
get
(
"ea"
));
}
@Test
public
void
event_attributes_xattributable
()
throws
EventException
{
Date
date
=
new
Date
();
BEvent
e
=
BEvent
.
create
(
processName
,
traceName
,
eventName
);
e
.
setProcessAttribute
(
"pa"
,
new
XAttributeLiteralImpl
(
"pa"
,
"v1"
));
e
.
setTraceAttribute
(
"ta"
,
new
XAttributeBooleanImpl
(
"ta"
,
false
));
e
.
setEventAttribute
(
"ea"
,
new
XAttributeDiscreteImpl
(
"ea"
,
42
));
e
.
setEventAttribute
(
"ea2"
,
new
XAttributeContinuousImpl
(
"ea2"
,
3.14
));
e
.
setEventAttribute
(
"ea3"
,
new
XAttributeTimestampImpl
(
"ea3"
,
date
));
assertEquals
(
e
.
getProcessAttributes
().
get
(
"pa"
),
"v1"
);
assertEquals
(
e
.
getTraceAttributes
().
get
(
"ta"
),
false
);
assertEquals
(
e
.
getEventAttributes
().
get
(
"ea"
),
42
l
);
assertEquals
(
e
.
getEventAttributes
().
get
(
"ea2"
),
3.14
);
assertEquals
(
e
.
getEventAttributes
().
get
(
"ea3"
),
date
);
}
@Test
public
void
event_to_string
()
throws
EventException
{
BEvent
e
=
BEvent
.
create
(
processName
,
traceName
,
eventName
,
eventDate
);
assertEquals
(
"{concept:name="
+
processName
+
"} - "
+
"{concept:name="
+
traceName
+
"} - "
+
"{concept:name="
+
eventName
+
", time:timestamp="
+
eventDate
.
toString
()
+
"}"
,
e
.
toString
());
}
}
This diff is collapsed.
Click to expand it.
andbur
@andbur
mentioned in commit
4e079533
·
2 years ago
mentioned in commit
4e079533
mentioned in commit 4e079533bf8667b212ef40a052709172b7bf9ed0
Toggle commit list
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