use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class PauseTransServletTest method testPauseTransServletEscapesHtmlWhenTransFound.
@Test
@PrepareForTest({ Encode.class })
public void testPauseTransServletEscapesHtmlWhenTransFound() throws ServletException, IOException {
KettleLogStore.init();
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
Trans mockTrans = mock(Trans.class);
TransMeta mockTransMeta = mock(TransMeta.class);
LogChannelInterface mockChannelInterface = mock(LogChannelInterface.class);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(PauseTransServlet.CONTEXT_PATH);
when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING_TO_TEST);
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(mockTransformationMap.getTransformation(any(CarteObjectEntry.class))).thenReturn(mockTrans);
when(mockTrans.getLogChannel()).thenReturn(mockChannelInterface);
when(mockTrans.getTransMeta()).thenReturn(mockTransMeta);
when(mockTransMeta.getMaximum()).thenReturn(new Point(10, 10));
pauseTransServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H1", out.toString())));
PowerMockito.verifyStatic(atLeastOnce());
Encode.forHtml(anyString());
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class RemoveJobServletTest method testRemoveJobServletEscapesHtmlWhenTransFound.
@Test
@PrepareForTest({ Encode.class })
public void testRemoveJobServletEscapesHtmlWhenTransFound() throws ServletException, IOException {
KettleLogStore.init();
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
Job mockJob = mock(Job.class);
JobMeta mockJobMeta = mock(JobMeta.class);
LogChannelInterface mockLogChannelInterface = mock(LogChannelInterface.class);
mockJob.setName(ServletTestUtils.BAD_STRING_TO_TEST);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(RemoveJobServlet.CONTEXT_PATH);
when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING_TO_TEST);
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(mockJobMap.getJob(any(CarteObjectEntry.class))).thenReturn(mockJob);
when(mockJob.getLogChannelId()).thenReturn(ServletTestUtils.BAD_STRING_TO_TEST);
when(mockJob.getLogChannel()).thenReturn(mockLogChannelInterface);
when(mockJob.getJobMeta()).thenReturn(mockJobMeta);
when(mockJobMeta.getMaximum()).thenReturn(new Point(10, 10));
removeJobServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H3", out.toString())));
PowerMockito.verifyStatic(atLeastOnce());
Encode.forHtml(anyString());
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class RemoveTransServletTest method testRemoveTransServletEscapesHtmlWhenTransFound.
@Test
@PrepareForTest({ Encode.class })
public void testRemoveTransServletEscapesHtmlWhenTransFound() throws ServletException, IOException {
KettleLogStore.init();
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
Trans mockTrans = mock(Trans.class);
TransMeta mockTransMeta = mock(TransMeta.class);
LogChannelInterface mockChannelInterface = mock(LogChannelInterface.class);
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
PowerMockito.spy(Encode.class);
when(mockHttpServletRequest.getContextPath()).thenReturn(RemoveTransServlet.CONTEXT_PATH);
when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING_TO_TEST);
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(mockTransformationMap.getTransformation(any(CarteObjectEntry.class))).thenReturn(mockTrans);
when(mockTrans.getLogChannel()).thenReturn(mockChannelInterface);
when(mockTrans.getLogChannelId()).thenReturn("test");
when(mockTrans.getTransMeta()).thenReturn(mockTransMeta);
when(mockTransMeta.getMaximum()).thenReturn(new Point(10, 10));
removeTransServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H3", out.toString())));
PowerMockito.verifyStatic(atLeastOnce());
Encode.forHtml(anyString());
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class JobDelegateTest method testElementToDataNodeSavesAttributes.
@Test
public void testElementToDataNodeSavesAttributes() throws KettleException {
JobMeta mockJobMeta = mock(JobMeta.class);
IUnifiedRepository mockUnifiedRepository = mock(IUnifiedRepository.class);
JobDelegate jobDelegate = new JobDelegate(mockPurRepository, mockUnifiedRepository);
JobLogTable mockJobLogTable = mock(JobLogTable.class);
JobEntryCopy mockJobEntryCopy = mock(JobEntryCopy.class);
Map<String, Map<String, String>> attributes = new HashMap<String, Map<String, String>>();
Map<String, String> group = new HashMap<String, String>();
final String mockGroup = "MOCK_GROUP";
final String mockProperty = "MOCK_PROPERTY";
final String mockValue = "MOCK_VALUE";
group.put(mockProperty, mockValue);
attributes.put(mockGroup, group);
JobEntryBaseAndInterface mockJobEntry = mock(JobEntryBaseAndInterface.class);
when(mockJobEntry.getAttributesMap()).thenReturn(attributes);
when(mockJobMeta.listParameters()).thenReturn(new String[] {});
when(mockJobMeta.getJobLogTable()).thenReturn(mockJobLogTable);
when(mockJobMeta.nrJobEntries()).thenReturn(1);
when(mockJobMeta.getJobEntry(0)).thenReturn(mockJobEntryCopy);
when(mockJobEntryCopy.getName()).thenReturn("MOCK_NAME");
when(mockJobEntryCopy.getLocation()).thenReturn(new Point(0, 0));
when(mockJobEntryCopy.getEntry()).thenReturn(mockJobEntry);
DataNode dataNode = jobDelegate.elementToDataNode(mockJobMeta);
DataNode groups = dataNode.getNode("entries").getNodes().iterator().next().getNode(AttributesMapUtil.NODE_ATTRIBUTE_GROUPS);
DataNode mockGroupNode = groups.getNode(mockGroup);
assertEquals(mockValue, mockGroupNode.getProperty(mockProperty).getString());
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransGraphTest method testMouseUpHopGetsSelected.
@Test
public void testMouseUpHopGetsSelected() {
MouseEvent event = mock(MouseEvent.class);
int x = 0, y = 0;
TransGraph transGraph = mock(TransGraph.class);
StepMeta stepMeta = mock(StepMeta.class);
StepErrorMeta errorMeta = new StepErrorMeta(null, null);
TransHopMeta selectedHop = new TransHopMeta();
selectedHop.setErrorHop(true);
selectedHop.setEnabled(TRUE_RESULT);
selectedHop.setFromStep(stepMeta);
when(stepMeta.getStepErrorMeta()).thenReturn(errorMeta);
when(transGraph.findHop(x, y)).thenReturn(selectedHop);
when(transGraph.screen2real(any(Integer.class), any(Integer.class))).thenReturn(new Point(x, y));
doCallRealMethod().when(transGraph).mouseUp(event);
transGraph.mouseUp(event);
Assert.assertTrue(errorMeta.isEnabled());
}
Aggregations