@Test @Transactional @Rollback(true) public void testCreateCanvas() throws Exception { uIService.saveWidget(widget); canvas = new Canvas("testCanvas"); canvas.setCanvasType(CanvasType.PRIVATE); canvas.setCanvasLayout(uIService.getCanvasLayoutById(1L)); canvas.setShortName("testCanvas"); canvas.setCreatedByUserName("createdByUserName"); canvas.setCreatedDateTime(new Date()); canvas.setWidgetInstanceList(widgetInstanceList); uIService.saveCanvas(canvas); Canvas retrivedCanvas = uIService.getCanvasByName(canvas.getName()); Assert.notNull(retrivedCanvas); }
private DefaultWidgetInstance prepareData(ObjectMapper objectMapper) throws JsonProcessingException { AbstractLicensableWidget widget = new UserProductivityWidget(); widget.setId(1l); widget.setName("user-productivity-widget"); Canvas perishableCanvas = new Canvas(); perishableCanvas.setName("Perishable Goods Canvas"); perishableCanvas.setShortName("shortName"); perishableCanvas.setCanvasType(CanvasType.PRIVATE); perishableCanvas.setCanvasId(1l); DefaultWidgetInstance defaultWidgetInstance = new DefaultWidgetInstance(); defaultWidgetInstance.setActualViewConfig(objectMapper.writeValueAsString(actualViewConfig)); defaultWidgetInstance.setCanvas(perishableCanvas); defaultWidgetInstance.setWidgetinstanceId(1l); defaultWidgetInstance.setWidget(widget); return defaultWidgetInstance; }
/** * @Author Adarsh kumar * * <p>testCanvasPersistedAndDeletion() provide the functionality of deletion of the canvas based * on the canvasId or canvasName in this test case new canvas is inserted and then deleted by the * uiService for testing. * * @throws Exception */ @Test @Rollback(value = true) @Transactional public void testCanvasPersistedAndDeletion() throws Exception { /* CREATING NEW CANVAS FOR TESTING PURPOSE */ this.uIService.saveWidget(widget); final Canvas canvasNew = new Canvas("testCanvas"); canvasNew.setCanvasType(CanvasType.PRIVATE); canvasNew.setCanvasLayout(uIService.getCanvasLayoutById(1L)); canvasNew.setShortName("testCanvas"); canvasNew.setCreatedByUserName("createdByUserName"); canvasNew.setCreatedDateTime(new Date()); canvasNew.setWidgetInstanceList(widgetInstanceList); final Long canvasId = this.uIService.saveCanvas(canvasNew); Assert.notNull(canvasId, "Canvas Isn't Persisted into database " + canvasId); /* DELETING THE CANVAS FROM DATABASE BASED ON ID */ final Boolean result = this.uIService.deleteCanvasById(canvasNew.getCanvasId()); Assert.isTrue(result, "Canvas Isn't deleted from database"); }