Changeset 631


Ignore:
Timestamp:
Apr 13, 2012, 2:56:41 PM (5 years ago)
Author:
david.vanenckevort@…
Message:
  • Added tests for addUrls().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/code/conceptwiki/storage/storage-api/src/test/java/nl/nbic/conceptwiki/storage/api/AbstractConceptStorageServiceUnitTest.java

    r544 r631  
    1616import nl.nbic.conceptwiki.common.impl.ConceptImpl;
    1717import nl.nbic.conceptwiki.common.impl.LabelImpl;
    18 import nl.nbic.conceptwiki.common.impl.LanguageImpl;
    19 import nl.nbic.conceptwiki.common.impl.QueryScopeImpl;
    2018import static nl.nbic.conceptwiki.common.util.CommonTestObjects.ALT_LABEL_A;
    2119import static nl.nbic.conceptwiki.common.util.CommonTestObjects.ALT_LABEL_B;
     
    4442import static org.junit.Assert.assertNull;
    4543import static org.junit.Assert.assertTrue;
     44
     45import java.util.UUID;
     46import nl.nbic.conceptwiki.common.api.Url;
     47import nl.nbic.conceptwiki.common.api.Url.UrlType;
     48import nl.nbic.conceptwiki.common.impl.UrlImpl;
    4649import org.junit.Ignore;
    4750import org.junit.Test;
     
    614617        assertEquals(newTags, tags);
    615618    }
    616 
     619   
     620    @Test
     621    public void testAddUrlsToExistingConcept() {
     622        final Concept concept = conceptStorageService.createConcept(CONCEPT_A, TEST_BRANCH_A_ID);
     623        final Url url = new UrlImpl(UrlType.PREFERRED, "http://www.conceptwiki.org/");
     624        final Set<Url> urls = conceptStorageService.addUrls(concept.getUuid(), ImmutableSet.of(url), TEST_BRANCH_A_ID);
     625        assertNotNull(urls);
     626        assertFalse(urls.isEmpty());
     627        assertTrue(urls.contains(url));
     628    }
     629
     630    @Test
     631    @Ignore("Can this work with the concept and the URLs all created in one transaction - is the index used updated in time?")
     632    public void testAddAdditionalUrlsToConcept() {
     633        final Concept concept = conceptStorageService.createConcept(CONCEPT_A, TEST_BRANCH_A_ID);
     634        final Url url = new UrlImpl(UrlType.PREFERRED, "http://www.conceptwiki.org/");
     635        final Set<Url> urls = conceptStorageService.addUrls(concept.getUuid(), ImmutableSet.of(url), TEST_BRANCH_A_ID);
     636        assertNotNull(urls);
     637        assertFalse(urls.isEmpty());
     638        assertTrue(urls.contains(url));
     639       
     640        final Url additionalUrl = new UrlImpl(UrlType.ALTERNATIVE, "http://cwaapp1.leidenuniv.nl/");
     641        final Set<Url> newUrls = conceptStorageService.addUrls(concept.getUuid(), ImmutableSet.of(url, additionalUrl), TEST_BRANCH_A_ID);
     642        assertNotNull(newUrls);
     643        assertFalse(newUrls.isEmpty());
     644        assertFalse(newUrls.contains(url));
     645        assertTrue(newUrls.contains(additionalUrl));
     646    }
     647
     648    @Test
     649    public void testAddUrlsToNonexistentConcept() {
     650        final Url url = new UrlImpl(UrlType.PREFERRED, "http://www.conceptwiki.org/");
     651        final Set<Url> urls = conceptStorageService.addUrls(UUID.randomUUID().toString(), ImmutableSet.of(url), TEST_BRANCH_A_ID);
     652        assertNotNull(urls);
     653        assertTrue(urls.isEmpty());
     654    }
     655   
     656    @Test(expected = ConstraintViolationException.class)
     657    public void testAddUrlsToNullUuid() {
     658        final Url url = new UrlImpl(UrlType.PREFERRED, "http://www.conceptwiki.org/");
     659        conceptStorageService.addUrls(null, ImmutableSet.of(url), TEST_BRANCH_A_ID);
     660    }
     661
     662    @Test
     663    public void testRemoveUrlFromConcept() {
     664       
     665    }
     666   
    617667    @Test
    618668    public void testGetConceptWithTwoBranches() {
Note: See TracChangeset for help on using the changeset viewer.