-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be3d1c3
commit a6ac1c1
Showing
2 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
test/functional/be/cytomine/AnnotationDomainTests.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package be.cytomine | ||
|
||
/* | ||
* Copyright (c) 2009-2019. Authors: see NOTICE file. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import be.cytomine.image.ImageInstance | ||
import be.cytomine.ontology.AlgoAnnotation | ||
import be.cytomine.ontology.UserAnnotation | ||
import be.cytomine.project.Project | ||
import be.cytomine.test.BasicInstanceBuilder | ||
import be.cytomine.test.Infos | ||
import be.cytomine.test.http.AnnotationDomainAPI | ||
import grails.converters.JSON | ||
import org.codehaus.groovy.grails.web.json.JSONObject | ||
|
||
|
||
class AnnotationDomainTests { | ||
|
||
void testSearchAnnotationFromUserAndJob() { | ||
Project project = BasicInstanceBuilder.getProjectNotExist(true) | ||
ImageInstance image = BasicInstanceBuilder.getImageInstanceNotExist(project, true) | ||
UserAnnotation userAnnotation = BasicInstanceBuilder.getUserAnnotationNotExist(project, image, true) | ||
AlgoAnnotation algoAnnotation = BasicInstanceBuilder.getAlgoAnnotationNotExist(image, true) | ||
ArrayList<Long> users = new ArrayList<>(); | ||
users.add(userAnnotation.user.id) | ||
users.add(algoAnnotation.user.id) | ||
|
||
def result = AnnotationDomainAPI.listByImageAndUsers(image.id,users,false, Infos.SUPERADMINLOGIN,Infos.SUPERADMINPASSWORD) | ||
assert 200 == result.code | ||
def json = JSON.parse(result.data) | ||
assert json instanceof JSONObject | ||
|
||
assert json.collection.size() == 1 | ||
|
||
result = AnnotationDomainAPI.listByImageAndUsers(image.id,users,true, Infos.SUPERADMINLOGIN,Infos.SUPERADMINPASSWORD) | ||
assert 200 == result.code | ||
json = JSON.parse(result.data) | ||
assert json instanceof JSONObject | ||
|
||
//TODO : includeAlgo remove the parameter users in the RestAnnotationDomainController ==> change that | ||
assert json.collection.size() == 1 | ||
|
||
users = users.reverse() | ||
result = AnnotationDomainAPI.listByImageAndUsers(image.id,users,true, Infos.SUPERADMINLOGIN,Infos.SUPERADMINPASSWORD) | ||
assert 200 == result.code | ||
json = JSON.parse(result.data) | ||
assert json instanceof JSONObject | ||
|
||
//TODO : includeAlgo remove the parameter users in the RestAnnotationDomainController ==> change that | ||
assert json.collection.size() == 1 | ||
} | ||
|
||
void testSearchAnnotationFromUsers() { | ||
Project project = BasicInstanceBuilder.getProjectNotExist(true) | ||
ImageInstance image = BasicInstanceBuilder.getImageInstanceNotExist(project, true) | ||
UserAnnotation userAnnotation = BasicInstanceBuilder.getUserAnnotationNotExist(project, image, true) | ||
UserAnnotation userAnnotation2 = BasicInstanceBuilder.getUserAnnotationNotExist(project, image, true) | ||
ArrayList<Long> users = new ArrayList<>(); | ||
users.add(userAnnotation.user.id) | ||
users.add(userAnnotation2.user.id) | ||
|
||
def result = AnnotationDomainAPI.listByImageAndUsers(image.id,users,false, Infos.SUPERADMINLOGIN,Infos.SUPERADMINPASSWORD) | ||
assert 200 == result.code | ||
def json = JSON.parse(result.data) | ||
assert json instanceof JSONObject | ||
|
||
assert json.collection.size() == 2 | ||
|
||
result = AnnotationDomainAPI.listByImageAndUsers(image.id,users,true, Infos.SUPERADMINLOGIN,Infos.SUPERADMINPASSWORD) | ||
assert 200 == result.code | ||
json = JSON.parse(result.data) | ||
assert json instanceof JSONObject | ||
|
||
//TODO : includeAlgo remove the parameter users in the RestAnnotationDomainController ==> change that | ||
assert json.collection.size() == 0 | ||
} | ||
|
||
void testSearchAnnotationFromJobs() { | ||
Project project = BasicInstanceBuilder.getProjectNotExist(true) | ||
ImageInstance image = BasicInstanceBuilder.getImageInstanceNotExist(project, true) | ||
AlgoAnnotation algoAnnotation = BasicInstanceBuilder.getAlgoAnnotationNotExist(image, true) | ||
AlgoAnnotation algoAnnotation2 = BasicInstanceBuilder.getAlgoAnnotationNotExist(image, true) | ||
ArrayList<Long> users = new ArrayList<>(); | ||
users.add(algoAnnotation.user.id) | ||
users.add(algoAnnotation2.user.id) | ||
|
||
def result = AnnotationDomainAPI.listByImageAndUsers(image.id,users,false, Infos.SUPERADMINLOGIN,Infos.SUPERADMINPASSWORD) | ||
assert 200 == result.code | ||
def json = JSON.parse(result.data) | ||
assert json instanceof JSONObject | ||
|
||
//TODO : currently if only algo, we infer automatically the research. Do we want to keep this ? | ||
assert json.collection.size() == 2 | ||
|
||
result = AnnotationDomainAPI.listByImageAndUsers(image.id,users,true, Infos.SUPERADMINLOGIN,Infos.SUPERADMINPASSWORD) | ||
assert 200 == result.code | ||
json = JSON.parse(result.data) | ||
assert json instanceof JSONObject | ||
|
||
assert json.collection.size() == 2 | ||
} | ||
|
||
|
||
} |