@@ -10,6 +10,7 @@
|
||||
package org.eclipse.hawkbit.mgmt.rest.resource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
@@ -858,7 +859,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
.version("anotherVersion").requiredMigrationStep(true).build());
|
||||
|
||||
// load also lazy stuff
|
||||
set = distributionSetManagement.getWithDetails(set.getId()).get();
|
||||
set = distributionSetManagement.getWithDetails(set.getId());
|
||||
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).hasSize(1);
|
||||
|
||||
@@ -943,11 +944,11 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
testdataFactory.generateDistributionSet("three", "three", standardDsType, List.of(os, jvm, ah), true));
|
||||
|
||||
final DistributionSet one = distributionSetManagement
|
||||
.getWithDetails(distributionSetManagement.findByRsql("name==one", PAGE).getContent().get(0).getId()).orElseThrow();
|
||||
.getWithDetails(distributionSetManagement.findByRsql("name==one", PAGE).getContent().get(0).getId());
|
||||
final DistributionSet two = distributionSetManagement
|
||||
.getWithDetails(distributionSetManagement.findByRsql("name==two", PAGE).getContent().get(0).getId()).orElseThrow();
|
||||
.getWithDetails(distributionSetManagement.findByRsql("name==two", PAGE).getContent().get(0).getId());
|
||||
final DistributionSet three = distributionSetManagement
|
||||
.getWithDetails(distributionSetManagement.findByRsql("name==three", PAGE).getContent().get(0).getId()).orElseThrow();
|
||||
.getWithDetails(distributionSetManagement.findByRsql("name==three", PAGE).getContent().get(0).getId());
|
||||
|
||||
assertThat((Object) JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString("http://localhost/rest/v1/distributionsets/" + one.getId());
|
||||
@@ -1702,11 +1703,11 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
|
||||
assertThat(targetFilterQueryManagement.find(targetFilterQuery.getId()).get().getAutoAssignDistributionSet())
|
||||
.isNull();
|
||||
assertThat(rolloutManagement.find(rollout.getId()).get().getStatus()).isIn(RolloutStatus.STOPPING,
|
||||
assertThat(rolloutManagement.get(rollout.getId()).getStatus()).isIn(RolloutStatus.STOPPING,
|
||||
RolloutStatus.STOPPED);
|
||||
//then enforce executor to stop the rollout and check
|
||||
rolloutHandler.handleAll();
|
||||
assertThat(rolloutManagement.find(rollout.getId()).get().getStatus()).isIn(RolloutStatus.STOPPED);
|
||||
assertThat(rolloutManagement.get(rollout.getId()).getStatus()).isIn(RolloutStatus.STOPPED);
|
||||
|
||||
for (final Target target : targets) {
|
||||
assertThat(targetManagement.find(target.getId()).get().getUpdateStatus())
|
||||
@@ -1735,17 +1736,16 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
.content(jsonObject.toString()).contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk());
|
||||
|
||||
assertThat(targetFilterQueryManagement.find(targetFilterQuery.getId()).get().getAutoAssignDistributionSet())
|
||||
.isNull();
|
||||
assertThat(rolloutManagement.find(rollout.getId()).get().getStatus()).isIn(RolloutStatus.DELETING,
|
||||
RolloutStatus.DELETED);
|
||||
assertThat(targetFilterQueryManagement.find(targetFilterQuery.getId()).get().getAutoAssignDistributionSet()).isNull();
|
||||
final Long rolloutId = rollout.getId();
|
||||
assertThat(rolloutManagement.get(rolloutId).getStatus()).isIn(RolloutStatus.DELETING, RolloutStatus.DELETED);
|
||||
//then enforce executor to stop the rollout and check
|
||||
rolloutHandler.handleAll();
|
||||
// assert rollout is deleted
|
||||
assertThat(rolloutManagement.find(rollout.getId())).isEmpty();
|
||||
assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(() -> rolloutManagement.get(rolloutId));
|
||||
|
||||
for (final Target target : targets) {
|
||||
assertThat(targetManagement.find(target.getId()).get().getUpdateStatus())
|
||||
assertThat(targetManagement.get(target.getId()).getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(deploymentManagement.findActionsByTarget(target.getControllerId(), PageRequest.of(0, 100))
|
||||
.getNumberOfElements()).isEqualTo(1);
|
||||
@@ -1769,11 +1769,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
.content(jsonObject.toString()).contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk());
|
||||
|
||||
assertThat(rolloutManagement.find(rollout.getId()).get().getStatus()).isIn(RolloutStatus.RUNNING);
|
||||
assertThat(rolloutManagement.get(rollout.getId()).getStatus()).isIn(RolloutStatus.RUNNING);
|
||||
|
||||
for (final Target target : targets) {
|
||||
assertThat(targetManagement.find(target.getId()).get().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(targetManagement.get(target.getId()).getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(deploymentManagement.findActionsByTarget(target.getControllerId(), PageRequest.of(0, 100))
|
||||
.getNumberOfElements()).isEqualTo(1);
|
||||
assertThat(deploymentManagement.findActionsByTarget(target.getControllerId(), PageRequest.of(0, 100))
|
||||
|
||||
@@ -30,13 +30,13 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.awaitility.Awaitility;
|
||||
import org.awaitility.core.ConditionFactory;
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutResponseBody;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtRestModelMapper;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
@@ -74,6 +74,7 @@ import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.ResultMatcher;
|
||||
|
||||
/**
|
||||
@@ -238,9 +239,10 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
final List<Target> allTargets = new ArrayList<>(successTargets);
|
||||
allTargets.addAll(failedTargets);
|
||||
|
||||
postRollout("rolloutToBeRetried", 1, dsA.getId(), "id==retryRolloutTarget*", 10, Action.ActionType.FORCED);
|
||||
final long rolloutToBeRetriedId = postRollout("rolloutToBeRetried", 1, dsA.getId(), "id==retryRolloutTarget*", 10,
|
||||
Action.ActionType.FORCED);
|
||||
|
||||
Rollout rollout = rolloutManagement.getByName("rolloutToBeRetried").orElseThrow();
|
||||
Rollout rollout = rolloutManagement.get(rolloutToBeRetriedId);
|
||||
|
||||
// no scheduler so invoke here
|
||||
rolloutHandler.handleAll();
|
||||
@@ -265,13 +267,18 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
//retry rollout
|
||||
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/retry", rollout.getId()))
|
||||
// retry rollout
|
||||
final MvcResult result = mvc.perform(post("/rest/v1/rollouts/{rolloutId}/retry", rollout.getId()))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().is(201));
|
||||
.andExpect(status().is(201))
|
||||
.andReturn();
|
||||
final long rolloutRetryId = OBJECT_MAPPER
|
||||
.readerFor(MgmtRolloutResponseBody.class)
|
||||
.<MgmtRolloutResponseBody> readValue(result.getResponse().getContentAsString())
|
||||
.getId();
|
||||
|
||||
//search for _retried suffix
|
||||
Rollout retriedRollout = rolloutManagement.getByName(rollout.getName() + "_retry").orElseThrow();
|
||||
Rollout retriedRollout = rolloutManagement.get(rolloutRetryId);
|
||||
//assert 4 targets involved
|
||||
rolloutHandler.handleAll();
|
||||
|
||||
@@ -303,8 +310,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
void retryNotFinishedRolloutShouldNotBeAllowed() throws Exception {
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
testdataFactory.createTargets("retryRolloutTarget-", 10);
|
||||
postRollout("rolloutToBeRetried", 1, dsA.getId(), "id==retryRolloutTarget*", 10, Action.ActionType.FORCED);
|
||||
Rollout rollout = rolloutManagement.getByName("rolloutToBeRetried").orElseThrow();
|
||||
final long rolloutToBeRetried = postRollout("rolloutToBeRetried", 1, dsA.getId(), "id==retryRolloutTarget*", 10,
|
||||
Action.ActionType.FORCED);
|
||||
Rollout rollout = rolloutManagement.get(rolloutToBeRetried);
|
||||
// no scheduler so invoke here
|
||||
rolloutHandler.handleAll();
|
||||
rolloutManagement.start(rollout.getId());
|
||||
@@ -1072,7 +1080,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSetLocked("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
final Rollout rollout1 = createRollout("rollout1", 4, dsA, "controllerId==rollout*",false);
|
||||
final Rollout rollout1 = createRollout("rollout1", 4, dsA, "controllerId==rollout*", false);
|
||||
final Rollout rollout2 = createRollout("rollout2", 1, dsA, "controllerId==rollout*", false);
|
||||
|
||||
rolloutManagement.start(rollout1.getId());
|
||||
@@ -1946,7 +1954,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
|
||||
private void awaitRunningState(final Long rolloutId) {
|
||||
awaitRollout().until(() -> SecurityContextSwitch
|
||||
.callAsPrivileged(() -> rolloutManagement.find(rolloutId).orElseThrow(NoSuchElementException::new))
|
||||
.callAsPrivileged(() -> rolloutManagement.get(rolloutId))
|
||||
.getStatus().equals(RolloutStatus.RUNNING));
|
||||
}
|
||||
|
||||
@@ -1966,22 +1974,21 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertStatusIs(final Rollout rollout, final RolloutStatus expected) {
|
||||
final Optional<Rollout> updatedRollout = rolloutManagement.find(rollout.getId());
|
||||
assertThat(updatedRollout).get().extracting(Rollout::getStatus).isEqualTo(expected);
|
||||
assertThat(rolloutManagement.get(rollout.getId()).getStatus()).isEqualTo(expected);
|
||||
}
|
||||
|
||||
private void postRollout(final String name, final int groupSize, final Long distributionSetId,
|
||||
private long postRollout(final String name, final int groupSize, final Long distributionSetId,
|
||||
final String targetFilterQuery, final int targets, final Action.ActionType type) throws Exception {
|
||||
postRollout(name, groupSize, distributionSetId, targetFilterQuery, targets, type, null, null);
|
||||
return postRollout(name, groupSize, distributionSetId, targetFilterQuery, targets, type, null, null);
|
||||
}
|
||||
|
||||
private void postRollout(final String name, final int groupSize, final Long distributionSetId,
|
||||
private long postRollout(final String name, final int groupSize, final Long distributionSetId,
|
||||
final String targetFilterQuery, final int targets, final Action.ActionType type, final Long startTime,
|
||||
final Long forceTime) throws Exception {
|
||||
postRollout(name, groupSize, distributionSetId, targetFilterQuery, targets, type, startTime, forceTime, false, null, 0);
|
||||
return postRollout(name, groupSize, distributionSetId, targetFilterQuery, targets, type, startTime, forceTime, false, null, 0);
|
||||
}
|
||||
|
||||
private void postRollout(final String name, final int groupSize, final Long distributionSetId,
|
||||
private long postRollout(final String name, final int groupSize, final Long distributionSetId,
|
||||
final String targetFilterQuery, final int targets, final Action.ActionType type, final Long startTime,
|
||||
final Long forceTime, boolean isDynamic, String dynamicGroupSuffix, int dynamicGroupTargetsCount) throws Exception {
|
||||
final String actionType = MgmtRestModelMapper.convertActionType(type).getName();
|
||||
@@ -1989,7 +1996,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
new RolloutGroupConditionBuilder().withDefaults().build(), null, actionType, null, startTime, forceTime,
|
||||
null, isDynamic, dynamicGroupSuffix, dynamicGroupTargetsCount);
|
||||
|
||||
mvc.perform(post("/rest/v1/rollouts").content(rollout).contentType(MediaType.APPLICATION_JSON)
|
||||
final MvcResult result = mvc.perform(post("/rest/v1/rollouts").content(rollout).contentType(MediaType.APPLICATION_JSON)
|
||||
.accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isCreated())
|
||||
@@ -2004,10 +2011,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("$.lastModifiedBy", equalTo("bumlux")))
|
||||
.andExpect(jsonPath("$.lastModifiedAt", not(equalTo(0))))
|
||||
.andExpect(jsonPath("$.totalTargets", equalTo(targets)))
|
||||
.andExpect(startTime != null ? jsonPath("$.startAt", equalTo(startTime.intValue()))
|
||||
: jsonPath("$.startAt").doesNotExist())
|
||||
.andExpect(forceTime != null ? jsonPath("$.forcetime", equalTo(forceTime.intValue()))
|
||||
: jsonPath("$.forcetime", equalTo(0)))
|
||||
.andExpect(startTime != null ? jsonPath("$.startAt", equalTo(startTime.intValue())) : jsonPath("$.startAt").doesNotExist())
|
||||
.andExpect(forceTime != null ? jsonPath("$.forcetime", equalTo(forceTime.intValue())) : jsonPath("$.forcetime", equalTo(0)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.running", equalTo(0)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.notstarted", equalTo(targets)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.scheduled", equalTo(0)))
|
||||
@@ -2019,8 +2024,12 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("$._links.pause.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/pause"))))
|
||||
.andExpect(jsonPath("$.dynamic", equalTo(isDynamic)))
|
||||
.andExpect(jsonPath("$._links.resume.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/resume"))))
|
||||
.andExpect(jsonPath(
|
||||
"$._links.groups.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), containsString("/deploygroups"))));
|
||||
.andExpect(jsonPath("$._links.groups.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), containsString("/deploygroups"))))
|
||||
.andReturn();
|
||||
return OBJECT_MAPPER
|
||||
.readerFor(MgmtRolloutResponseBody.class)
|
||||
.<MgmtRolloutResponseBody> readValue(result.getResponse().getContentAsString())
|
||||
.getId();
|
||||
}
|
||||
|
||||
private Rollout createRollout(
|
||||
@@ -2039,7 +2048,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
// Run here, because Scheduler is disabled during tests
|
||||
rolloutHandler.handleAll();
|
||||
|
||||
return rolloutManagement.find(rollout.getId()).orElseThrow(NoSuchElementException::new);
|
||||
return rolloutManagement.get(rollout.getId());
|
||||
}
|
||||
|
||||
private void triggerNextGroupAndExpect(final Rollout rollout, final ResultMatcher expect) throws Exception {
|
||||
|
||||
@@ -31,13 +31,16 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.hawkbit.artifact.exception.ArtifactBinaryNotFoundException;
|
||||
import org.eclipse.hawkbit.artifact.exception.FileSizeQuotaExceededException;
|
||||
import org.eclipse.hawkbit.artifact.exception.StorageQuotaExceededException;
|
||||
import org.eclipse.hawkbit.artifact.model.ArtifactStream;
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
|
||||
@@ -47,13 +50,9 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.resource.util.ResourceUtility;
|
||||
import org.eclipse.hawkbit.repository.Constants;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.artifact.exception.ArtifactBinaryNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.artifact.model.DbArtifact;
|
||||
import org.eclipse.hawkbit.repository.artifact.model.DbArtifactHash;
|
||||
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.FileSizeQuotaExceededException;
|
||||
import org.eclipse.hawkbit.repository.exception.StorageQuotaExceededException;
|
||||
import org.eclipse.hawkbit.repository.jpa.repository.LocalArtifactRepository;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.ArtifactUpload;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
@@ -94,6 +93,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
"hawkbit.server.security.dos.maxArtifactStorage=500000" })
|
||||
class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
|
||||
private LocalArtifactRepository localArtifactRepository;
|
||||
|
||||
@BeforeEach
|
||||
public void assertPreparationOfRepo() {
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).as("no softwaremodule should be founded").isEmpty();
|
||||
@@ -145,7 +146,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
|
||||
final byte[] random = randomBytes(5);
|
||||
|
||||
artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, 0));
|
||||
artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random), null, 0, null, sm.getId(), "file1", false));
|
||||
|
||||
mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", sm.getId())
|
||||
.param("representation", MgmtRepresentationMode.FULL.toString())
|
||||
@@ -515,8 +516,10 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
.andExpect(jsonPath("$.providedFilename", equalTo("customFilename")))
|
||||
.andExpect(status().isCreated())
|
||||
.andDo(result -> {
|
||||
final MgmtArtifact mgmtArtifact = OBJECT_MAPPER.readerFor(MgmtArtifact.class).readValue(result.getResponse().getContentAsString());
|
||||
assertThat(artifactManagement.loadArtifactBinary(mgmtArtifact.getHashes().getSha1(), sm.getId(), sm.isEncrypted())).isNotNull();
|
||||
final MgmtArtifact mgmtArtifact = OBJECT_MAPPER.readerFor(MgmtArtifact.class)
|
||||
.readValue(result.getResponse().getContentAsString());
|
||||
assertThat(artifactManagement.getArtifactStream(mgmtArtifact.getHashes().getSha1(), sm.getId(),
|
||||
sm.isEncrypted())).isNotNull();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -687,9 +690,9 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
final byte[] random = randomBytes(artifactSize);
|
||||
|
||||
final Artifact artifact = artifactManagement.create(
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize));
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), null, artifactSize, null, sm.getId(), "file1", false));
|
||||
final Artifact artifact2 = artifactManagement.create(
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file2", false, artifactSize));
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), null, artifactSize, null, sm.getId(), "file2", false));
|
||||
|
||||
downloadAndVerify(sm, random, artifact);
|
||||
downloadAndVerify(sm, random, artifact2);
|
||||
@@ -707,7 +710,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
final byte[] random = randomBytes(artifactSize);
|
||||
|
||||
final Artifact artifact = artifactManagement
|
||||
.create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize));
|
||||
.create(new ArtifactUpload(new ByteArrayInputStream(random), null, artifactSize, null, sm.getId(), "file1", false));
|
||||
|
||||
// perform test
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}", sm.getId(), artifact.getId())
|
||||
@@ -722,11 +725,9 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
.andExpect(jsonPath("$.hashes.sha256", equalTo(artifact.getSha256Hash())))
|
||||
.andExpect(jsonPath("$.providedFilename", equalTo("file1")))
|
||||
.andExpect(jsonPath("$._links.download.href",
|
||||
equalTo("http://localhost/rest/v1/softwaremodules/%s/artifacts/%s/download"
|
||||
.formatted(sm.getId(), artifact.getId()))))
|
||||
equalTo("http://localhost/rest/v1/softwaremodules/%s/artifacts/%s/download".formatted(sm.getId(), artifact.getId()))))
|
||||
.andExpect(jsonPath("$._links.self.href",
|
||||
equalTo("http://localhost/rest/v1/softwaremodules/%s/artifacts/%s".formatted(sm.getId(),
|
||||
artifact.getId()))));
|
||||
equalTo("http://localhost/rest/v1/softwaremodules/%s/artifacts/%s".formatted(sm.getId(), artifact.getId()))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -742,7 +743,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
final byte[] random = randomBytes(artifactSize);
|
||||
|
||||
final Artifact artifact = artifactManagement
|
||||
.create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize));
|
||||
.create(new ArtifactUpload(new ByteArrayInputStream(random), null, artifactSize, null, sm.getId(), "file1", false));
|
||||
|
||||
// perform test
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}", sm.getId(), artifact.getId())
|
||||
@@ -806,9 +807,9 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
final byte[] random = randomBytes(artifactSize);
|
||||
|
||||
final Artifact artifact = artifactManagement.create(
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize));
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), null, artifactSize, null, sm.getId(), "file1", false));
|
||||
final Artifact artifact2 = artifactManagement.create(
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file2", false, artifactSize));
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), null, artifactSize, null, sm.getId(), "file2", false));
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
@@ -844,9 +845,9 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
final byte[] random = randomBytes(artifactSize);
|
||||
|
||||
final Artifact artifact = artifactManagement
|
||||
.create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize));
|
||||
.create(new ArtifactUpload(new ByteArrayInputStream(random), null, artifactSize, null, sm.getId(), "file1", false));
|
||||
final Artifact artifact2 = artifactManagement
|
||||
.create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file2", false, artifactSize));
|
||||
.create(new ArtifactUpload(new ByteArrayInputStream(random), null, artifactSize, null, sm.getId(), "file2", false));
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId())
|
||||
.param("representation", MgmtRepresentationMode.FULL.toString())
|
||||
@@ -910,7 +911,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
|
||||
// SM does not exist
|
||||
artifactManagement
|
||||
.create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize));
|
||||
.create(new ArtifactUpload(new ByteArrayInputStream(random), null, artifactSize, null, sm.getId(), "file1", false));
|
||||
mvc.perform(get("/rest/v1/softwaremodules/1234567890/artifacts"))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isNotFound());
|
||||
@@ -954,10 +955,10 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
final long moduleId = sm.getId();
|
||||
final byte[] random = randomBytes(artifactSize);
|
||||
final Artifact artifact = artifactManagement.create(
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), moduleId, "file1", false, artifactSize));
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), null, artifactSize, null, moduleId, "file1", false));
|
||||
final byte[] random2 = randomBytes(artifactSize);
|
||||
artifactManagement.create(
|
||||
new ArtifactUpload(new ByteArrayInputStream(random2), moduleId, "file2", false, artifactSize));
|
||||
new ArtifactUpload(new ByteArrayInputStream(random2), null, artifactSize, null, moduleId, "file2", false));
|
||||
|
||||
// check repo before delete
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(1);
|
||||
@@ -974,7 +975,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
final boolean encrypted = sm.isEncrypted();
|
||||
final String sha1Hash = artifact.getSha1Hash();
|
||||
assertThatExceptionOfType(ArtifactBinaryNotFoundException.class)
|
||||
.isThrownBy(() -> artifactManagement.loadArtifactBinary(sha1Hash, moduleId, encrypted));
|
||||
.isThrownBy(() -> artifactManagement.getArtifactStream(sha1Hash, moduleId, encrypted));
|
||||
assertThat(softwareModuleManagement.find(moduleId).get().getArtifacts())
|
||||
.as("After delete artifact should available for marked as deleted sm's").hasSize(1);
|
||||
}
|
||||
@@ -1344,14 +1345,14 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
final byte[] random = randomBytes(artifactSize);
|
||||
|
||||
final Artifact artifact = artifactManagement.create(
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize));
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), null, artifactSize, null, sm.getId(), "file1", false));
|
||||
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).as("Softwaremoudle size is wrong").hasSize(1);
|
||||
|
||||
final Long smId = sm.getId();
|
||||
final String sha1Hash = artifact.getSha1Hash();
|
||||
final boolean encrypted = sm.isEncrypted();
|
||||
assertThat(artifactManagement.loadArtifactBinary(sha1Hash, smId, encrypted)).isNotNull();
|
||||
assertThat(artifactManagement.getArtifactStream(sha1Hash, smId, encrypted)).isNotNull();
|
||||
|
||||
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", sm.getId()))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
@@ -1359,7 +1360,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).as("After delete no softwarmodule should be available").isEmpty();
|
||||
assertThatExceptionOfType(EntityNotFoundException.class) // sm doesn't exists
|
||||
.isThrownBy(() -> artifactManagement.loadArtifactBinary(sha1Hash, smId, encrypted));
|
||||
.isThrownBy(() -> artifactManagement.getArtifactStream(sha1Hash, smId, encrypted));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1376,12 +1377,12 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
final Long appTypeSmId = appTypeSm.getId();
|
||||
|
||||
final Artifact artifact = artifactManagement.create(
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), appTypeSmId, "file1", false, artifactSize));
|
||||
new ArtifactUpload(new ByteArrayInputStream(random), null, artifactSize, null, appTypeSmId, "file1", false));
|
||||
|
||||
assertThat(softwareModuleManagement.count()).isEqualTo(3);
|
||||
final String sha1Hash = artifact.getSha1Hash();
|
||||
final boolean encrypted = appTypeSm.isEncrypted();
|
||||
assertThat(artifactManagement.loadArtifactBinary(sha1Hash, appTypeSmId, encrypted)).isNotNull();
|
||||
assertThat(artifactManagement.getArtifactStream(sha1Hash, appTypeSmId, encrypted)).isNotNull();
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}", appTypeSmId))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
@@ -1399,7 +1400,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
|
||||
assertThat(softwareModuleManagement.count()).isEqualTo(2);
|
||||
assertThatExceptionOfType(ArtifactBinaryNotFoundException.class)
|
||||
.isThrownBy(() -> artifactManagement.loadArtifactBinary(sha1Hash, appTypeSmId, encrypted));
|
||||
.isThrownBy(() -> artifactManagement.getArtifactStream(sha1Hash, appTypeSmId, encrypted));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1526,19 +1527,13 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
}
|
||||
|
||||
private void assertArtifact(final SoftwareModule sm, final byte[] random) throws IOException {
|
||||
final DbArtifact artifact = artifactManagement
|
||||
.loadArtifactBinary(
|
||||
softwareModuleManagement.find(
|
||||
sm.getId()).orElseThrow().getArtifacts().get(0).getSha1Hash(), sm.getId(), sm.isEncrypted());
|
||||
// binary
|
||||
try (final InputStream fileInputStream = artifact.getFileInputStream()) {
|
||||
assertTrue(IOUtils.contentEquals(new ByteArrayInputStream(random), fileInputStream),
|
||||
"Wrong artifact content");
|
||||
try (final ArtifactStream artifact = artifactManagement.getArtifactStream(
|
||||
softwareModuleManagement.find(sm.getId()).orElseThrow().getArtifacts().get(0).getSha1Hash(), sm.getId(), sm.isEncrypted())) {
|
||||
assertTrue(IOUtils.contentEquals(new ByteArrayInputStream(random), artifact), "Wrong artifact content");
|
||||
// hashes
|
||||
assertThat(artifact.getSha1Hash()).as("Wrong sha1 hash").isEqualTo(HashGeneratorUtils.generateSHA1(random));
|
||||
}
|
||||
|
||||
// hashes
|
||||
final DbArtifactHash hash = artifact.getHashes();
|
||||
assertThat(hash.getSha1()).as("Wrong sha1 hash").isEqualTo(HashGeneratorUtils.generateSHA1(random));
|
||||
// metadata
|
||||
assertThat(softwareModuleManagement.find(sm.getId()).orElseThrow().getArtifacts().get(0).getFilename())
|
||||
.as("wrong metadata of the filename").isEqualTo("origFilename");
|
||||
|
||||
@@ -538,8 +538,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
// action has not been cancelled confirmed from controller, so DS
|
||||
// remains assigned until
|
||||
// confirmation
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(tA.getControllerId())).isPresent();
|
||||
assertThat(deploymentManagement.getInstalledDistributionSet(tA.getControllerId())).isNotPresent();
|
||||
assertThat(deploymentManagement.findAssignedDistributionSet(tA.getControllerId())).isPresent();
|
||||
assertThat(deploymentManagement.findInstalledDistributionSet(tA.getControllerId())).isNotPresent();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -619,7 +619,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId))
|
||||
.andExpect(status().isOk());
|
||||
|
||||
assertThat(targetManagement.getByControllerId(knownControllerId)).isNotPresent();
|
||||
assertThat(targetManagement.findByControllerId(knownControllerId)).isNotPresent();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -667,9 +667,10 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("$.description", equalTo(knownNewDescription)))
|
||||
.andExpect(jsonPath("$.name", equalTo(knownNameNotModify)));
|
||||
|
||||
final Target findTargetByControllerID = targetManagement.getByControllerId(knownControllerId).get();
|
||||
assertThat(findTargetByControllerID.getDescription()).isEqualTo(knownNewDescription);
|
||||
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModify);
|
||||
assertThat(targetManagement.getByControllerId(knownControllerId)).satisfies(findTargetByControllerID -> {
|
||||
assertThat(findTargetByControllerID.getDescription()).isEqualTo(knownNewDescription);
|
||||
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModify);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -691,8 +692,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
final Target findTargetByControllerID = targetManagement.getByControllerId(knownControllerId).get();
|
||||
assertThat(findTargetByControllerID.getDescription()).isEqualTo("old description");
|
||||
assertThat(targetManagement.getByControllerId(knownControllerId).getDescription()).isEqualTo("old description");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -716,9 +716,10 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("$.securityToken", equalTo(knownNewToken)))
|
||||
.andExpect(jsonPath("$.name", equalTo(knownNameNotModify)));
|
||||
|
||||
final Target findTargetByControllerID = targetManagement.getByControllerId(knownControllerId).get();
|
||||
assertThat(findTargetByControllerID.getSecurityToken()).isEqualTo(knownNewToken);
|
||||
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModify);
|
||||
assertThat(targetManagement.getByControllerId(knownControllerId)).satisfies(findTargetByControllerID -> {
|
||||
assertThat(findTargetByControllerID.getSecurityToken()).isEqualTo(knownNewToken);
|
||||
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModify);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -742,9 +743,10 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("$.address", equalTo(knownNewAddress)))
|
||||
.andExpect(jsonPath("$.name", equalTo(knownNameNotModify)));
|
||||
|
||||
final Target findTargetByControllerID = targetManagement.getByControllerId(knownControllerId).get();
|
||||
assertThat(findTargetByControllerID.getAddress()).hasToString(knownNewAddress);
|
||||
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModify);
|
||||
assertThat(targetManagement.getByControllerId(knownControllerId)).satisfies(findTargetByControllerID -> {
|
||||
assertThat(findTargetByControllerID.getAddress()).hasToString(knownNewAddress);
|
||||
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModify);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1027,7 +1029,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("[0].controllerId", equalTo(randomString)))
|
||||
.andExpect(jsonPath("[0].name", equalTo(expectedTargetName)));
|
||||
|
||||
assertThat(targetManagement.getByControllerId(randomString).get().getName()).isEqualTo(expectedTargetName);
|
||||
assertThat(targetManagement.getByControllerId(randomString).getName()).isEqualTo(expectedTargetName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1638,8 +1640,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("total", equalTo(1)));
|
||||
implicitLock(set);
|
||||
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
||||
target = targetManagement.getByControllerId(target.getControllerId()).get();
|
||||
assertThat(deploymentManagement.findAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
||||
target = targetManagement.getByControllerId(target.getControllerId());
|
||||
|
||||
// repeating DS assignment leads again to OK
|
||||
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS")
|
||||
@@ -1651,7 +1653,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("total", equalTo(1)));
|
||||
|
||||
// ...but does not change the target
|
||||
assertThat(targetManagement.getByControllerId(target.getControllerId()).get()).isEqualTo(target);
|
||||
assertThat(targetManagement.findByControllerId(target.getControllerId()).get()).isEqualTo(target);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1683,7 +1685,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("total", equalTo(1)));
|
||||
implicitLock(set);
|
||||
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
||||
assertThat(deploymentManagement.findAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
||||
|
||||
assertThat(
|
||||
actionRepository
|
||||
@@ -1716,7 +1718,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("total", equalTo(1)));
|
||||
implicitLock(set);
|
||||
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
||||
assertThat(deploymentManagement.findAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
||||
final Slice<Action> actions = deploymentManagement.findActionsByTarget("targetExist", PageRequest.of(0, 100));
|
||||
assertThat(actions).isNotEmpty().filteredOn(a -> a.getDistributionSet().equals(set))
|
||||
.extracting(Action::getActionType).containsOnly(ActionType.DOWNLOAD_ONLY);
|
||||
@@ -1741,9 +1743,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("total", equalTo(1)));
|
||||
implicitLock(set);
|
||||
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
||||
assertThat(deploymentManagement.getInstalledDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
||||
target = targetManagement.getByControllerId(target.getControllerId()).get();
|
||||
assertThat(deploymentManagement.findAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
||||
assertThat(deploymentManagement.findInstalledDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
||||
target = targetManagement.getByControllerId(target.getControllerId());
|
||||
assertThat(target.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
// repeating DS assignment leads again to OK
|
||||
@@ -1757,7 +1759,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("total", equalTo(1)));
|
||||
|
||||
// ...but does not change the target
|
||||
assertThat(targetManagement.getByControllerId(target.getControllerId()).get()).isEqualTo(target);
|
||||
assertThat(targetManagement.getByControllerId(target.getControllerId())).isEqualTo(target);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1780,7 +1782,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
assertThat(findActiveActionsByTarget).hasSize(1);
|
||||
assertThat(findActiveActionsByTarget.get(0).getActionType()).isEqualTo(ActionType.TIMEFORCED);
|
||||
assertThat(findActiveActionsByTarget.get(0).getForcedTime()).isEqualTo(forceTime);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("fsdfsd").get()).isEqualTo(set);
|
||||
assertThat(deploymentManagement.findAssignedDistributionSet("fsdfsd").get()).isEqualTo(set);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2038,7 +2040,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
knownControllerAttrs.put("b.2", "2");
|
||||
testdataFactory.createTarget(knownTargetId);
|
||||
controllerManagement.updateControllerAttributes(knownTargetId, knownControllerAttrs, null);
|
||||
assertThat(targetManagement.getByControllerId(knownTargetId).orElseThrow().isRequestControllerAttributes()).isFalse();
|
||||
assertThat(targetManagement.getByControllerId(knownTargetId).isRequestControllerAttributes()).isFalse();
|
||||
|
||||
verifyAttributeUpdateCanBeRequested(knownTargetId);
|
||||
verifyRequestAttributesAttributeIsOptional(knownTargetId);
|
||||
@@ -2539,8 +2541,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("[0].controllerId", equalTo("targetcontroller")))
|
||||
.andExpect(jsonPath("[0].targetType", equalTo(targetTypes.get(0).getId().intValue())));
|
||||
|
||||
assertThat(targetManagement.getByControllerId("targetcontroller").get().getTargetType().getId())
|
||||
.isEqualTo(targetTypes.get(0).getId());
|
||||
assertThat(targetManagement.getByControllerId("targetcontroller").getTargetType().getId()).isEqualTo(targetTypes.get(0).getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2610,8 +2611,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk());
|
||||
|
||||
assertThat(targetManagement.getByControllerId(targetControllerId).get().getTargetType().getId())
|
||||
.isEqualTo(targetType.getId());
|
||||
assertThat(targetManagement.getByControllerId(targetControllerId).getTargetType().getId()).isEqualTo(targetType.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2669,7 +2669,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk());
|
||||
|
||||
assertThat(targetManagement.getByControllerId(targetControllerId).get().getTargetType()).isNull();
|
||||
assertThat(targetManagement.getByControllerId(targetControllerId).getTargetType()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -2873,12 +2873,11 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
}
|
||||
|
||||
private Target assertTarget(final String controllerId, final String name, final String description) {
|
||||
final Optional<Target> target1 = targetManagement.getByControllerId(controllerId);
|
||||
assertThat(target1).isPresent();
|
||||
final Target t = target1.get();
|
||||
assertThat(t.getName()).isEqualTo(name);
|
||||
assertThat(t.getDescription()).isEqualTo(description);
|
||||
return t;
|
||||
final Target target = targetManagement.getByControllerId(controllerId);
|
||||
assertThat(target).isNotNull();
|
||||
assertThat(target.getName()).isEqualTo(name);
|
||||
assertThat(target.getDescription()).isEqualTo(description);
|
||||
return target;
|
||||
}
|
||||
|
||||
private void getActions(final boolean withExternalRef) throws Exception {
|
||||
@@ -2986,7 +2985,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk());
|
||||
|
||||
assertThat(targetManagement.getByControllerId(knownTargetId).orElseThrow().isRequestControllerAttributes()).isTrue();
|
||||
assertThat(targetManagement.getByControllerId(knownTargetId).isRequestControllerAttributes()).isTrue();
|
||||
}
|
||||
|
||||
private void verifyRequestAttributesAttributeIsOptional(final String knownTargetId) throws Exception {
|
||||
@@ -3006,7 +3005,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
assertThat(targetManagement.getByControllerId(knownTargetId).orElseThrow().isRequestControllerAttributes()).isTrue();
|
||||
assertThat(targetManagement.getByControllerId(knownTargetId).isRequestControllerAttributes()).isTrue();
|
||||
}
|
||||
|
||||
private String getCreateTargetsListJsonString(final String controllerId, final String name, final String description) {
|
||||
@@ -3048,7 +3047,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
// verify active action
|
||||
final Slice<Action> actionsByTarget = deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE);
|
||||
assertThat(actionsByTarget.getContent()).hasSize(1);
|
||||
return targetManagement.getByControllerId(tA.getControllerId()).get();
|
||||
return targetManagement.getByControllerId(tA.getControllerId());
|
||||
}
|
||||
|
||||
private void setupTargetWithMetadata(final String knownControllerId, final String knownKey, final String knownValue) {
|
||||
|
||||
@@ -722,7 +722,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
|
||||
for (int index = 0; index < size; index++) {
|
||||
String name = "TestTypePOST" + index;
|
||||
final TargetType created = targetTypeManagement.getByName(name).get();
|
||||
final TargetType created = findTargetTypeByName(name);
|
||||
|
||||
assertThat(JsonPath.compile("$[ ?(@.name=='" + name + "') ].id")
|
||||
.read(mvcResult.getResponse().getContentAsString()).toString()).contains(String.valueOf(created.getId()));
|
||||
|
||||
Reference in New Issue
Block a user