@Test
  public void shouldSerializeObjectAttribute() {
    String expectedResult =
        "{\"product\":{\"id\":1,\"creationDate\":\""
            + currentDateAsStr
            + "\",\"name\":\"Product 1\",\"data\":\"data object for product\"}}";

    Product product = new Product(1L, "Product 1", currentDate);
    product.setData("data object for product");

    gsonSerialization.from(product).serialize();
    assertThat(jsonResult(), is(equalTo(expectedResult)));
  }
  @Test
  public void shouldSerializeByteArrayAttribute() {
    String expectedResult =
        "{\"product\":{\"id\":1,\"creationDate\":\""
            + currentDateAsStr
            + "\",\"name\":\"Product 1\""
            + ",\"image\":\"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK8AAACvABQqw0mAAAABV0RVh0Q3JlYXRpb24gVGltZQA2LzI0LzA59sFr4wAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNAay06AAAAJ3SURBVDiNlZO/S2phGMc/R+tkQnIMiZRMCgeVY4S2tUYQbS0hlUNDa1tLyyVaqhMh1NbgH9DSYEP+BQ1BS4OLBYFRqb1w9FR43rc7hHUv3eH2wDN9eeD7fH9o9Xo95jjO1dvbm8EPpq+vT/j9/knt5ubm2fiYn9wjhEAIITztdtvw+Xy4rvttn56eWF9fZ2dnB8dx/sJ8Ph/tdtvwSCnRNA0p5bdtNBqcnp5SLpfpdDq0Wi06nQ5/3vS4rotSCoDX11ceHx8JBAL09/cTCoXY398nHA7TbDbZ2toik8mwsLDA4OAgruvSI6VEKUWj0cCyLMrlMvF4nFQqRSaT4eHhAV3XKZVKFItFisUilUqFvb09pJR4unTX1tY4Pj4ml8tRrVYpFAq4rotlWRweHpJIJIhEImSzWeLx+Ocrnq4od3d3RKNRZmZmCAaDpNNp5ubmCIVChMNh5ufnCQaDLC8vk8/nP8X0SCkBODo6QtM0crkcw8PD7O7u4jgOtVqN9/d3bNum2Wxye3vLy8sLwBcDpRSmaRIIBGi1WmxubpJOp3EcB9u2qdfr6LrOyMgIhUKBlZUVlFK4rot3aWnp19DQENfX15ydndHb28vFxQXVapWpqSmi0SimaZJMJkmlUui6zujoKNPT09zf33/ZmM/nMQyDk5MTDg4OsCyLWCzG4uIiXacmJiZIJpMAnww8XXB2dhbbttne3uby8pJsNotpmiil0DQNpRRKKbxeL16vF6XUR5C6idvY2GBsbIzz83MSiQSrq6uMj4/TFflfXZBSopVKpWfAiEQi/G+hhBDUajUA0TMwMDAphLiqVCo/qqPf7xeGYUz+Bgm0dbIWFetGAAAAAElFTkSuQmCC\"}}";

    Product product = new Product(1L, "Product 1", currentDate);
    product.setImage(
        Base64.decodeBase64(
            "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK8AAACvABQqw0mAAAABV0RVh0Q3JlYXRpb24gVGltZQA2LzI0LzA59sFr4wAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNAay06AAAAJ3SURBVDiNlZO/S2phGMc/R+tkQnIMiZRMCgeVY4S2tUYQbS0hlUNDa1tLyyVaqhMh1NbgH9DSYEP+BQ1BS4OLBYFRqb1w9FR43rc7hHUv3eH2wDN9eeD7fH9o9Xo95jjO1dvbm8EPpq+vT/j9/knt5ubm2fiYn9wjhEAIITztdtvw+Xy4rvttn56eWF9fZ2dnB8dx/sJ8Ph/tdtvwSCnRNA0p5bdtNBqcnp5SLpfpdDq0Wi06nQ5/3vS4rotSCoDX11ceHx8JBAL09/cTCoXY398nHA7TbDbZ2toik8mwsLDA4OAgruvSI6VEKUWj0cCyLMrlMvF4nFQqRSaT4eHhAV3XKZVKFItFisUilUqFvb09pJR4unTX1tY4Pj4ml8tRrVYpFAq4rotlWRweHpJIJIhEImSzWeLx+Ocrnq4od3d3RKNRZmZmCAaDpNNp5ubmCIVChMNh5ufnCQaDLC8vk8/nP8X0SCkBODo6QtM0crkcw8PD7O7u4jgOtVqN9/d3bNum2Wxye3vLy8sLwBcDpRSmaRIIBGi1WmxubpJOp3EcB9u2qdfr6LrOyMgIhUKBlZUVlFK4rot3aWnp19DQENfX15ydndHb28vFxQXVapWpqSmi0SimaZJMJkmlUui6zujoKNPT09zf33/ZmM/nMQyDk5MTDg4OsCyLWCzG4uIiXacmJiZIJpMAnww8XXB2dhbbttne3uby8pJsNotpmiil0DQNpRRKKbxeL16vF6XUR5C6idvY2GBsbIzz83MSiQSrq6uMj4/TFflfXZBSopVKpWfAiEQi/G+hhBDUajUA0TMwMDAphLiqVCo/qqPf7xeGYUz+Bgm0dbIWFetGAAAAAElFTkSuQmCC"
                .getBytes()));

    gsonSerialization.from(product).serialize();
    assertThat(jsonResult(), is(equalTo(expectedResult)));
  }
 private Product createProductWithGroup(Long idProduct, Long idGroup) {
   Product product = createProduct(idProduct);
   product.setGroup(createGroup(idGroup));
   return product;
 }