Example usage for org.springframework.data.domain PageRequest of

List of usage examples for org.springframework.data.domain PageRequest of

Introduction

In this page you can find the example usage for org.springframework.data.domain PageRequest of.

Prototype

public static PageRequest of(int page, int size, Direction direction, String... properties) 

Source Link

Document

Creates a new PageRequest with sort direction and properties applied.

Usage

From source file:org.eclipse.hawkbit.ddi.rest.resource.DdiDeploymentBaseTest.java

@Test
@Description("Forced deployment to a controller. Checks if the resource reponse payload for a given deployment is as expected.")
public void deplomentForceAction() throws Exception {
    // Prepare test data
    final DistributionSet ds = testdataFactory.createDistributionSet("", true);
    final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);

    final int artifactSize = 5 * 1024;
    final byte random[] = RandomUtils.nextBytes(artifactSize);
    final Artifact artifact = artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random),
            getOsModule(ds), "test1", false, artifactSize));
    final Artifact artifactSignature = artifactManagement.create(new ArtifactUpload(
            new ByteArrayInputStream(random), getOsModule(ds), "test1.signature", false, artifactSize));

    final Target savedTarget = testdataFactory.createTarget("4712");

    assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).isEmpty();
    assertThat(deploymentManagement.countActionsAll()).isEqualTo(0);
    assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(0);

    List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.FORCED,
            RepositoryModelConstants.NO_FORCE_TIME, Arrays.asList(savedTarget.getControllerId()))
            .getAssignedEntity();/*from   w ww  .j  av a2s  .  c o m*/
    assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);

    final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
            .getContent().get(0);
    assertThat(deploymentManagement.countActionsAll()).isEqualTo(1);
    saved = assignDistributionSet(ds2, saved).getAssignedEntity();
    assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2);
    assertThat(deploymentManagement.countActionsAll()).isEqualTo(2);

    final Action uaction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
            .getContent().get(0);
    assertThat(uaction.getDistributionSet()).isEqualTo(ds);
    assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2);

    // Run test
    long current = System.currentTimeMillis();
    mvc.perform(get("/{tenant}/controller/v1/4712", tenantAware.getCurrentTenant()))
            .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
            .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8))
            .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00")))
            .andExpect(jsonPath("$._links.deploymentBase.href",
                    startsWith("http://localhost/" + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/deploymentBase/" + uaction.getId())));
    assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
            .isGreaterThanOrEqualTo(current);
    assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
            .isLessThanOrEqualTo(System.currentTimeMillis());
    assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2);

    current = System.currentTimeMillis();

    final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId())
            .get();

    mvc.perform(get("/{tenant}/controller/v1/4712/deploymentBase/" + uaction.getId(),
            tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON))
            .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(jsonPath("$.id", equalTo(String.valueOf(action.getId()))))
            .andExpect(jsonPath("$.deployment.download", equalTo("forced")))
            .andExpect(jsonPath("$.deployment.update", equalTo("forced")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='jvm')].name",
                    contains(ds.findFirstModuleByType(runtimeType).get().getName())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='jvm')].version",
                    contains(ds.findFirstModuleByType(runtimeType).get().getVersion())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].name",
                    contains(ds.findFirstModuleByType(osType).get().getName())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].version",
                    contains(ds.findFirstModuleByType(osType).get().getVersion())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0].size", contains(5 * 1024)))
            .andExpect(
                    jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0].filename", contains("test1")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0].hashes.md5",
                    contains(artifact.getMd5Hash())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0].hashes.sha1",
                    contains(artifact.getSha1Hash())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0]._links.download-http.href",
                    contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/softwaremodules/"
                            + findDistributionSetByAction.findFirstModuleByType(osType).get().getId()
                            + "/artifacts/test1")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0]._links.md5sum-http.href",
                    contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/softwaremodules/"
                            + findDistributionSetByAction.findFirstModuleByType(osType).get().getId()
                            + "/artifacts/test1.MD5SUM")))

            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1].size", contains(5 * 1024)))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1].filename",
                    contains("test1.signature")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1].hashes.md5",
                    contains(artifactSignature.getMd5Hash())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1].hashes.sha1",
                    contains(artifactSignature.getSha1Hash())))

            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1]._links.download-http.href",
                    contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/softwaremodules/"
                            + findDistributionSetByAction.findFirstModuleByType(osType).get().getId()
                            + "/artifacts/test1.signature")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1]._links.md5sum-http.href",
                    contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/softwaremodules/"
                            + findDistributionSetByAction.findFirstModuleByType(osType).get().getId()
                            + "/artifacts/test1.signature.MD5SUM")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='bApp')].version",
                    contains(ds.findFirstModuleByType(appType).get().getVersion())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='bApp')].name",
                    contains(ds.findFirstModuleByType(appType).get().getName())));

    // Retrieved is reported
    final Iterable<ActionStatus> actionStatusMessages = deploymentManagement
            .findActionStatusByAction(PageRequest.of(0, 100, Direction.DESC, "id"), uaction.getId());
    assertThat(actionStatusMessages).hasSize(2);
    final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
    assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
}

From source file:org.eclipse.hawkbit.ddi.rest.resource.DdiDeploymentBaseTest.java

@Test
@Description("Attempt/soft deployment to a controller. Checks if the resource reponse payload  for a given deployment is as expected.")
public void deplomentAttemptAction() throws Exception {
    // Prepare test data
    final DistributionSet ds = testdataFactory.createDistributionSet("", true);
    final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);
    final String visibleMetadataOsKey = "metaDataVisible";
    final String visibleMetadataOsValue = "withValue";

    final int artifactSize = 5 * 1024;
    final byte random[] = RandomUtils.nextBytes(artifactSize);
    final Artifact artifact = artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random),
            getOsModule(ds), "test1", false, artifactSize));
    final Artifact artifactSignature = artifactManagement.create(new ArtifactUpload(
            new ByteArrayInputStream(random), getOsModule(ds), "test1.signature", false, artifactSize));

    softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(getOsModule(ds))
            .key(visibleMetadataOsKey).value(visibleMetadataOsValue).targetVisible(true));
    softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(getOsModule(ds))
            .key("metaDataNotVisible").value("withValue").targetVisible(false));

    final Target savedTarget = testdataFactory.createTarget("4712");

    assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).isEmpty();
    assertThat(deploymentManagement.countActionsAll()).isEqualTo(0);
    assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(0);

    List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.SOFT,
            RepositoryModelConstants.NO_FORCE_TIME, Arrays.asList(savedTarget.getControllerId()))
            .getAssignedEntity();//w ww.j av  a  2  s  .co  m
    assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);

    final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
            .getContent().get(0);
    assertThat(deploymentManagement.countActionsAll()).isEqualTo(1);
    saved = assignDistributionSet(ds2, saved).getAssignedEntity();
    assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2);
    assertThat(deploymentManagement.countActionsAll()).isEqualTo(2);

    final Action uaction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
            .getContent().get(0);
    assertThat(uaction.getDistributionSet()).isEqualTo(ds);
    assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2);

    // Run test

    final long current = System.currentTimeMillis();
    mvc.perform(get("/{tenant}/controller/v1/4712", tenantAware.getCurrentTenant()))
            .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
            .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8))
            .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00")))
            .andExpect(jsonPath("$._links.deploymentBase.href",
                    startsWith("http://localhost/" + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/deploymentBase/" + uaction.getId())));
    assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
            .isGreaterThanOrEqualTo(current);
    assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
            .isLessThanOrEqualTo(System.currentTimeMillis());
    assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2);

    final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId())
            .get();

    mvc.perform(get("/{tenant}/controller/v1/4712/deploymentBase/" + uaction.getId(),
            tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON))
            .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(jsonPath("$.id", equalTo(String.valueOf(action.getId()))))
            .andExpect(jsonPath("$.deployment.download", equalTo("attempt")))
            .andExpect(jsonPath("$.deployment.update", equalTo("attempt")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='jvm')].name",
                    contains(ds.findFirstModuleByType(runtimeType).get().getName())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='jvm')].version",
                    contains(ds.findFirstModuleByType(runtimeType).get().getVersion())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].name",
                    contains(ds.findFirstModuleByType(osType).get().getName())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].version",
                    contains(ds.findFirstModuleByType(osType).get().getVersion())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].metadata[0].key")
                    .value(visibleMetadataOsKey))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].metadata[0].value")
                    .value(visibleMetadataOsValue))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0].size", contains(5 * 1024)))
            .andExpect(
                    jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0].filename", contains("test1")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0].hashes.md5",
                    contains(artifact.getMd5Hash())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0].hashes.sha1",
                    contains(artifact.getSha1Hash())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0]._links.download-http.href",
                    contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/softwaremodules/" + getOsModule(findDistributionSetByAction)
                            + "/artifacts/test1")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0]._links.md5sum-http.href",
                    contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/softwaremodules/" + getOsModule(findDistributionSetByAction)
                            + "/artifacts/test1.MD5SUM")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1].size", contains(5 * 1024)))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1].filename",
                    contains("test1.signature")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1].hashes.md5",
                    contains(artifactSignature.getMd5Hash())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1].hashes.sha1",
                    contains(artifactSignature.getSha1Hash())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1]._links.download-http.href",
                    contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/softwaremodules/" + getOsModule(findDistributionSetByAction)
                            + "/artifacts/test1.signature")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1]._links.md5sum-http.href",
                    contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/softwaremodules/" + getOsModule(findDistributionSetByAction)
                            + "/artifacts/test1.signature.MD5SUM")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='bApp')].version",
                    contains(ds.findFirstModuleByType(appType).get().getVersion())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='bApp')].metadata").doesNotExist())
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='bApp')].name")
                    .value(ds.findFirstModuleByType(appType).get().getName()));

    // Retrieved is reported
    final List<ActionStatus> actionStatusMessages = deploymentManagement
            .findActionStatusByAction(PageRequest.of(0, 100, Direction.DESC, "id"), uaction.getId())
            .getContent();
    assertThat(actionStatusMessages).hasSize(2);
    final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
    assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
}

From source file:org.eclipse.hawkbit.ddi.rest.resource.DdiDeploymentBaseTest.java

@Test
@Description("Attempt/soft deployment to a controller including automated switch to hard. Checks if the resource reponse payload  for a given deployment is as expected.")
public void deplomentAutoForceAction() throws Exception {
    // Prepare test data
    final DistributionSet ds = testdataFactory.createDistributionSet("", true);
    final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);

    final int artifactSize = 5 * 1024;
    final byte random[] = RandomUtils.nextBytes(artifactSize);
    final Artifact artifact = artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random),
            getOsModule(ds), "test1", false, artifactSize));
    final Artifact artifactSignature = artifactManagement.create(new ArtifactUpload(
            new ByteArrayInputStream(random), getOsModule(ds), "test1.signature", false, artifactSize));

    final Target savedTarget = testdataFactory.createTarget("4712");

    assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).isEmpty();
    assertThat(deploymentManagement.countActionsAll()).isEqualTo(0);
    assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(0);

    List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.TIMEFORCED,
            System.currentTimeMillis(), Arrays.asList(savedTarget.getControllerId())).getAssignedEntity();
    assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);

    final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
            .getContent().get(0);/*from  w  w  w . j a v  a  2s.c o  m*/
    assertThat(deploymentManagement.countActionsAll()).isEqualTo(1);
    saved = assignDistributionSet(ds2, saved).getAssignedEntity();
    assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2);
    assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2);

    final Action uaction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
            .getContent().get(0);
    assertThat(uaction.getDistributionSet()).isEqualTo(ds);
    assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2);

    // Run test

    long current = System.currentTimeMillis();
    mvc.perform(get("/{tenant}/controller/v1/4712", tenantAware.getCurrentTenant()))
            .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
            .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8))
            .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00")))
            .andExpect(jsonPath("$._links.deploymentBase.href",
                    startsWith("http://localhost/" + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/deploymentBase/" + uaction.getId())));
    assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
            .isGreaterThanOrEqualTo(current);
    assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
            .isLessThanOrEqualTo(System.currentTimeMillis());
    assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2);

    current = System.currentTimeMillis();

    final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId())
            .get();

    mvc.perform(get("/{tenant}/controller/v1/4712/deploymentBase/{actionId}", tenantAware.getCurrentTenant(),
            uaction.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
            .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8))
            .andExpect(jsonPath("$.id", equalTo(String.valueOf(action.getId()))))
            .andExpect(jsonPath("$.deployment.download", equalTo("forced")))
            .andExpect(jsonPath("$.deployment.update", equalTo("forced")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='jvm')].name",
                    contains(ds.findFirstModuleByType(runtimeType).get().getName())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='jvm')].version",
                    contains(ds.findFirstModuleByType(runtimeType).get().getVersion())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].name",
                    contains(ds.findFirstModuleByType(osType).get().getName())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].version",
                    contains(ds.findFirstModuleByType(osType).get().getVersion())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0].size", contains(5 * 1024)))
            .andExpect(
                    jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0].filename", contains("test1")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0].hashes.md5",
                    contains(artifact.getMd5Hash())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0].hashes.sha1",
                    contains(artifact.getSha1Hash())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0]._links.download-http.href",
                    contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/softwaremodules/"
                            + findDistributionSetByAction.findFirstModuleByType(osType).get().getId()
                            + "/artifacts/test1")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[0]._links.md5sum-http.href",
                    contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/softwaremodules/"
                            + findDistributionSetByAction.findFirstModuleByType(osType).get().getId()
                            + "/artifacts/test1.MD5SUM")))

            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1].size", contains(5 * 1024)))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1].filename",
                    contains("test1.signature")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1].hashes.md5",
                    contains(artifactSignature.getMd5Hash())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1].hashes.sha1",
                    contains(artifactSignature.getSha1Hash())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1]._links.download-http.href",
                    contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/softwaremodules/"
                            + findDistributionSetByAction.findFirstModuleByType(osType).get().getId()
                            + "/artifacts/test1.signature")))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='os')].artifacts[1]._links.md5sum-http.href",
                    contains(HTTP_LOCALHOST + tenantAware.getCurrentTenant()
                            + "/controller/v1/4712/softwaremodules/"
                            + findDistributionSetByAction.findFirstModuleByType(osType).get().getId()
                            + "/artifacts/test1.signature.MD5SUM")))

            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='bApp')].version",
                    contains(ds.findFirstModuleByType(appType).get().getVersion())))
            .andExpect(jsonPath("$.deployment.chunks[?(@.part=='bApp')].name",
                    contains(ds.findFirstModuleByType(appType).get().getName())));

    // Retrieved is reported
    final Iterable<ActionStatus> actionStatusMessages = deploymentManagement
            .findActionStatusByAction(PageRequest.of(0, 100, Direction.DESC, "id"), uaction.getId())
            .getContent();
    assertThat(actionStatusMessages).hasSize(2);
    final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
    assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
}

From source file:org.eclipse.hawkbit.mgmt.rest.resource.MgmtTargetResourceTest.java

@Test
@Description("Ensures that actions list is in exptected order.")
public void getActionStatusReturnsCorrectType() throws Exception {
    final int limitSize = 2;
    final String knownTargetId = "targetId";
    final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
    controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actions.get(0).getId())
            .status(Status.FINISHED).message("test"));

    final PageRequest pageRequest = PageRequest.of(0, 1000, Direction.ASC, ActionFields.ID.getFieldName());
    final Action action = deploymentManagement.findActionsByTarget(knownTargetId, pageRequest).getContent()
            .get(0);/*w ww  . j  a v a 2  s.c  o  m*/

    final ActionStatus status = deploymentManagement.findActionStatusByAction(PAGE, action.getId()).getContent()
            .stream().sorted((e1, e2) -> Long.compare(e2.getId(), e1.getId())).collect(Collectors.toList())
            .get(0);

    mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/"
            + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(0).getId() + "/status")
                    .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))
                    .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:DESC"))
            .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print())
            .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(3)))
            .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize)))
            .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize)))
            .andExpect(jsonPath("content.[0].id", equalTo(status.getId().intValue())))
            .andExpect(jsonPath("content.[0].type", equalTo("finished")))
            .andExpect(jsonPath("content.[0].messages", hasSize(1)))
            .andExpect(jsonPath("content.[0].reportedAt", equalTo(status.getCreatedAt())))
            .andExpect(jsonPath("content.[1].type", equalTo("canceling")));
}

From source file:org.jbb.members.web.base.logic.MemberSearchCriteriaFactory.java

private Pageable includeSortingToPageable(SearchMemberForm form, Pageable pageable) {
    return PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(),
            Direction.fromString(form.getSortDirection()), form.getSortByField());
}