@Transactional
  @Rollback(true)
  @Test
  public void testUpdateWidgetInstance()
      throws IllegalArgumentException, IllegalAccessException, InvocationTargetException,
          SecurityException, NoSuchMethodException, IOException {
    ObjectMapper objectMapper = new ObjectMapper();

    DefaultWidgetInstance defaultWidgetInstance = prepareData(objectMapper);

    Map<String, String> responsMap = uIService.createOrUpdateWidgetInstance(defaultWidgetInstance);
    Assert.isTrue(
        responsMap.get("widgetInstanceAction").equals("update"),
        "The response action should have been 'updated'");

    Canvas retrievedPerishableCanvas = uIService.getCanvasByName("Perishable Goods Canvas");
    List<DefaultWidgetInstance> retrievedDefaultWidgetInstances =
        retrievedPerishableCanvas.getWidgetInstanceList();

    DefaultWidgetInstance retrievedRefaultWidgetInstance = retrievedDefaultWidgetInstances.get(0);
    Assert.isTrue(
        objectMapper
            .writeValueAsString(actualViewConfig)
            .equals(retrievedRefaultWidgetInstance.getActualViewConfig()));
  }
  @Test
  @Transactional
  @Rollback(true)
  public void testGetWidgetInstanceListForCanvas() throws Exception {

    List<DefaultWidgetInstance> widgetInstanceList =
        uIService.getWidgetInstanceListForCanvas(3l, JACK_USERNAME);
    for (DefaultWidgetInstance widgetInstance : widgetInstanceList) {

      Map<String, Map<Permission, Boolean>> actionConfigMap =
          widgetInstance.getWidget().getActionConfig().getActionConfig();

      Assert.notNull(actionConfigMap);
    }
    Assert.notNull(widgetInstanceList);
  }
  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;
  }