@Test public void unsupportedBuildAreaDoesntBreakProjectorGradient() throws InappropriateDeviceException, ScriptException, Exception { AbstractPrintFileProcessor processor = createNewPrintFileProcessor(); Graphics2D graphics = Mockito.mock(Graphics2D.class); PrintJob printJob = createTestPrintJob(processor); Mockito.when( printJob .getPrinter() .getConfiguration() .getSlicingProfile() .getProjectorGradientCalculator()) .thenReturn("var mm = $buildAreaMM * 2;java.awt.Color.ORANGE"); Mockito.when(printJob.getPrintFileProcessor().getBuildAreaMM(Mockito.any(PrintJob.class))) .thenReturn(null); DataAid aid = processor.initializeJobCacheWithDataAid(printJob); // apply image transform processor.applyBulbMask(aid, graphics, 0, 0); // processor.applyImageTransforms(aid, graphics, 0, 0); // processor.applyImageTransforms(aid, null, 0, 0); }
@Test public void EnsureMethodsThrowExceptionIfNotInitialized() throws Exception { AbstractPrintFileProcessor processor = Mockito.mock(AbstractPrintFileProcessor.class, Mockito.CALLS_REAL_METHODS); PrintJob printJob = createTestPrintJob(processor); DataAid aid = null; try { // applyimagetransform processor.applyBulbMask(aid, null, 0, 0); Assert.fail("Failed to throw IllegalStateException."); } catch (IllegalStateException e) { } try { // applyimagetransform processor.applyImageTransforms(aid, null); Assert.fail("Failed to throw IllegalStateException."); } catch (IllegalStateException e) { } try { processor.performFooter(aid); Assert.fail("Failed to throw IllegalStateException."); } catch (IllegalStateException e) { } try { processor.performHeader(aid); Assert.fail("Failed to throw IllegalStateException."); } catch (IllegalStateException e) { } try { processor.printImageAndPerformPostProcessing(aid, image); Assert.fail("Failed to throw IllegalStateException."); } catch (IllegalStateException e) { } try { processor.performPreSlice(aid, null); Assert.fail("Failed to throw IllegalStateException."); } catch (IllegalStateException e) { } }