Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EventsAPI
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
Container registry
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jards
EventsAPI
Commits
7ae271f5
Commit
7ae271f5
authored
7 years ago
by
Carsten Karbach
Browse files
Options
Downloads
Patches
Plain Diff
Update to new client version, add test to send event and delete the
generated .obj file
parent
3314a017
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
composer.lock
+3
-3
3 additions, 3 deletions
composer.lock
configs/myurl.cnf
+1
-0
1 addition, 0 deletions
configs/myurl.cnf
rest/events/events_api.json
+55
-1
55 additions, 1 deletion
rest/events/events_api.json
tests/EventManagementTest.php
+49
-0
49 additions, 0 deletions
tests/EventManagementTest.php
with
108 additions
and
4 deletions
composer.lock
+
3
−
3
View file @
7ae271f5
...
@@ -8,11 +8,11 @@
...
@@ -8,11 +8,11 @@
"packages": [
"packages": [
{
{
"name": "jards/eventsapiclient",
"name": "jards/eventsapiclient",
"version": "v2.
2
",
"version": "v2.
4
",
"source": {
"source": {
"type": "git",
"type": "git",
"url": "https://gitlab.version.fz-juelich.de/jards/EventsAPIClient.git",
"url": "https://gitlab.version.fz-juelich.de/jards/EventsAPIClient.git",
"reference": "
69d8a58854ea6a7cd822a568ba3b6aab70719f7d
"
"reference": "
b36657b4f7bdf30e8f4f9c0ecf1d77af1a6bc085
"
},
},
"require": {
"require": {
"ext-curl": "*",
"ext-curl": "*",
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
"sdk",
"sdk",
"swagger"
"swagger"
],
],
"time": "201
7-11-06T10:22
:2
4
+00:00"
"time": "201
8-01-15T15:34
:2
2
+00:00"
},
},
{
{
"name": "phpmailer/phpmailer",
"name": "phpmailer/phpmailer",
...
...
This diff is collapsed.
Click to expand it.
configs/myurl.cnf
0 → 100644
+
1
−
0
View file @
7ae271f5
https://<hostname>/<path to events>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
rest/events/events_api.json
+
55
−
1
View file @
7ae271f5
{
{
"swagger"
:
"2.0"
,
"swagger"
:
"2.0"
,
"info"
:
{
"info"
:
{
"version"
:
"0.
0.
1"
,
"version"
:
"0.1"
,
"title"
:
"Event receiver service. Send any events, which should be handled by this service."
"title"
:
"Event receiver service. Send any events, which should be handled by this service."
},
},
"consumes"
:
[
"consumes"
:
[
...
@@ -76,17 +76,71 @@
...
@@ -76,17 +76,71 @@
],
],
"properties"
:
{
"properties"
:
{
"date"
:
{
"date"
:
{
"description"
:
"Date when the event happened."
,
"type"
:
"string"
,
"type"
:
"string"
,
"format"
:
"date-time"
"format"
:
"date-time"
},
},
"name"
:
{
"name"
:
{
"description"
:
"Name of the event"
,
"type"
:
"string"
"type"
:
"string"
},
},
"description"
:
{
"description"
:
{
"description"
:
"Detailled description on what happened during this event"
,
"type"
:
"string"
"type"
:
"string"
},
},
"id"
:{
"id"
:{
"description"
:
"Internal event ID, differs for every EventsAPI instance"
,
"type"
:
"integer"
"type"
:
"integer"
},
"source"
:
{
"description"
:
"Who has triggered the event?"
,
"type"
:
"string"
},
"newState"
:
{
"description"
:
"The new state for the project or application caused by the event"
,
"type"
:
"string"
},
"triggerType"
:
{
"description"
:
"Name of the trigger which is activated by this event"
,
"type"
:
"string"
},
"project"
:
{
"$ref"
:
"#/definitions/Project"
},
"application"
:
{
"$ref"
:
"#/definitions/Application"
}
}
},
"Project"
:
{
"type"
:
"object"
,
"required"
:
[
"id"
],
"properties"
:
{
"id"
:
{
"description"
:
"Project ID"
,
"type"
:
"string"
},
"type"
:
{
"description"
:
"Project type such as regular, gcs, test, large-scale"
,
"type"
:
"string"
}
}
},
"Application"
:
{
"type"
:
"object"
,
"required"
:
[
"id"
],
"properties"
:
{
"id"
:
{
"description"
:
"Application / Proposal ID"
,
"type"
:
"integer"
},
"type"
:
{
"description"
:
"Proposal type such as extension or new"
,
"type"
:
"string"
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/EventManagementTest.php
+
49
−
0
View file @
7ae271f5
...
@@ -22,4 +22,53 @@ class EventManagementTest extends TestCase{
...
@@ -22,4 +22,53 @@ class EventManagementTest extends TestCase{
$this
->
assertTrue
(
is_array
(
$eventsArray
)
||
is_empty
(
$eventsArray
),
"Result of event management is not an array."
);
$this
->
assertTrue
(
is_array
(
$eventsArray
)
||
is_empty
(
$eventsArray
),
"Result of event management is not an array."
);
}
}
protected
function
getExistingEventIDs
(){
$eventManagement
=
new
EventManagement
();
$events
=
$eventManagement
->
getEvents
();
$content
=
$events
->
getContent
();
$eventsArray
=
json_decode
(
$content
);
$oldEventIDs
=
array
();
foreach
(
$eventsArray
as
$event
){
$id
=
$event
->
id
;
$oldEventIDs
[]
=
$id
;
}
sort
(
$oldEventIDs
);
return
$oldEventIDs
;
}
/**
* Send an event. Deletes all new created event objects
*/
public
function
testSendEvent
(){
echo
"testSendEvent
\n
"
;
$eventManagement
=
new
EventManagement
();
$oldEventIDs
=
$this
->
getExistingEventIDs
();
$url
=
file_get_contents
(
__DIR__
.
'/../configs/myurl.cnf'
);
$eventManagement
->
sendEvent
(
'test event'
,
'This is only a test'
,
$url
);
$newEventIDs
=
$this
->
getExistingEventIDs
();
$this
->
assertNotEquals
(
join
(
'|'
,
$oldEventIDs
),
join
(
'|'
,
$newEventIDs
),
"No event seems to be sent"
);
foreach
(
$newEventIDs
as
$newID
){
if
(
!
in_array
(
$newID
,
$oldEventIDs
)){
$toDelete
=
__DIR__
.
'/../data/'
.
$newID
.
'.obj'
;
unlink
(
$toDelete
);
}
}
$newEventIDs
=
$this
->
getExistingEventIDs
();
$this
->
assertEquals
(
join
(
'|'
,
$oldEventIDs
),
join
(
'|'
,
$newEventIDs
),
"Could not revert new created events"
);
}
}
}
\ No newline at end of file
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