Package de.panikco.pmdb.service

Source Code of de.panikco.pmdb.service.MediaServiceTest

package de.panikco.pmdb.service;

import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import de.panikco.pmdb.model.Media;
import de.panikco.pmdb.repos.MediaRepository;

import static org.junit.Assert.assertEquals;

import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;

public class MediaServiceTest {

  @InjectMocks
  MediaService ms = new MediaServiceImpl();
 
  @Mock
  MediaRepository repository;
 
  @Before
  public void init() {
    MockitoAnnotations.initMocks(this);
  }
 
  @Test
  public void addMediaTest() {
   
    List <Media> media = new ArrayList<Media>();
    Media aMedium = new Media();
    aMedium.setTitle("Herr der Ringe");
    media.add(aMedium);
   
    when(repository.findAll()).thenReturn(media);
   
    List<Media> result = ms.getAllMedia();
   
    verify(repository).findAll();
    verifyNoMoreInteractions(repository);
   
    assertEquals(media, result);

  }

}
TOP

Related Classes of de.panikco.pmdb.service.MediaServiceTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.