use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class StopJobServletTest method testStopJobServletEscapesHtmlWhenTransFound.
@Test
@PrepareForTest({ Encode.class })
public void testStopJobServletEscapesHtmlWhenTransFound() 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(StopJobServlet.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));
stopJobServlet.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 StopTransServletIT method testStopTransServletEscapesHtmlWhenTransFound.
@Test
public void testStopTransServletEscapesHtmlWhenTransFound() 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);
when(mockHttpServletRequest.getContextPath()).thenReturn(StopTransServlet.CONTEXT_PATH);
when(mockHttpServletRequest.getParameter(anyString())).thenReturn(ServletTestUtils.BAD_STRING);
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));
stopTransServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
assertFalse(ServletTestUtils.hasBadText(ServletTestUtils.getInsideOfTag("H1", out.toString())));
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class JobInformation method loadValues.
private JobInformationValues loadValues(ReportSubjectLocation location) throws KettleException {
// Load the job
//
JobMeta jobMeta = loadJob(location);
Point min = jobMeta.getMinimum();
Point area = jobMeta.getMaximum();
area.x += 30;
area.y += 30;
int iconsize = 32;
ScrollBarInterface bar = new ScrollBarInterface() {
public void setThumb(int thumb) {
}
public int getSelection() {
return 0;
}
};
// Paint the transformation...
//
GCInterface gc = new SwingGC(null, area, iconsize, 50, 20);
List<AreaOwner> areaOwners = new ArrayList<AreaOwner>();
JobPainter painter = new JobPainter(gc, jobMeta, area, bar, bar, null, null, null, areaOwners, new ArrayList<JobEntryCopy>(), iconsize, 1, 0, 0, true, "FreeSans", 10);
painter.setMagnification(0.25f);
painter.drawJob();
BufferedImage bufferedImage = (BufferedImage) gc.getImage();
int newWidth = bufferedImage.getWidth() - min.x;
int newHeigth = bufferedImage.getHeight() - min.y;
BufferedImage image = new BufferedImage(newWidth, newHeigth, bufferedImage.getType());
image.getGraphics().drawImage(bufferedImage, 0, 0, newWidth, newHeigth, min.x, min.y, min.x + newWidth, min.y + newHeigth, null);
JobInformationValues values = new JobInformationValues();
values.jobMeta = jobMeta;
values.image = image;
values.areaOwners = areaOwners;
return values;
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransformationInformation method drawImage.
public void drawImage(final Graphics2D g2d, final Rectangle2D rectangle2d, ReportSubjectLocation location, boolean pixelateImages) throws KettleException {
// Load the transformation
//
TransMeta transMeta = loadTransformation(location);
Point min = transMeta.getMinimum();
Point area = transMeta.getMaximum();
area.x -= min.x;
area.y -= min.y;
int iconsize = 32;
ScrollBarInterface bar = new ScrollBarInterface() {
public void setThumb(int thumb) {
}
public int getSelection() {
return 0;
}
};
// Paint the transformation...
//
Rectangle rect = new java.awt.Rectangle(0, 0, area.x, area.y);
double magnificationX = rectangle2d.getWidth() / rect.getWidth();
double magnificationY = rectangle2d.getHeight() / rect.getHeight();
float magnification = (float) Math.min(1, Math.min(magnificationX, magnificationY));
SwingGC gc = new SwingGC(g2d, rect, iconsize, 0, 0);
gc.setDrawingPixelatedImages(pixelateImages);
TransPainter painter = new TransPainter(gc, transMeta, area, bar, bar, null, null, null, new ArrayList<AreaOwner>(), new ArrayList<StepMeta>(), iconsize, 1, 0, 0, true, "FreeSans", 10);
painter.setMagnification(magnification);
painter.setTranslationX((-min.x) * magnification);
painter.setTranslationY((-min.y) * magnification);
painter.buildTransformationImage();
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class AbstractMetaTest method testAddRemoveViewUndo.
@Test
public void testAddRemoveViewUndo() throws Exception {
// addUndo() right now will fail with an NPE
assertEquals(0, meta.getUndoSize());
meta.clearUndo();
assertEquals(0, meta.getUndoSize());
assertEquals(0, meta.getMaxUndo());
meta.setMaxUndo(3);
assertEquals(3, meta.getMaxUndo());
// viewThisUndo() and viewPreviousUndo() have the same logic
assertNull(meta.viewThisUndo());
assertNull(meta.viewPreviousUndo());
assertNull(meta.viewNextUndo());
assertNull(meta.previousUndo());
assertNull(meta.nextUndo());
StepMeta fromMeta = mock(StepMeta.class);
StepMeta toMeta = mock(StepMeta.class);
Object[] from = new Object[] { fromMeta };
Object[] to = new Object[] { toMeta };
int[] pos = new int[0];
Point[] prev = new Point[0];
Point[] curr = new Point[0];
meta.addUndo(from, to, pos, prev, curr, AbstractMeta.TYPE_UNDO_NEW, false);
assertNotNull(meta.viewThisUndo());
assertNotNull(meta.viewPreviousUndo());
assertNull(meta.viewNextUndo());
meta.addUndo(from, to, pos, prev, curr, AbstractMeta.TYPE_UNDO_CHANGE, false);
assertNotNull(meta.viewThisUndo());
assertNotNull(meta.viewPreviousUndo());
assertNull(meta.viewNextUndo());
TransAction action = meta.previousUndo();
assertNotNull(action);
assertEquals(AbstractMeta.TYPE_UNDO_CHANGE, action.getType());
assertNotNull(meta.viewThisUndo());
assertNotNull(meta.viewPreviousUndo());
assertNotNull(meta.viewNextUndo());
meta.addUndo(from, to, pos, prev, curr, AbstractMeta.TYPE_UNDO_DELETE, false);
meta.addUndo(from, to, pos, prev, curr, AbstractMeta.TYPE_UNDO_POSITION, false);
assertNotNull(meta.previousUndo());
assertNotNull(meta.nextUndo());
meta.setMaxUndo(1);
assertEquals(1, meta.getUndoSize());
meta.addUndo(from, to, pos, prev, curr, AbstractMeta.TYPE_UNDO_NEW, false);
}
Aggregations