Search in sources :

Example 1 with Tag

use of org.sagebionetworks.bridge.models.Tag in project BridgeServer2 by Sage-Bionetworks.

the class TagControllerTest method addTag.

@Test
public void addTag() throws Exception {
    doReturn(session).when(controller).getAuthenticatedSession(SUPERADMIN);
    mockRequestBody(mockRequest, new Tag("tagValue"));
    controller.addTag();
    verify(mockService).addTag("tagValue");
}
Also used : Tag(org.sagebionetworks.bridge.models.Tag) Test(org.testng.annotations.Test)

Example 2 with Tag

use of org.sagebionetworks.bridge.models.Tag in project BridgeServer2 by Sage-Bionetworks.

the class TagEventListenerTest method onDeleteWithTransientEntities.

@Test
public void onDeleteWithTransientEntities() throws HibernateException {
    DeleteEvent event = new DeleteEvent(new Tag("value"), null);
    listener.onDelete(event, null);
    verify(cacheProvider).removeObject(CacheKey.tagList());
}
Also used : DeleteEvent(org.hibernate.event.spi.DeleteEvent) Tag(org.sagebionetworks.bridge.models.Tag) Test(org.testng.annotations.Test)

Example 3 with Tag

use of org.sagebionetworks.bridge.models.Tag in project BridgeServer2 by Sage-Bionetworks.

the class TagEventListenerTest method onPersist.

@Test
public void onPersist() throws HibernateException {
    PersistEvent event = new PersistEvent(new Tag("value"), null);
    listener.onPersist(event);
    verify(cacheProvider).removeObject(CacheKey.tagList());
}
Also used : PersistEvent(org.hibernate.event.spi.PersistEvent) Tag(org.sagebionetworks.bridge.models.Tag) Test(org.testng.annotations.Test)

Example 4 with Tag

use of org.sagebionetworks.bridge.models.Tag in project BridgeServer2 by Sage-Bionetworks.

the class TagEventListenerTest method onMergeWithCopiedAlready.

@Test
public void onMergeWithCopiedAlready() throws HibernateException {
    MergeEvent event = new MergeEvent(new Tag("value"), null);
    event.setEntity(new Tag("value"));
    listener.onMerge(event, null);
    verify(cacheProvider).removeObject(CacheKey.tagList());
}
Also used : MergeEvent(org.hibernate.event.spi.MergeEvent) Tag(org.sagebionetworks.bridge.models.Tag) Test(org.testng.annotations.Test)

Example 5 with Tag

use of org.sagebionetworks.bridge.models.Tag in project BridgeServer2 by Sage-Bionetworks.

the class TagController method addTag.

@PostMapping("/v1/tags")
@ResponseStatus(HttpStatus.CREATED)
public StatusMessage addTag() {
    getAuthenticatedSession(SUPERADMIN);
    Tag tag = parseJson(Tag.class);
    // This method is provided so Sage admins can seed the tags we wish to use
    tagService.addTag(tag.getValue());
    return new StatusMessage("Tag created if not already present.");
}
Also used : Tag(org.sagebionetworks.bridge.models.Tag) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Aggregations

Tag (org.sagebionetworks.bridge.models.Tag)13 Test (org.testng.annotations.Test)9 DeleteEvent (org.hibernate.event.spi.DeleteEvent)2 MergeEvent (org.hibernate.event.spi.MergeEvent)2 PersistEvent (org.hibernate.event.spi.PersistEvent)2 ImmutableList (com.google.common.collect.ImmutableList)1 List (java.util.List)1 SaveOrUpdateEvent (org.hibernate.event.spi.SaveOrUpdateEvent)1 StatusMessage (org.sagebionetworks.bridge.models.StatusMessage)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1