Search in sources :

Example 1 with ImageHelper

use of org.haiku.haikudepotserver.graphics.ImageHelper in project haikudepotserver by haiku.

the class PkgScreenshotControllerIT method testGet_scaling.

@Test
public void testGet_scaling() throws Exception {
    IntegrationTestSupportService.StandardTestData data = integrationTestSupportService.createStandardTestData();
    MockHttpServletResponse response = new MockHttpServletResponse();
    // ------------------------------------
    pkgScreenshotController.handleGet(response, 160, 120, "png", data.pkg1.getPkgSupplement().getSortedPkgScreenshots().get(0).getCode());
    // -----------------------------------
    Assertions.assertThat(response.getContentType()).isEqualTo(MediaType.PNG.toString());
    ImageHelper imageHelper = new ImageHelper();
    ImageHelper.Size size = imageHelper.derivePngSize(response.getContentAsByteArray());
    Assertions.assertThat(size.width).isEqualTo(160);
    Assertions.assertThat(size.height).isEqualTo(120);
}
Also used : IntegrationTestSupportService(org.haiku.haikudepotserver.IntegrationTestSupportService) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) ImageHelper(org.haiku.haikudepotserver.graphics.ImageHelper) AbstractIntegrationTest(org.haiku.haikudepotserver.AbstractIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

AbstractIntegrationTest (org.haiku.haikudepotserver.AbstractIntegrationTest)1 IntegrationTestSupportService (org.haiku.haikudepotserver.IntegrationTestSupportService)1 ImageHelper (org.haiku.haikudepotserver.graphics.ImageHelper)1 Test (org.junit.jupiter.api.Test)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1