@Test public void testGetJobXml() throws Exception { String jobName = "pr"; String xmlString = "<xml>some xml goes here</xml>"; Mockito.when(client.get(Mockito.anyString())).thenReturn(xmlString); String xmlReturn = server.getJobXml(jobName); Mockito.verify(client).get("/job/pr/config.xml"); assertEquals(xmlString, xmlReturn); }
@Test public void testUpdateJobXml() throws Exception { String jobName = "pr"; String xmlString = "<xml>some xml goes here</xml>"; Mockito.when(client.post_xml(Mockito.anyString(), Mockito.eq(xmlString))).thenReturn(xmlString); server.updateJob(jobName, xmlString); ArgumentCaptor<String> captureString = ArgumentCaptor.forClass(String.class); Mockito.verify(client).post_xml(Mockito.eq("/job/pr/config.xml"), captureString.capture()); assertEquals(xmlString, captureString.getValue()); }
@Test public void testJenkinsConnectivityBroken() throws IOException { Mockito.when(client.get("/")).thenThrow(IOException.class); assertEquals(server.isRunning(), false); }
@Test public void testJenkinsConnectivity() throws IOException { Mockito.when(client.get("/")).thenReturn("<xml>not a real response</xml>"); assertEquals(server.isRunning(), true); }
@Before public void setUp() throws Exception { when(client.get("/", MainView.class)).thenReturn(mainView); }