// Path: spring-jdbc/src/main/java/io/crate/spring/jdbc/samples/dao/ImagesDao.java
// public interface ImagesDao {
// 
//     boolean imageExists(String digest);
// 
//     List<Image> getImages();
// 
//     InputStream getImageAsInputStream(String digest);
// 
//     boolean deleteImage(String digest);
// 
//     Map<String, String> insertImage(String digest, byte[] decoded);
// }
// 
// Path: spring-jdbc/src/main/java/io/crate/spring/jdbc/samples/model/Image.java
// public class Image {
// 
//     private final String digest;
// 
//     @JsonProperty("last_modified")
//     private final Date lastModified;
// 
//     public Image(String digest, Date last_modified) {
//         this.digest = digest;
//         this.lastModified = last_modified;
//     }
// 
//     public String getDigest() {
//         return digest;
//     }
// 
//     public Date getLastModified() {
//         return lastModified;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         Image image = (Image) o;
//         return Objects.equals(digest, image.digest) &&
//                 Objects.equals(lastModified, image.lastModified);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(digest, lastModified);
//     }
// }


import com.google.common.hash.Hashing;
import io.crate.spring.jdbc.samples.dao.ImagesDao;
import io.crate.spring.jdbc.samples.model.Image;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
import java.util.Random;
package io.crate.spring.jdbc.samples.da;



@SpringBootTest
public class ImagesDaoTest {

    @Autowired
    private ImagesDao dao;

    @Test
    public void testImageCrud() throws Exception {
        var data = new byte[10];
        new Random().nextBytes(data);
        var hash = Hashing.sha1().hashBytes(data).toString();

        dao.insertImage(hash, data);
        Assertions.assertTrue(dao.imageExists(hash));
        var result = dao.getImageAsInputStream(hash).readAllBytes();;
        Assertions.assertArrayEquals(data, result);

// Path: spring-jdbc/src/main/java/io/crate/spring/jdbc/samples/dao/ImagesDao.java
// public interface ImagesDao {
// 
//     boolean imageExists(String digest);
// 
//     List<Image> getImages();
// 
//     InputStream getImageAsInputStream(String digest);
// 
//     boolean deleteImage(String digest);
// 
//     Map<String, String> insertImage(String digest, byte[] decoded);
// }
// 
// Path: spring-jdbc/src/main/java/io/crate/spring/jdbc/samples/model/Image.java
// public class Image {
// 
//     private final String digest;
// 
//     @JsonProperty("last_modified")
//     private final Date lastModified;
// 
//     public Image(String digest, Date last_modified) {
//         this.digest = digest;
//         this.lastModified = last_modified;
//     }
// 
//     public String getDigest() {
//         return digest;
//     }
// 
//     public Date getLastModified() {
//         return lastModified;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         Image image = (Image) o;
//         return Objects.equals(digest, image.digest) &&
//                 Objects.equals(lastModified, image.lastModified);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(digest, lastModified);
//     }
// }


// Path: spring-jdbc/src/test/java/io/crate/spring/jdbc/samples/da/ImagesDaoTest.java
import com.google.common.hash.Hashing;
import io.crate.spring.jdbc.samples.dao.ImagesDao;
import io.crate.spring.jdbc.samples.model.Image;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
import java.util.Random;

package io.crate.spring.jdbc.samples.da;



@SpringBootTest
public class ImagesDaoTest {

    @Autowired
    private ImagesDao dao;

    @Test
    public void testImageCrud() throws Exception {
        var data = new byte[10];
        new Random().nextBytes(data);
        var hash = Hashing.sha1().hashBytes(data).toString();

        dao.insertImage(hash, data);
        Assertions.assertTrue(dao.imageExists(hash));
        var result = dao.getImageAsInputStream(hash).readAllBytes();;
        Assertions.assertArrayEquals(data, result);

        List<Image> images = dao.getImages();