Changeset 617

Show
Ignore:
Timestamp:
03-04-12 14:24:31 (2 years ago)
Author:
freek.de.bruijn@…
Message:

Removed static imports of Mockito.doThrow and Mockito.when.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/code/conceptwiki/service/service-impl/src/test/java/nl/nbic/conceptwiki/service/ConceptServiceImplUnitTest.java

    r616 r617  
    77import static org.junit.Assert.assertNull; 
    88import static org.junit.Assert.assertTrue; 
    9 import static org.mockito.Mockito.doThrow; 
    10 import static org.mockito.Mockito.when; 
    119 
    1210import com.google.common.collect.Iterables; 
     
    137135        // setup 
    138136        final List<SearchResult> searchResults = Arrays.asList((SearchResult) new SearchResultImpl("malaria", "1234")); 
    139         when(mockSearchService.searchConcepts(Mockito.anyString(), Mockito.anyInt(), 
     137        Mockito.when(mockSearchService.searchConcepts(Mockito.anyString(), Mockito.anyInt(), 
    140138                        Mockito.anyInt())).thenReturn(searchResults); 
    141139 
     
    158156        final List<SearchResult> searchResults = new ArrayList<SearchResult>(); 
    159157        searchResults.add(new SearchResultImpl("malaria", uuid)); 
    160         when(mockSearchService.searchConcepts(Mockito.anyString(), Mockito.anyInt(), 
     158        Mockito.when(mockSearchService.searchConcepts(Mockito.anyString(), Mockito.anyInt(), 
    161159                        Mockito.anyInt())).thenReturn(searchResults); 
    162160        // ... 
    163161        final ImmutableSet<Label> testLabels = ImmutableSet.of(PREF_LABEL_A); 
    164         when(mockStorageService.getConcept(uuid)).thenReturn(new ConceptImpl.Builder().labels(testLabels).build()); 
     162        Mockito.when(mockStorageService.getConcept(uuid)).thenReturn(new ConceptImpl.Builder().labels(testLabels).build()); 
    165163 
    166164        // exercise 
     
    182180        final List<SearchResult> searchResults = Arrays.asList((SearchResult) new SearchResultImpl("malaria", "1234"), 
    183181                (SearchResult) new SearchResultImpl("malaria mosquito", "789abc")); 
    184         when(mockSearchService.searchConcepts(Mockito.anyString(), Mockito.anyInt(), 
     182        Mockito.when(mockSearchService.searchConcepts(Mockito.anyString(), Mockito.anyInt(), 
    185183                        Mockito.anyInt())).thenReturn(searchResults); 
    186184 
     
    223221        // setup 
    224222        final List<Concept> searchResults = Arrays.asList((Concept) new ConceptImpl.Builder().build()); 
    225         when(mockStorageService.getConceptsByLabel(Mockito.anyString(), Mockito.eq(QueryScopeImpl.LITE_SCOPE), 
     223        Mockito.when(mockStorageService.getConceptsByLabel(Mockito.anyString(), Mockito.eq(QueryScopeImpl.LITE_SCOPE), 
    226224                        Mockito.anyInt(), Mockito.eq(DEFAULT_LANGUAGE))).thenReturn(searchResults); 
    227225 
     
    246244        final Concept concept = new ConceptImpl.Builder().labels(Sets.newHashSet(label)).build(); 
    247245        final Concept mockedResult = new ConceptImpl.Builder().labels(Sets.newHashSet(label)).uuid(UUID.randomUUID().toString()).build(); 
    248         when(mockStorageService.createConcept(Mockito.any(Concept.class), Mockito.anyInt())).thenReturn(mockedResult); 
     246        Mockito.when(mockStorageService.createConcept(Mockito.any(Concept.class), Mockito.anyInt())).thenReturn(mockedResult); 
    249247 
    250248        // exercise 
     
    262260        final Label label = new LabelImpl(LabelType.PREFERRED, DEFAULT_LABEL, DEFAULT_LANGUAGE); 
    263261        final Concept concept = new ConceptImpl.Builder().labels(Sets.newHashSet(label)).build(); 
    264         when(mockStorageService.createConcept(Mockito.any(Concept.class), Mockito.anyInt())).thenThrow(new RuntimeException()); 
     262        Mockito.when(mockStorageService.createConcept(Mockito.any(Concept.class), Mockito.anyInt())).thenThrow(new RuntimeException()); 
    265263 
    266264        // exercise 
     
    272270        final Label label = new LabelImpl(LabelType.PREFERRED, DEFAULT_LABEL, DEFAULT_LANGUAGE); 
    273271        final Concept concept = new ConceptImpl.Builder().labels(Sets.newHashSet(label)).build(); 
    274         doThrow(new RuntimeException()).when(mockHistoryService).storeRevision(Mockito.anyString(), Mockito.any(Changeset.class)); 
     272        Mockito.doThrow(new RuntimeException()).when(mockHistoryService).storeRevision(Mockito.anyString(), Mockito.any(Changeset.class)); 
    275273 
    276274        // exercise 
     
    282280        final Label label = new LabelImpl(LabelType.PREFERRED, DEFAULT_LABEL, DEFAULT_LANGUAGE); 
    283281        final Concept concept = new ConceptImpl.Builder().labels(Sets.newHashSet(label)).build(); 
    284         doThrow(new RuntimeException()).when(mockSearchService).indexConcept(Mockito.any(Concept.class)); 
     282        Mockito.doThrow(new RuntimeException()).when(mockSearchService).indexConcept(Mockito.any(Concept.class)); 
    285283 
    286284        // exercise 
     
    295293    @Test 
    296294    public void testDeleteConcept() { 
    297         when(mockStorageService.isExistingConcept(Mockito.anyString())).thenReturn(true); 
     295        Mockito.when(mockStorageService.isExistingConcept(Mockito.anyString())).thenReturn(true); 
    298296        final String uuid = UUID.randomUUID().toString(); 
    299297 
     
    306304    @Test(expected = IllegalArgumentException.class) 
    307305    public void testDeleteNonExistantConcept() { 
    308         when(mockStorageService.isExistingConcept(Mockito.anyString())).thenReturn(false); 
     306        Mockito.when(mockStorageService.isExistingConcept(Mockito.anyString())).thenReturn(false); 
    309307        final String uuid = UUID.randomUUID().toString(); 
    310308 
     
    320318    public void testGetNonExistingConcept() { 
    321319        final String uuid = UUID.randomUUID().toString(); 
    322         when(mockStorageService.getConcept(uuid, DEFAULT_BRANCH)).thenReturn(null); 
     320        Mockito.when(mockStorageService.getConcept(uuid, DEFAULT_BRANCH)).thenReturn(null); 
    323321        final Concept result = conceptService.getConcept(uuid, DEFAULT_BRANCH); 
    324322 
     
    331329        final Label label = new LabelImpl(LabelType.PREFERRED, DEFAULT_LABEL, DEFAULT_LANGUAGE); 
    332330        final Concept concept = new ConceptImpl.Builder().labels(Sets.newHashSet(label)).uuid(uuid).build(); 
    333         when(mockStorageService.getConcept(uuid, DEFAULT_BRANCH)).thenReturn(concept); 
     331        Mockito.when(mockStorageService.getConcept(uuid, DEFAULT_BRANCH)).thenReturn(concept); 
    334332 
    335333        final Concept result = conceptService.getConcept(uuid, DEFAULT_BRANCH); 
     
    352350        final Concept concept = new ConceptImpl.Builder().labels(Sets.newHashSet(label)).uuid(uuid).build(); 
    353351 
    354         when(mockStorageService.getConcept(uuid, DEFAULT_BRANCH)).thenReturn(concept); 
     352        Mockito.when(mockStorageService.getConcept(uuid, DEFAULT_BRANCH)).thenReturn(concept); 
    355353 
    356354        conceptService.updateConcept(uuid, changeset, DEFAULT_BRANCH);