|
|
|
|
@@ -10,8 +10,11 @@
|
|
|
|
|
package org.eclipse.hawkbit.mgmt.rest.resource;
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.ACTION_V1_REQUEST_MAPPING;
|
|
|
|
|
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_SEARCH;
|
|
|
|
|
import static org.hamcrest.CoreMatchers.equalTo;
|
|
|
|
|
import static org.hamcrest.Matchers.hasSize;
|
|
|
|
|
import static org.springframework.http.MediaType.APPLICATION_JSON;
|
|
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
|
|
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
|
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
|
|
|
|
@@ -35,7 +38,6 @@ import org.eclipse.hawkbit.repository.model.Rollout;
|
|
|
|
|
import org.eclipse.hawkbit.repository.model.Target;
|
|
|
|
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.test.web.servlet.ResultActions;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -84,32 +86,32 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
|
|
|
|
assignDistributionSet(dsA, Collections.singletonList(testdataFactory.createTarget("knownTargetId")));
|
|
|
|
|
|
|
|
|
|
final String rsqlPendingStatus = "status==pending";
|
|
|
|
|
final String rsqlFinishedStatus = "status==finished";
|
|
|
|
|
final String rsqlPendingStatus = "active==true";
|
|
|
|
|
final String rsqlFinishedStatus = "active==false";
|
|
|
|
|
final String rsqlPendingOrFinishedStatus = rsqlFinishedStatus + "," + rsqlPendingStatus;
|
|
|
|
|
|
|
|
|
|
// pending status one result
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("size", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("content[0].status", equalTo("pending")));
|
|
|
|
|
.andExpect(jsonPath("content[0].active", equalTo(true)));
|
|
|
|
|
|
|
|
|
|
// finished status none result
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(0)))
|
|
|
|
|
.andExpect(jsonPath("size", equalTo(0)));
|
|
|
|
|
|
|
|
|
|
// pending or finished status one result
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("size", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("content[0].status", equalTo("pending")));
|
|
|
|
|
.andExpect(jsonPath("content[0].active", equalTo(true)));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -122,34 +124,34 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
|
|
|
|
assignDistributionSet(dsA, Collections.singletonList(testdataFactory.createTarget("knownTargetId")));
|
|
|
|
|
|
|
|
|
|
final String rsqlPendingStatus = "detailStatus==running";
|
|
|
|
|
final String rsqlFinishedStatus = "detailStatus==finished";
|
|
|
|
|
final String rsqlPendingStatus = "status==running";
|
|
|
|
|
final String rsqlFinishedStatus = "status==finished";
|
|
|
|
|
final String rsqlPendingOrFinishedStatus = rsqlFinishedStatus + "," + rsqlPendingStatus;
|
|
|
|
|
|
|
|
|
|
// running status one result
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("size", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("content[0].detailStatus", equalTo("running")))
|
|
|
|
|
.andExpect(jsonPath("content[0].status", equalTo("pending")));
|
|
|
|
|
.andExpect(jsonPath("content[0].active", equalTo(true)))
|
|
|
|
|
.andExpect(jsonPath("content[0].status", equalTo("running")));
|
|
|
|
|
|
|
|
|
|
// finished status none result
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(0)))
|
|
|
|
|
.andExpect(jsonPath("size", equalTo(0)));
|
|
|
|
|
|
|
|
|
|
// running or finished status one result
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("size", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("content[0].detailStatus", equalTo("running")))
|
|
|
|
|
.andExpect(jsonPath("content[0].status", equalTo("pending")));
|
|
|
|
|
.andExpect(jsonPath("content[0].active", equalTo(true)))
|
|
|
|
|
.andExpect(jsonPath("content[0].status", equalTo("running")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -175,7 +177,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
final String rsqlExtRefNoMatch = "externalref==234extRef";
|
|
|
|
|
|
|
|
|
|
// pending status one result
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRef))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRef))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(1)))
|
|
|
|
|
@@ -183,14 +185,14 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
.andExpect(jsonPath("content[0].externalRef", equalTo(externalRefs.get(0))));
|
|
|
|
|
|
|
|
|
|
// finished status none result
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRefWildcard))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRefWildcard))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(2)))
|
|
|
|
|
.andExpect(jsonPath("size", equalTo(2)));
|
|
|
|
|
|
|
|
|
|
// pending or finished status one result
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRefNoMatch))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRefNoMatch))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(0)))
|
|
|
|
|
@@ -204,8 +206,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
void filterActionsByLastStatusCode() throws Exception {
|
|
|
|
|
// assign a distribution set to three targets
|
|
|
|
|
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
|
|
|
|
final DistributionSetAssignmentResult assignmentResult = assignDistributionSet(dsA,
|
|
|
|
|
testdataFactory.createTargets("target1", "target2", "target3"));
|
|
|
|
|
final DistributionSetAssignmentResult assignmentResult = assignDistributionSet(
|
|
|
|
|
dsA, testdataFactory.createTargets("target1", "target2", "target3"));
|
|
|
|
|
final List<Action> actions = assignmentResult.getAssignedEntity();
|
|
|
|
|
assertThat(actions).hasSize(3);
|
|
|
|
|
|
|
|
|
|
@@ -216,7 +218,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
|
|
|
|
|
// verify that one result is returned if the actions are filtered for status code 200
|
|
|
|
|
final String rsqlStatusCode = "lastStatusCode==200";
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlStatusCode))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlStatusCode))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(1)))
|
|
|
|
|
@@ -225,7 +227,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
|
|
|
|
|
// verify no result is returned if we filter for a non-existing status code
|
|
|
|
|
final String rsqlWrongStatusCode = "lastStatusCode==999";
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlWrongStatusCode))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlWrongStatusCode))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(0)))
|
|
|
|
|
@@ -245,7 +247,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
final String rsqlDsVersion = "distributionSet.version==" + ds.getVersion();
|
|
|
|
|
final String rsqlDsId = "distributionSet.id==" + ds.getId();
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName)
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName)
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
@@ -254,25 +256,25 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.distributionset.name",
|
|
|
|
|
equalTo(ds.getName() + ":" + ds.getVersion())));
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsVersion))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsVersion))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("size", equalTo(1)));
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName + "," + rsqlDsVersion))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName + "," + rsqlDsVersion))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("size", equalTo(1)));
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=distributionSet.name==FooBar"))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=distributionSet.name==FooBar"))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(0)))
|
|
|
|
|
.andExpect(jsonPath("size", equalTo(0)));
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsId))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsId))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(1)))
|
|
|
|
|
@@ -301,7 +303,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
final String rsqlRolloutName = "rollout.name==" + rollout.getName();
|
|
|
|
|
final String rsqlRolloutId = "rollout.id==" + rollout.getId();
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutName)
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutName)
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
@@ -311,15 +313,14 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
.andExpect(jsonPath(
|
|
|
|
|
"content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion())));
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutId)
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutId)
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("size", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.target.name", equalTo(target1.getName())))
|
|
|
|
|
.andExpect(jsonPath(
|
|
|
|
|
"content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion())));
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion())));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -364,7 +365,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
|
|
|
|
|
final Action action0 = actions.get(0);
|
|
|
|
|
final Action action1 = actions.get(1);
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING)
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
@@ -373,8 +374,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
// verify action 1
|
|
|
|
|
.andExpect(jsonPath("content.[1].id", equalTo(action1.getId().intValue())))
|
|
|
|
|
.andExpect(jsonPath("content.[1].type", equalTo("update")))
|
|
|
|
|
.andExpect(jsonPath("content.[1].status", equalTo("pending")))
|
|
|
|
|
.andExpect(jsonPath("content.[1].detailStatus", equalTo("running")))
|
|
|
|
|
.andExpect(jsonPath("content.[1].active", equalTo(true)))
|
|
|
|
|
.andExpect(jsonPath("content.[1].status", equalTo("running")))
|
|
|
|
|
.andExpect(jsonPath("content.[1]._links.self.href",
|
|
|
|
|
equalTo(generateActionLink(knownTargetId, action1.getId()))))
|
|
|
|
|
.andExpect(jsonPath("content.[1]._links.target.href", equalTo(generateTargetLink(knownTargetId))))
|
|
|
|
|
@@ -384,13 +385,12 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
// verify action 0
|
|
|
|
|
.andExpect(jsonPath("content.[0].id", equalTo(action0.getId().intValue())))
|
|
|
|
|
.andExpect(jsonPath("content.[0].type", equalTo("cancel")))
|
|
|
|
|
.andExpect(jsonPath("content.[0].status", equalTo("pending")))
|
|
|
|
|
.andExpect(jsonPath("content.[0].detailStatus", equalTo("canceling")))
|
|
|
|
|
.andExpect(jsonPath("content.[0].active", equalTo(true)))
|
|
|
|
|
.andExpect(jsonPath("content.[0].status", equalTo("canceling")))
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.self.href",
|
|
|
|
|
equalTo(generateActionLink(knownTargetId, action0.getId()))))
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.target.href", equalTo(generateTargetLink(knownTargetId))))
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.distributionset.href",
|
|
|
|
|
equalTo(generateDistributionSetLink(action0))))
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.distributionset.href", equalTo(generateDistributionSetLink(action0))))
|
|
|
|
|
|
|
|
|
|
// verify collection properties
|
|
|
|
|
.andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(2)))
|
|
|
|
|
@@ -403,7 +403,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
*/
|
|
|
|
|
@Test
|
|
|
|
|
void getActionsWithEmptyResult() throws Exception {
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("size", equalTo(0)))
|
|
|
|
|
@@ -421,7 +421,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
|
|
|
|
|
// page 1: one entry
|
|
|
|
|
final Action action0 = actions.get(0);
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING)
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
@@ -430,8 +430,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
// verify action 0
|
|
|
|
|
.andExpect(jsonPath("content.[0].id", equalTo(action0.getId().intValue())))
|
|
|
|
|
.andExpect(jsonPath("content.[0].type", equalTo("cancel")))
|
|
|
|
|
.andExpect(jsonPath("content.[0].status", equalTo("pending")))
|
|
|
|
|
.andExpect(jsonPath("content.[0].detailStatus", equalTo(action0.getStatus().toString().toLowerCase())))
|
|
|
|
|
.andExpect(jsonPath("content.[0].active", equalTo(true)))
|
|
|
|
|
.andExpect(jsonPath("content.[0].status", equalTo(action0.getStatus().toString().toLowerCase())))
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.self.href",
|
|
|
|
|
equalTo(generateActionLink(knownTargetId, action0.getId()))))
|
|
|
|
|
|
|
|
|
|
@@ -442,7 +442,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
|
|
|
|
|
// page 2: one entry
|
|
|
|
|
final Action action1 = actions.get(1);
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING)
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))
|
|
|
|
|
@@ -453,10 +453,9 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
// verify action 1
|
|
|
|
|
.andExpect(jsonPath("content.[0].id", equalTo(action1.getId().intValue())))
|
|
|
|
|
.andExpect(jsonPath("content.[0].type", equalTo("update")))
|
|
|
|
|
.andExpect(jsonPath("content.[0].status", equalTo("pending")))
|
|
|
|
|
.andExpect(jsonPath("content.[0].detailStatus", equalTo(action1.getStatus().toString().toLowerCase())))
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.self.href",
|
|
|
|
|
equalTo(generateActionLink(knownTargetId, action1.getId()))))
|
|
|
|
|
.andExpect(jsonPath("content.[0].active", equalTo(true)))
|
|
|
|
|
.andExpect(jsonPath("content.[0].status", equalTo(action1.getStatus().toString().toLowerCase())))
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.self.href", equalTo(generateActionLink(knownTargetId, action1.getId()))))
|
|
|
|
|
|
|
|
|
|
// verify collection properties
|
|
|
|
|
.andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(2)))
|
|
|
|
|
@@ -474,12 +473,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
|
|
|
|
|
|
|
|
|
|
// not allowed methods
|
|
|
|
|
mvc.perform(post(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isMethodNotAllowed());
|
|
|
|
|
mvc.perform(put(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isMethodNotAllowed());
|
|
|
|
|
mvc.perform(post(ACTION_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed());
|
|
|
|
|
mvc.perform(put(ACTION_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -492,7 +487,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
|
|
|
|
|
final Long actionId = actions.get(0).getId();
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + actionId))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + actionId))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath(JSON_PATH_ACTION_ID, equalTo(actionId.intValue())));
|
|
|
|
|
@@ -503,9 +498,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
*/
|
|
|
|
|
@Test
|
|
|
|
|
void requestActionThatDoesNotExistsLeadsToNotFound() throws Exception {
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + 101))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isNotFound());
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + 101)).andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@@ -514,20 +507,18 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
Action action1 = assignmentResults.get(0).getAssignedEntity().get(0);
|
|
|
|
|
Action action2 = assignmentResults.get(1).getAssignedEntity().get(0);
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
|
|
|
|
|
// verify action 1
|
|
|
|
|
.andExpect(jsonPath("content.[0].id", equalTo(action1.getId().intValue())))
|
|
|
|
|
.andExpect(jsonPath("content.[1].id", equalTo(action2.getId().intValue())));
|
|
|
|
|
|
|
|
|
|
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + action1.getId()))
|
|
|
|
|
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING + "/" + action1.getId()))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk());
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + action1.getId()))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + action1.getId()))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isNotFound());
|
|
|
|
|
}
|
|
|
|
|
@@ -536,11 +527,9 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
void shouldSuccessfullyDeleteMultipleActions() throws Exception {
|
|
|
|
|
final List<DistributionSetAssignmentResult> assignmentResults = createTargetsAndPerformAssignment(4);
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
|
|
|
|
|
// verify action 1
|
|
|
|
|
.andExpect(jsonPath("content.[0].id", equalTo(assignmentResults.get(0).getAssignedEntity().get(0).getId().intValue())))
|
|
|
|
|
.andExpect(jsonPath("content.[1].id", equalTo(assignmentResults.get(1).getAssignedEntity().get(0).getId().intValue())))
|
|
|
|
|
@@ -548,33 +537,31 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
.andExpect(jsonPath("content.[3].id", equalTo(assignmentResults.get(3).getAssignedEntity().get(0).getId().intValue())));
|
|
|
|
|
|
|
|
|
|
final List<Long> actionIdsToDelete = new ArrayList<>();
|
|
|
|
|
long deletedActionId1 = assignmentResults.get(2).getAssignedEntity().get(0).getId();
|
|
|
|
|
final long deletedActionId1 = assignmentResults.get(2).getAssignedEntity().get(0).getId();
|
|
|
|
|
actionIdsToDelete.add(deletedActionId1);
|
|
|
|
|
long deletedActionId2 = assignmentResults.get(3).getAssignedEntity().get(0).getId();
|
|
|
|
|
final long deletedActionId2 = assignmentResults.get(3).getAssignedEntity().get(0).getId();
|
|
|
|
|
actionIdsToDelete.add(deletedActionId2);
|
|
|
|
|
|
|
|
|
|
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
|
|
|
|
|
.content(toJson(actionIdsToDelete)).contentType(MediaType.APPLICATION_JSON))
|
|
|
|
|
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).content(toJson(actionIdsToDelete)).contentType(APPLICATION_JSON))
|
|
|
|
|
.andExpect(status().isOk());
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + deletedActionId1))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedActionId1))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isNotFound());
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + deletedActionId2))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedActionId2))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isNotFound());
|
|
|
|
|
Action deletedAction3 = assignmentResults.get(1).getAssignedEntity().get(0);
|
|
|
|
|
String rsql = "target.name==" + deletedAction3.getTarget().getName();
|
|
|
|
|
final Action deletedAction3 = assignmentResults.get(1).getAssignedEntity().get(0);
|
|
|
|
|
final String rsql = "target.name==" + deletedAction3.getTarget().getName();
|
|
|
|
|
|
|
|
|
|
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, rsql).contentType(MediaType.APPLICATION_JSON))
|
|
|
|
|
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).param(REQUEST_PARAMETER_SEARCH, rsql).contentType(APPLICATION_JSON))
|
|
|
|
|
.andExpect(status().isOk());
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + deletedAction3.getId()))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedAction3.getId()))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isNotFound());
|
|
|
|
|
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + assignmentResults.get(0).getAssignedEntity().get(0).getId()))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + assignmentResults.get(0).getAssignedEntity().get(0).getId()))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk());
|
|
|
|
|
}
|
|
|
|
|
@@ -582,14 +569,13 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
@Test
|
|
|
|
|
void shouldReceiveBadRequestWhenNeeded() throws Exception {
|
|
|
|
|
// bad request on both empty parameters
|
|
|
|
|
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING).contentType(MediaType.APPLICATION_JSON))
|
|
|
|
|
.andExpect(status().isBadRequest());
|
|
|
|
|
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).contentType(APPLICATION_JSON)).andExpect(status().isBadRequest());
|
|
|
|
|
|
|
|
|
|
// bad request when both parameters are present
|
|
|
|
|
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING).contentType(MediaType.APPLICATION_JSON)
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "target.name==test")
|
|
|
|
|
.content(toJson(List.of(1,2,3)))
|
|
|
|
|
.contentType(MediaType.APPLICATION_JSON))
|
|
|
|
|
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).contentType(APPLICATION_JSON)
|
|
|
|
|
.param(REQUEST_PARAMETER_SEARCH, "target.name==test")
|
|
|
|
|
.content(toJson(List.of(1, 2, 3)))
|
|
|
|
|
.contentType(APPLICATION_JSON))
|
|
|
|
|
.andExpect(status().isBadRequest());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -623,15 +609,14 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
private void verifyResultsByTargetPropertyFilter(final Target target, final DistributionSet ds, final String rsqlTargetFilter)
|
|
|
|
|
throws Exception {
|
|
|
|
|
// pending status one result
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlTargetFilter)
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlTargetFilter)
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("total", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("size", equalTo(1)))
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.target.name", equalTo(target.getName())))
|
|
|
|
|
.andExpect(jsonPath(
|
|
|
|
|
"content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion())));
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion())));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void getActions(final boolean withExternalRef) throws Exception {
|
|
|
|
|
@@ -650,26 +635,22 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final ResultActions resultActions =
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
|
|
|
|
|
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
|
|
|
|
|
mvc.perform(get(ACTION_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
// verify action 1
|
|
|
|
|
.andExpect(jsonPath("content.[1].id", equalTo(action1.getId().intValue())))
|
|
|
|
|
.andExpect(jsonPath("content.[1].type", equalTo("update")))
|
|
|
|
|
.andExpect(jsonPath("content.[1].status", equalTo("pending")))
|
|
|
|
|
.andExpect(jsonPath("content.[1].detailStatus", equalTo("running")))
|
|
|
|
|
.andExpect(jsonPath("content.[1].active", equalTo(true)))
|
|
|
|
|
.andExpect(jsonPath("content.[1].status", equalTo("running")))
|
|
|
|
|
.andExpect(jsonPath("content.[1]._links.self.href",
|
|
|
|
|
equalTo(generateActionLink(knownTargetId, action1.getId()))))
|
|
|
|
|
|
|
|
|
|
// verify action 0
|
|
|
|
|
.andExpect(jsonPath("content.[0].id", equalTo(action0.getId().intValue())))
|
|
|
|
|
.andExpect(jsonPath("content.[0].type", equalTo("cancel")))
|
|
|
|
|
.andExpect(jsonPath("content.[0].status", equalTo("pending")))
|
|
|
|
|
.andExpect(jsonPath("content.[1].detailStatus", equalTo("running")))
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.self.href",
|
|
|
|
|
equalTo(generateActionLink(knownTargetId, action0.getId()))))
|
|
|
|
|
|
|
|
|
|
.andExpect(jsonPath("content.[0].active", equalTo(true)))
|
|
|
|
|
.andExpect(jsonPath("content.[1].status", equalTo("running")))
|
|
|
|
|
.andExpect(jsonPath("content.[0]._links.self.href", equalTo(generateActionLink(knownTargetId, action0.getId()))))
|
|
|
|
|
// verify collection properties
|
|
|
|
|
.andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(2)))
|
|
|
|
|
.andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(2)))
|
|
|
|
|
@@ -700,10 +681,9 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
|
|
|
|
|
controllerManagement.updateActionExternalRef(actions.get(0).getId(), externalRef);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final ResultActions resultActions =
|
|
|
|
|
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/{actionId}", actions.get(0).getId()))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk());
|
|
|
|
|
final ResultActions resultActions = mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/{actionId}", actions.get(0).getId()))
|
|
|
|
|
.andDo(MockMvcResultPrinter.print())
|
|
|
|
|
.andExpect(status().isOk());
|
|
|
|
|
|
|
|
|
|
if (withExternalRef) {
|
|
|
|
|
resultActions.andExpect(jsonPath("externalRef", equalTo(externalRef)));
|
|
|
|
|
|