Project

General

Profile

1
package eu.dnetlib.parthenos.publisher;
2

    
3
import eu.dnetlib.parthenos.jrr.JRRPublisher;
4
import eu.dnetlib.parthenos.jrr.JRRPublisherHelper;
5
import org.junit.Test;
6
import org.junit.runner.RunWith;
7
import org.springframework.beans.factory.annotation.Autowired;
8
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
9
import org.springframework.boot.test.mock.mockito.MockBean;
10
import org.springframework.test.context.junit4.SpringRunner;
11
import org.springframework.test.web.servlet.MockMvc;
12

    
13
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
14
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
15

    
16
/**
17
 * Created by Alessia Bardi on 29/08/2017.
18
 *
19
 * @author Alessia Bardi
20
 */
21
@RunWith(SpringRunner.class)
22
@WebMvcTest(ParthenosPublisherController.class)
23
public class ParthenosPublisherControllerTest {
24
	@Autowired
25
	private MockMvc mvc;
26

    
27
	@MockBean
28
	private ParthenosPublisherHelper parthenosPublisherHelper;
29

    
30
	@MockBean
31
	private JRRPublisherHelper jrrPublisherHelper;
32

    
33
	@Test
34
	public void publishOK() throws Exception {
35
		mvc.perform(post("/publish").param("record", "<aTestRecord>value</aTestRecord>").param("parthenosTarget", "VIRTUOSO"))
36
				.andExpect(status().isOk());
37
	}
38

    
39
	@Test
40
	public void testEx() throws Exception {
41
		mvc.perform(post("/publish")).andExpect(status().is4xxClientError());
42
	}
43

    
44
	@Test
45
	public void testJRREx() throws Exception {
46
		mvc.perform(post("/publishJRR")).andExpect(status().is4xxClientError());
47
	}
48

    
49
	@Test
50
	public void testJRROk() throws Exception {
51
		mvc.perform(post("/publishJRR")).andExpect(status().is4xxClientError());
52
	}
53

    
54

    
55

    
56
}
(1-1/2)