Search in sources :

Example 6 with Image

use of tech.aroma.thrift.Image in project aroma-data-operations by RedRoma.

the class CassandraMediaRepositoryIT method testGetThumbnail.

@Test
public void testGetThumbnail() throws Exception {
    instance.saveThumbnail(mediaId, dimension, image);
    Image result = instance.getThumbnail(mediaId, dimension);
    assertThat(result, notNullValue());
    assertThat(result.data, is(image.data));
    assertThat(result.imageType, is(image.imageType));
}
Also used : Image(tech.aroma.thrift.Image) IntegrationTest(tech.sirwellington.alchemy.annotations.testing.IntegrationTest) Test(org.junit.Test)

Example 7 with Image

use of tech.aroma.thrift.Image in project aroma-data-operations by RedRoma.

the class CassandraMediaRepository method getThumbnail.

@Override
public Image getThumbnail(String mediaId, Dimension dimension) throws DoesNotExistException, TException {
    checkMediaId(mediaId);
    checkDimension(dimension);
    Statement query = createQueryToGetThumbnail(mediaId, dimension);
    ResultSet results = tryToExecute(query, "Failed to Query Cassandra for Thumbnail with Media ID: " + mediaId + " Dimension: " + dimension);
    checkResultsNotMissing(results);
    Row row = results.one();
    ensureRowExists(row, mediaId);
    Image thumbnail = converRowToImage(row);
    return thumbnail;
}
Also used : Statement(com.datastax.driver.core.Statement) ResultSet(com.datastax.driver.core.ResultSet) Row(com.datastax.driver.core.Row) Image(tech.aroma.thrift.Image)

Example 8 with Image

use of tech.aroma.thrift.Image in project aroma-data-operations by RedRoma.

the class CassandraMediaRepository method getMedia.

@Override
public Image getMedia(String mediaId) throws DoesNotExistException, TException {
    checkMediaId(mediaId);
    Statement query = createQueryToGetImage(mediaId);
    ResultSet results = tryToExecute(query, "Could not query Cassandra for Media with ID:" + mediaId);
    checkResultsNotMissing(results);
    Row row = results.one();
    ensureRowExists(row, mediaId);
    Image image = converRowToImage(row);
    return image;
}
Also used : Statement(com.datastax.driver.core.Statement) ResultSet(com.datastax.driver.core.ResultSet) Row(com.datastax.driver.core.Row) Image(tech.aroma.thrift.Image)

Example 9 with Image

use of tech.aroma.thrift.Image in project aroma-data-operations by RedRoma.

the class CassandraMediaRepositoryIT method testGetMedia.

@Test
public void testGetMedia() throws Exception {
    instance.saveMedia(mediaId, image);
    Image result = instance.getMedia(mediaId);
    assertImagesTheSame(result, image);
}
Also used : Image(tech.aroma.thrift.Image) IntegrationTest(tech.sirwellington.alchemy.annotations.testing.IntegrationTest) Test(org.junit.Test)

Example 10 with Image

use of tech.aroma.thrift.Image in project aroma-data-operations by RedRoma.

the class MemoryMediaRepositoryTest method testDeleteThumbnail.

@Test
public void testDeleteThumbnail() throws Exception {
    Image thumbnail = Lists.oneOf(thumbnails);
    Dimension dimension = thumbnail.getDimension();
    instance.saveThumbnail(mediaId, dimension, thumbnail);
    instance.deleteThumbnail(mediaId, dimension);
    assertThat(instance.containsThumbnail(mediaId, dimension), is(false));
}
Also used : Dimension(tech.aroma.thrift.Dimension) Image(tech.aroma.thrift.Image) Test(org.junit.Test)

Aggregations

Image (tech.aroma.thrift.Image)11 Test (org.junit.Test)9 Dimension (tech.aroma.thrift.Dimension)5 IntegrationTest (tech.sirwellington.alchemy.annotations.testing.IntegrationTest)3 ResultSet (com.datastax.driver.core.ResultSet)2 Row (com.datastax.driver.core.Row)2 Statement (com.datastax.driver.core.Statement)2 DontRepeat (tech.sirwellington.alchemy.test.junit.runners.DontRepeat)1