Remove TargetInfo entity (#453)
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -69,7 +69,7 @@ public final class MgmtTargetMapper {
|
||||
}
|
||||
|
||||
static void addPollStatus(final Target target, final MgmtTarget targetRest) {
|
||||
final PollStatus pollStatus = target.getTargetInfo().getPollStatus();
|
||||
final PollStatus pollStatus = target.getPollStatus();
|
||||
if (pollStatus != null) {
|
||||
final MgmtPollStatus pollStatusRest = new MgmtPollStatus();
|
||||
pollStatusRest.setLastRequestAt(
|
||||
@@ -111,9 +111,9 @@ public final class MgmtTargetMapper {
|
||||
targetRest.setControllerId(target.getControllerId());
|
||||
targetRest.setDescription(target.getDescription());
|
||||
targetRest.setName(target.getName());
|
||||
targetRest.setUpdateStatus(target.getTargetInfo().getUpdateStatus().name().toLowerCase());
|
||||
targetRest.setUpdateStatus(target.getUpdateStatus().name().toLowerCase());
|
||||
|
||||
final URI address = target.getTargetInfo().getAddress();
|
||||
final URI address = target.getAddress();
|
||||
if (address != null) {
|
||||
if (IpUtil.isIpAddresKnown(address)) {
|
||||
targetRest.setIpAddress(address.getHost());
|
||||
@@ -130,8 +130,8 @@ public final class MgmtTargetMapper {
|
||||
targetRest.setSecurityToken(target.getSecurityToken());
|
||||
|
||||
// last target query is the last controller request date
|
||||
final Long lastTargetQuery = target.getTargetInfo().getLastTargetQuery();
|
||||
final Long installationDate = target.getTargetInfo().getInstallationDate();
|
||||
final Long lastTargetQuery = target.getLastTargetQuery();
|
||||
final Long installationDate = target.getInstallationDate();
|
||||
|
||||
if (lastTargetQuery != null) {
|
||||
targetRest.setLastControllerRequestAt(lastTargetQuery);
|
||||
|
||||
@@ -137,8 +137,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
|
||||
@Override
|
||||
public ResponseEntity<MgmtTargetAttributes> getAttributes(@PathVariable("controllerId") final String controllerId) {
|
||||
final Target foundTarget = findTargetWithExceptionIfNotFound(controllerId);
|
||||
final Map<String, String> controllerAttributes = foundTarget.getTargetInfo().getControllerAttributes();
|
||||
final Map<String, String> controllerAttributes = targetManagement.getControllerAttributes(controllerId);
|
||||
if (controllerAttributes.isEmpty()) {
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
@@ -267,16 +266,13 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
@Override
|
||||
public ResponseEntity<MgmtDistributionSet> getAssignedDistributionSet(
|
||||
@PathVariable("controllerId") final String controllerId) {
|
||||
final Target findTarget = findTargetWithExceptionIfNotFound(controllerId);
|
||||
final MgmtDistributionSet distributionSetRest = MgmtDistributionSetMapper
|
||||
.toResponse(findTarget.getAssignedDistributionSet());
|
||||
final HttpStatus retStatus;
|
||||
final MgmtDistributionSet distributionSetRest = deploymentManagement.getAssignedDistributionSet(controllerId)
|
||||
.map(MgmtDistributionSetMapper::toResponse).orElse(null);
|
||||
|
||||
if (distributionSetRest == null) {
|
||||
retStatus = HttpStatus.NO_CONTENT;
|
||||
} else {
|
||||
retStatus = HttpStatus.OK;
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
return new ResponseEntity<>(distributionSetRest, retStatus);
|
||||
return new ResponseEntity<>(distributionSetRest, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,16 +298,13 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
@Override
|
||||
public ResponseEntity<MgmtDistributionSet> getInstalledDistributionSet(
|
||||
@PathVariable("controllerId") final String controllerId) {
|
||||
final Target findTarget = findTargetWithExceptionIfNotFound(controllerId);
|
||||
final MgmtDistributionSet distributionSetRest = MgmtDistributionSetMapper
|
||||
.toResponse(findTarget.getTargetInfo().getInstalledDistributionSet());
|
||||
final HttpStatus retStatus;
|
||||
final MgmtDistributionSet distributionSetRest = deploymentManagement.getInstalledDistributionSet(controllerId)
|
||||
.map(MgmtDistributionSetMapper::toResponse).orElse(null);
|
||||
|
||||
if (distributionSetRest == null) {
|
||||
retStatus = HttpStatus.NO_CONTENT;
|
||||
} else {
|
||||
retStatus = HttpStatus.OK;
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
return new ResponseEntity<>(distributionSetRest, retStatus);
|
||||
return new ResponseEntity<>(distributionSetRest, HttpStatus.OK);
|
||||
}
|
||||
|
||||
private Target findTargetWithExceptionIfNotFound(final String controllerId) {
|
||||
|
||||
@@ -833,8 +833,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
||||
mvc.perform(delete("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetMetadata(testDS.getId(), knownKey).isPresent())
|
||||
.isFalse();
|
||||
assertThat(distributionSetManagement.findDistributionSetMetadata(testDS.getId(), knownKey)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -853,8 +852,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
||||
mvc.perform(delete("/rest/v1/distributionsets/1234/metadata/{key}", knownKey))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetMetadata(testDS.getId(), knownKey).isPresent())
|
||||
.isTrue();
|
||||
assertThat(distributionSetManagement.findDistributionSetMetadata(testDS.getId(), knownKey)).isPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -301,8 +301,8 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
||||
.andExpect(jsonPath("$.distributionSetId", equalTo(dsA.getId().intValue())))
|
||||
.andExpect(jsonPath("$.createdBy", equalTo("bumlux")))
|
||||
.andExpect(jsonPath("$.createdAt", not(equalTo(0))))
|
||||
.andExpect(jsonPath("$.lastModifiedBy").doesNotExist())
|
||||
.andExpect(jsonPath("$.lastModifiedAt").doesNotExist())
|
||||
.andExpect(jsonPath("$.lastModifiedBy", equalTo("bumlux")))
|
||||
.andExpect(jsonPath("$.lastModifiedAt", not(equalTo(0))))
|
||||
.andExpect(jsonPath("$.totalTargets", equalTo(20)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.running", equalTo(0)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.notstarted", equalTo(20)))
|
||||
@@ -673,8 +673,8 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
||||
.andExpect(jsonPath("$.targetPercentage", equalTo(25.0)))
|
||||
.andExpect(jsonPath("$.createdBy", equalTo("bumlux")))
|
||||
.andExpect(jsonPath("$.createdAt", not(equalTo(0))))
|
||||
.andExpect(jsonPath("$.lastModifiedBy").doesNotExist())
|
||||
.andExpect(jsonPath("$.lastModifiedAt").doesNotExist())
|
||||
.andExpect(jsonPath("$.lastModifiedBy", equalTo("bumlux")))
|
||||
.andExpect(jsonPath("$.lastModifiedAt", not(equalTo(0))))
|
||||
.andExpect(jsonPath("$.totalTargets", equalTo(0)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.running", equalTo(0)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.notstarted", equalTo(0)))
|
||||
|
||||
@@ -237,8 +237,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
|
||||
|
||||
// hashes
|
||||
assertThat(artifactManagement.findArtifactByFilename("customFilename").isPresent())
|
||||
.as("Local artifact is wrong").isTrue();
|
||||
assertThat(artifactManagement.findArtifactByFilename("customFilename")).as("Local artifact is wrong")
|
||||
.isPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -868,7 +868,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
||||
mvc.perform(delete("/rest/v1/softwaremodules/{swId}/metadata/{key}", sm.getId(), knownKey))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
|
||||
assertThat(softwareManagement.findSoftwareModuleMetadata(sm.getId(), knownKey).isPresent()).isFalse();
|
||||
assertThat(softwareManagement.findSoftwareModuleMetadata(sm.getId(), knownKey)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -888,7 +888,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
||||
mvc.perform(delete("/rest/v1/softwaremodules/1234/metadata/{key}", knownKey))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
||||
|
||||
assertThat(softwareManagement.findSoftwareModuleMetadata(sm.getId(), knownKey).isPresent()).isTrue();
|
||||
assertThat(softwareManagement.findSoftwareModuleMetadata(sm.getId(), knownKey)).isPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -74,7 +74,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
||||
mvc.perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId()))
|
||||
.andExpect(status().isOk());
|
||||
|
||||
assertThat(targetFilterQueryManagement.findTargetFilterQueryById(filterQuery.getId()).isPresent()).isFalse();
|
||||
assertThat(targetFilterQueryManagement.findTargetFilterQueryById(filterQuery.getId())).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -222,21 +222,24 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
final Target tA = createTargetAndStartAction();
|
||||
|
||||
// test - cancel the active action
|
||||
mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}",
|
||||
tA.getControllerId(), tA.getActions().get(0).getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isNoContent());
|
||||
mvc.perform(
|
||||
delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}",
|
||||
tA.getControllerId(), deploymentManagement.findActionsByTarget(tA.getControllerId(), pageReq)
|
||||
.getContent().get(0).getId()))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNoContent());
|
||||
|
||||
final Action action = deploymentManagement.findAction(tA.getActions().get(0).getId()).get();
|
||||
final Action action = deploymentManagement.findAction(
|
||||
deploymentManagement.findActionsByTarget(tA.getControllerId(), pageReq).getContent().get(0).getId())
|
||||
.get();
|
||||
// still active because in "canceling" state and waiting for controller
|
||||
// feedback
|
||||
assertThat(action.isActive()).isTrue();
|
||||
|
||||
final Target queryTarget = targetManagement.findTargetByControllerID(tA.getControllerId()).get();
|
||||
// action has not been cancelled confirmed from controller, so DS
|
||||
// remains assigned until
|
||||
// confirmation
|
||||
assertThat(queryTarget.getAssignedDistributionSet()).isNotNull();
|
||||
assertThat(queryTarget.getTargetInfo().getInstalledDistributionSet()).isNull();
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(tA.getControllerId())).isPresent();
|
||||
assertThat(deploymentManagement.getInstalledDistributionSet(tA.getControllerId())).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -246,11 +249,12 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
final Target tA = createTargetAndStartAction();
|
||||
|
||||
// cancel the active action
|
||||
deploymentManagement.cancelAction(tA.getActions().get(0).getId());
|
||||
deploymentManagement.cancelAction(
|
||||
deploymentManagement.findActionsByTarget(tA.getControllerId(), pageReq).getContent().get(0).getId());
|
||||
|
||||
// find the current active action
|
||||
final List<Action> cancelActions = deploymentManagement.findActionsByTarget(tA.getControllerId(), pageReq)
|
||||
.getContent().stream().filter(action -> action.isCancelingOrCanceled()).collect(Collectors.toList());
|
||||
.getContent().stream().filter(Action::isCancelingOrCanceled).collect(Collectors.toList());
|
||||
assertThat(cancelActions).hasSize(1);
|
||||
|
||||
// test - cancel an cancel action returns forbidden
|
||||
@@ -266,7 +270,8 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
final Target tA = createTargetAndStartAction();
|
||||
|
||||
// cancel the active action
|
||||
deploymentManagement.cancelAction(tA.getActions().get(0).getId());
|
||||
deploymentManagement.cancelAction(
|
||||
deploymentManagement.findActionsByTarget(tA.getControllerId(), pageReq).getContent().get(0).getId());
|
||||
|
||||
// find the current active action
|
||||
final List<Action> cancelActions = deploymentManagement.findActionsByTarget(tA.getControllerId(), pageReq)
|
||||
@@ -287,9 +292,11 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
final Target tA = createTargetAndStartAction();
|
||||
|
||||
// test - cancel an cancel action returns forbidden
|
||||
mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}?force=true",
|
||||
tA.getControllerId(), tA.getActions().get(0).getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isMethodNotAllowed());
|
||||
mvc.perform(
|
||||
delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}?force=true",
|
||||
tA.getControllerId(), deploymentManagement.findActionsByTarget(tA.getControllerId(), pageReq)
|
||||
.getContent().get(0).getId()))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -301,7 +308,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId))
|
||||
.andExpect(status().isOk());
|
||||
|
||||
assertThat(targetManagement.findTargetByControllerID(knownControllerId).isPresent()).isFalse();
|
||||
assertThat(targetManagement.findTargetByControllerID(knownControllerId)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -387,7 +394,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
.andExpect(jsonPath("$.name", equalTo(knownNameNotModiy)));
|
||||
|
||||
final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownControllerId).get();
|
||||
assertThat(findTargetByControllerID.getTargetInfo().getAddress().toString()).isEqualTo(knownNewAddress);
|
||||
assertThat(findTargetByControllerID.getAddress().toString()).isEqualTo(knownNewAddress);
|
||||
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModiy);
|
||||
}
|
||||
|
||||
@@ -518,7 +525,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
.andExpect(jsonPath(JSON_PATH_NAME, equalTo(knownName)))
|
||||
.andExpect(jsonPath(JSON_PATH_CONTROLLERID, equalTo(knownControllerId)))
|
||||
.andExpect(jsonPath(JSON_PATH_DESCRIPTION, equalTo(TARGET_DESCRIPTION_TEST)))
|
||||
.andExpect(jsonPath(JSON_PATH_LAST_REQUEST_AT, equalTo(target.getTargetInfo().getLastTargetQuery())))
|
||||
.andExpect(jsonPath(JSON_PATH_LAST_REQUEST_AT, equalTo(target.getLastTargetQuery())))
|
||||
.andExpect(jsonPath("$.pollStatus", hasKey("lastRequestAt")))
|
||||
.andExpect(jsonPath("$.pollStatus", hasKey("nextExpectedRequestAt")))
|
||||
.andExpect(jsonPath("$.pollStatus.overdue", equalTo(false)))
|
||||
@@ -749,7 +756,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
assertThat(targetManagement.findTargetByControllerID("id1").get().getName()).isEqualTo("testname1");
|
||||
assertThat(targetManagement.findTargetByControllerID("id1").get().getDescription()).isEqualTo("testid1");
|
||||
assertThat(targetManagement.findTargetByControllerID("id1").get().getSecurityToken()).isEqualTo("token");
|
||||
assertThat(targetManagement.findTargetByControllerID("id1").get().getTargetInfo().getAddress().toString())
|
||||
assertThat(targetManagement.findTargetByControllerID("id1").get().getAddress().toString())
|
||||
.isEqualTo("amqp://test123/foobar");
|
||||
assertThat(targetManagement.findTargetByControllerID("id2")).isNotNull();
|
||||
assertThat(targetManagement.findTargetByControllerID("id2").get().getName()).isEqualTo("testname2");
|
||||
@@ -1078,8 +1085,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
|
||||
assertThat(targetManagement.findTargetByControllerID("fsdfsd").get().getAssignedDistributionSet())
|
||||
.isEqualTo(set);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("fsdfsd").get()).isEqualTo(set);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1101,8 +1107,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
assertThat(findActiveActionsByTarget).hasSize(1);
|
||||
assertThat(findActiveActionsByTarget.get(0).getActionType()).isEqualTo(ActionType.TIMEFORCED);
|
||||
assertThat(findActiveActionsByTarget.get(0).getForcedTime()).isEqualTo(forceTime);
|
||||
assertThat(targetManagement.findTargetByControllerID("fsdfsd").get().getAssignedDistributionSet())
|
||||
.isEqualTo(set);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("fsdfsd").get()).isEqualTo(set);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user