Skip to content
Snippets Groups Projects
Commit 7ae271f5 authored by Carsten Karbach's avatar Carsten Karbach
Browse files

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
...@@ -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": "2017-11-06T10:22:24+00:00" "time": "2018-01-15T15:34:22+00:00"
}, },
{ {
"name": "phpmailer/phpmailer", "name": "phpmailer/phpmailer",
......
https://<hostname>/<path to events>
\ No newline at end of file
{ {
"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"
} }
} }
} }
......
...@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment