Search in sources :

Example 1 with GetPkgScreenshotsRequest

use of org.haiku.haikudepotserver.api1.model.pkg.GetPkgScreenshotsRequest in project haikudepotserver by haiku.

the class PkgApiIT method testGetPkgScreenshots.

/**
 * <p>This test depends on the sample package pkg1 having some screenshots associated with it.</p>
 */
@Test
public void testGetPkgScreenshots() {
    IntegrationTestSupportService.StandardTestData data = integrationTestSupportService.createStandardTestData();
    // ------------------------------------
    GetPkgScreenshotsResult result = pkgApi.getPkgScreenshots(new GetPkgScreenshotsRequest(data.pkg1.getName()));
    // ------------------------------------
    PkgSupplement pkgSupplement = data.pkg1.getPkgSupplement();
    Assertions.assertThat(result.items.size()).isEqualTo(pkgSupplement.getPkgScreenshots().size());
    List<org.haiku.haikudepotserver.dataobjects.PkgScreenshot> sortedScreenshots = pkgSupplement.getSortedPkgScreenshots();
    Assertions.assertThat(sortedScreenshots).hasSize(3);
    int[] widths = { 320, 240, 320 };
    int[] heights = { 240, 320, 240 };
    int[] lengths = { 41296, 28303, 33201 };
    for (int i = 0; i < sortedScreenshots.size(); i++) {
        org.haiku.haikudepotserver.dataobjects.PkgScreenshot pkgScreenshot = sortedScreenshots.get(i);
        PkgScreenshot apiPkgScreenshot = result.items.get(i);
        Assertions.assertThat(pkgScreenshot.getCode()).isEqualTo(apiPkgScreenshot.code);
        Assertions.assertThat(pkgScreenshot.getWidth()).isEqualTo(apiPkgScreenshot.width);
        Assertions.assertThat(pkgScreenshot.getHeight()).isEqualTo(apiPkgScreenshot.height);
        Assertions.assertThat(pkgScreenshot.getLength()).isEqualTo(apiPkgScreenshot.length);
        Assertions.assertThat(apiPkgScreenshot.width).isEqualTo(widths[i]);
        Assertions.assertThat(apiPkgScreenshot.height).isEqualTo(heights[i]);
        Assertions.assertThat(apiPkgScreenshot.length).isEqualTo(lengths[i]);
    }
}
Also used : PkgScreenshot(org.haiku.haikudepotserver.api1.model.pkg.PkgScreenshot) PkgSupplement(org.haiku.haikudepotserver.dataobjects.PkgSupplement) GetPkgScreenshotsResult(org.haiku.haikudepotserver.api1.model.pkg.GetPkgScreenshotsResult) IntegrationTestSupportService(org.haiku.haikudepotserver.IntegrationTestSupportService) GetPkgScreenshotsRequest(org.haiku.haikudepotserver.api1.model.pkg.GetPkgScreenshotsRequest) AbstractIntegrationTest(org.haiku.haikudepotserver.AbstractIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

AbstractIntegrationTest (org.haiku.haikudepotserver.AbstractIntegrationTest)1 IntegrationTestSupportService (org.haiku.haikudepotserver.IntegrationTestSupportService)1 GetPkgScreenshotsRequest (org.haiku.haikudepotserver.api1.model.pkg.GetPkgScreenshotsRequest)1 GetPkgScreenshotsResult (org.haiku.haikudepotserver.api1.model.pkg.GetPkgScreenshotsResult)1 PkgScreenshot (org.haiku.haikudepotserver.api1.model.pkg.PkgScreenshot)1 PkgSupplement (org.haiku.haikudepotserver.dataobjects.PkgSupplement)1 Test (org.junit.jupiter.api.Test)1