[#1509] Sync Target type with SW and DS types (REST Layer) (#1514)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2023-12-13 14:33:32 +02:00
committed by GitHub
parent 4b5a7d6e7d
commit 767a7e6b11
11 changed files with 117 additions and 154 deletions

View File

@@ -1399,8 +1399,9 @@ public class TestdataFactory {
*/ */
public TargetType findOrCreateTargetType(final String targetTypeName) { public TargetType findOrCreateTargetType(final String targetTypeName) {
return targetTypeManagement.getByName(targetTypeName) return targetTypeManagement.getByName(targetTypeName)
.orElseGet(() -> targetTypeManagement.create(entityFactory.targetType().create().name(targetTypeName) .orElseGet(() -> targetTypeManagement.create(entityFactory.targetType().create()
.description(targetTypeName + " description").colour(DEFAULT_COLOUR))); .name(targetTypeName).description(targetTypeName + " description")
.key(targetTypeName + " key").colour(DEFAULT_COLOUR)));
} }
/** /**
@@ -1431,8 +1432,9 @@ public class TestdataFactory {
public List<TargetType> createTargetTypes(final String targetTypePrefix, final int count) { public List<TargetType> createTargetTypes(final String targetTypePrefix, final int count) {
final List<TargetTypeCreate> result = Lists.newArrayListWithExpectedSize(count); final List<TargetTypeCreate> result = Lists.newArrayListWithExpectedSize(count);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
result.add(entityFactory.targetType().create().name(targetTypePrefix + i) result.add(entityFactory.targetType().create()
.description(targetTypePrefix + " description").colour(DEFAULT_COLOUR)); .name(targetTypePrefix + i).description(targetTypePrefix + " description")
.key(targetTypePrefix + i + " key").colour(DEFAULT_COLOUR));
} }
return targetTypeManagement.create(result); return targetTypeManagement.create(result);
} }

View File

@@ -0,0 +1,56 @@
/**
* Copyright (c) 2023 Bosch.IO GmbH and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.hawkbit.mgmt.json.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* A json annotated rest model for Type to RESTful API representation.
*
*/
public abstract class MgmtTypeEntity extends MgmtNamedEntity {
@JsonProperty(required = true)
@Schema(example = "id.t23")
private String key;
@JsonProperty
@Schema(example = "brown")
private String colour;
@JsonProperty
@Schema(example = "false")
private boolean deleted;
public String getKey() {
return key;
}
public void setKey(final String key) {
this.key = key;
}
public String getColour() {
return colour;
}
public void setColour(String colour) {
this.colour = colour;
}
public boolean isDeleted() {
return deleted;
}
public void setDeleted(final boolean deleted) {
this.deleted = deleted;
}
}

View File

@@ -10,49 +10,25 @@
package org.eclipse.hawkbit.mgmt.json.model.distributionsettype; package org.eclipse.hawkbit.mgmt.json.model.distributionsettype;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.eclipse.hawkbit.mgmt.json.model.MgmtTypeEntity;
/** /**
* A json annotated rest model for SoftwareModuleType to RESTful API * A json annotated rest model for SoftwareModuleType to RESTful API
* representation. * representation.
*
*
*
*
*/ */
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtDistributionSetType extends MgmtNamedEntity { public class MgmtDistributionSetType extends MgmtTypeEntity {
@JsonProperty(value = "id", required = true) @JsonProperty(value = "id", required = true)
@Schema(example = "99") @Schema(example = "99")
private Long moduleId; private Long moduleId;
@JsonProperty(required = true)
@Schema(example = "os_app")
private String key;
@JsonProperty
@Schema(example = "false")
private boolean deleted;
@JsonProperty
@Schema(example = "black")
private String colour;
public boolean isDeleted() {
return deleted;
}
public void setDeleted(final boolean deleted) {
this.deleted = deleted;
}
/** /**
* @return the moduleId * @return the moduleId
*/ */
@@ -67,35 +43,4 @@ public class MgmtDistributionSetType extends MgmtNamedEntity {
public void setModuleId(final Long moduleId) { public void setModuleId(final Long moduleId) {
this.moduleId = moduleId; this.moduleId = moduleId;
} }
/**
* @return the key
*/
public String getKey() {
return key;
}
/**
* @param key
* the key to set
*/
public void setKey(final String key) {
this.key = key;
}
/**
* @return the colour
*/
public String getColour() {
return colour;
}
/**
* @param colour
* the colour to set
*/
public void setColour(String colour) {
this.colour = colour;
}
} }

View File

@@ -10,50 +10,29 @@
package org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype; package org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.eclipse.hawkbit.mgmt.json.model.MgmtTypeEntity;
/** /**
* A json annotated rest model for SoftwareModuleType to RESTful API * A json annotated rest model for SoftwareModuleType to RESTful API
* representation. * representation.
*
*/ */
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtSoftwareModuleType extends MgmtNamedEntity { public class MgmtSoftwareModuleType extends MgmtTypeEntity {
@JsonProperty(value = "id", required = true) @JsonProperty(value = "id", required = true)
@Schema(example = "83") @Schema(example = "83")
private Long moduleId; private Long moduleId;
@JsonProperty(required = true)
@Schema(example = "OS")
private String key;
@JsonProperty @JsonProperty
@Schema(example = "1") @Schema(example = "1")
private int maxAssignments; private int maxAssignments;
@JsonProperty
@Schema(example = "false")
private boolean deleted;
@JsonProperty
@Schema(example = "brown")
private String colour;
public boolean isDeleted() {
return deleted;
}
public void setDeleted(final boolean deleted) {
this.deleted = deleted;
}
public Long getModuleId() { public Long getModuleId() {
return moduleId; return moduleId;
} }
@@ -62,14 +41,6 @@ public class MgmtSoftwareModuleType extends MgmtNamedEntity {
this.moduleId = moduleId; this.moduleId = moduleId;
} }
public String getKey() {
return key;
}
public void setKey(final String key) {
this.key = key;
}
public int getMaxAssignments() { public int getMaxAssignments() {
return maxAssignments; return maxAssignments;
} }
@@ -77,12 +48,4 @@ public class MgmtSoftwareModuleType extends MgmtNamedEntity {
public void setMaxAssignments(final int maxAssignments) { public void setMaxAssignments(final int maxAssignments) {
this.maxAssignments = maxAssignments; this.maxAssignments = maxAssignments;
} }
public String getColour() {
return colour;
}
public void setColour(String colour) {
this.colour = colour;
}
} }

View File

@@ -13,25 +13,20 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; import org.eclipse.hawkbit.mgmt.json.model.MgmtTypeEntity;
/** /**
* A json annotated rest model for TargetType to RESTful API * A json annotated rest model for TargetType to RESTful API
* representation. * representation.
*
*/ */
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtTargetType extends MgmtNamedEntity { public class MgmtTargetType extends MgmtTypeEntity {
@JsonProperty(value = "id", required = true) @JsonProperty(value = "id", required = true)
@Schema(example = "26") @Schema(example = "26")
private Long typeId; private Long typeId;
@JsonProperty
@Schema(example = "rgb(255,255,255")
private String colour;
/** /**
* @return target type ID * @return target type ID
*/ */
@@ -46,20 +41,4 @@ public class MgmtTargetType extends MgmtNamedEntity {
public void setTypeId(final Long typeId) { public void setTypeId(final Long typeId) {
this.typeId = typeId; this.typeId = typeId;
} }
/**
*
* @return the colour
*/
public String getColour() {
return colour;
}
/**
* @param colour
* the colour to set
*/
public void setColour(String colour) {
this.colour = colour;
}
} }

View File

@@ -12,6 +12,7 @@ package org.eclipse.hawkbit.mgmt.json.model.targettype;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeAssignment; import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeAssignment;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost; import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssigment; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssigment;
@@ -20,7 +21,11 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModule
* Request Body for TargetType POST. * Request Body for TargetType POST.
* *
*/ */
public class MgmtTargetTypeRequestBodyPost extends MgmtTargetTypeRequestBodyPut{ public class MgmtTargetTypeRequestBodyPost extends MgmtTargetTypeRequestBodyPut {
@JsonProperty
@Schema(example = "id.t23")
private String key;
@JsonProperty @JsonProperty
private List<MgmtDistributionSetTypeAssignment> compatibledistributionsettypes; private List<MgmtDistributionSetTypeAssignment> compatibledistributionsettypes;
@@ -42,6 +47,15 @@ public class MgmtTargetTypeRequestBodyPost extends MgmtTargetTypeRequestBodyPut{
return this; return this;
} }
public MgmtTargetTypeRequestBodyPost setKey(final String key) {
this.key = key;
return this;
}
public String getKey() {
return key;
}
@Override @Override
public MgmtTargetTypeRequestBodyPost setColour(final String colour) { public MgmtTargetTypeRequestBodyPost setColour(final String colour) {
super.setColour(colour); super.setColour(colour);

View File

@@ -80,11 +80,8 @@ final class MgmtDistributionSetTypeMapper {
static MgmtDistributionSetType toResponse(final DistributionSetType type) { static MgmtDistributionSetType toResponse(final DistributionSetType type) {
final MgmtDistributionSetType result = new MgmtDistributionSetType(); final MgmtDistributionSetType result = new MgmtDistributionSetType();
MgmtRestModelMapper.mapNamedToNamed(result, type); MgmtRestModelMapper.mapTypeToType(result, type);
result.setKey(type.getKey());
result.setModuleId(type.getId()); result.setModuleId(type.getId());
result.setDeleted(type.isDeleted());
result.setColour(type.getColour());
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(result.getModuleId())) result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(result.getModuleId()))
.withSelfRel().expand()); .withSelfRel().expand());

View File

@@ -11,12 +11,14 @@ package org.eclipse.hawkbit.mgmt.rest.resource;
import org.eclipse.hawkbit.mgmt.json.model.MgmtBaseEntity; import org.eclipse.hawkbit.mgmt.json.model.MgmtBaseEntity;
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
import org.eclipse.hawkbit.mgmt.json.model.MgmtTypeEntity;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtCancelationType; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtCancelationType;
import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.DistributionSetInvalidation.CancelationType; import org.eclipse.hawkbit.repository.model.DistributionSetInvalidation.CancelationType;
import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity; import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
import org.eclipse.hawkbit.repository.model.Type;
/** /**
* A mapper which maps repository model to RESTful model representation and * A mapper which maps repository model to RESTful model representation and
@@ -48,6 +50,14 @@ public final class MgmtRestModelMapper {
response.setDescription(base.getDescription()); response.setDescription(base.getDescription());
} }
static void mapTypeToType(final MgmtTypeEntity response, final Type base) {
mapNamedToNamed(response, base);
response.setKey(base.getKey());
response.setColour(base.getColour());
response.setDeleted(base.isDeleted());
}
/** /**
* Convert the given {@link MgmtActionType} into a corresponding repository * Convert the given {@link MgmtActionType} into a corresponding repository
* {@link ActionType}. * {@link ActionType}.

View File

@@ -65,12 +65,9 @@ final class MgmtSoftwareModuleTypeMapper {
static MgmtSoftwareModuleType toResponse(final SoftwareModuleType type) { static MgmtSoftwareModuleType toResponse(final SoftwareModuleType type) {
final MgmtSoftwareModuleType result = new MgmtSoftwareModuleType(); final MgmtSoftwareModuleType result = new MgmtSoftwareModuleType();
MgmtRestModelMapper.mapNamedToNamed(result, type); MgmtRestModelMapper.mapTypeToType(result, type);
result.setKey(type.getKey());
result.setMaxAssignments(type.getMaxAssignments()); result.setMaxAssignments(type.getMaxAssignments());
result.setModuleId(type.getId()); result.setModuleId(type.getId());
result.setDeleted(type.isDeleted());
result.setColour(type.getColour());
result.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getModuleId())) result.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getModuleId()))
.withSelfRel().expand()); .withSelfRel().expand());

View File

@@ -29,9 +29,7 @@ import org.eclipse.hawkbit.repository.model.TargetType;
import org.eclipse.hawkbit.rest.data.ResponseList; import org.eclipse.hawkbit.rest.data.ResponseList;
/** /**
* A mapper which maps repository model to RESTful model representation and * A mapper which maps repository model to RESTful model representation and back.
* back.
*
*/ */
public final class MgmtTargetTypeMapper { public final class MgmtTargetTypeMapper {
@@ -50,8 +48,9 @@ public final class MgmtTargetTypeMapper {
private static TargetTypeCreate fromRequest(final EntityFactory entityFactory, private static TargetTypeCreate fromRequest(final EntityFactory entityFactory,
final MgmtTargetTypeRequestBodyPost targetTypesRest) { final MgmtTargetTypeRequestBodyPost targetTypesRest) {
return entityFactory.targetType().create().name(targetTypesRest.getName()) return entityFactory.targetType().create()
.description(targetTypesRest.getDescription()).colour(targetTypesRest.getColour()) .name(targetTypesRest.getName()).description(targetTypesRest.getDescription())
.key(targetTypesRest.getKey()).colour(targetTypesRest.getColour())
.compatible(getDistributionSets(targetTypesRest)); .compatible(getDistributionSets(targetTypesRest));
} }
@@ -70,9 +69,9 @@ public final class MgmtTargetTypeMapper {
static MgmtTargetType toResponse(final TargetType type) { static MgmtTargetType toResponse(final TargetType type) {
final MgmtTargetType result = new MgmtTargetType(); final MgmtTargetType result = new MgmtTargetType();
MgmtRestModelMapper.mapNamedToNamed(result, type);
MgmtRestModelMapper.mapTypeToType(result, type);
result.setTypeId(type.getId()); result.setTypeId(type.getId());
result.setColour(type.getColour());
result.add( result.add(
linkTo(methodOn(MgmtTargetTypeRestApi.class).getTargetType(result.getTypeId())).withSelfRel().expand()); linkTo(methodOn(MgmtTargetTypeRestApi.class).getTargetType(result.getTypeId())).withSelfRel().expand());
return result; return result;

View File

@@ -98,8 +98,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("$.lastModifiedBy", equalTo(TEST_USER))) .andExpect(jsonPath("$.lastModifiedBy", equalTo(TEST_USER)))
.andExpect(jsonPath("$.lastModifiedAt", equalTo(testType.getLastModifiedAt()))) .andExpect(jsonPath("$.lastModifiedAt", equalTo(testType.getLastModifiedAt())))
.andExpect(jsonPath("$._links.self.href", equalTo("http://localhost/rest/v1/targettypes/" + typeId))) .andExpect(jsonPath("$._links.self.href", equalTo("http://localhost/rest/v1/targettypes/" + typeId)))
.andExpect(jsonPath("$.deleted").doesNotExist()) .andExpect(jsonPath("$.deleted", equalTo(false)))
.andExpect(jsonPath("$.key").doesNotExist()) .andExpect(jsonPath("$.key", equalTo(typeName + " key")))
.andExpect(jsonPath("$._links.compatibledistributionsettypes.href", .andExpect(jsonPath("$._links.compatibledistributionsettypes.href",
equalTo("http://localhost/rest/v1/targettypes/" + typeId + "/compatibledistributionsettypes"))); equalTo("http://localhost/rest/v1/targettypes/" + typeId + "/compatibledistributionsettypes")));
} }
@@ -129,8 +129,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].lastModifiedBy", contains(TEST_USER))) .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].lastModifiedBy", contains(TEST_USER)))
.andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].lastModifiedAt", .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].lastModifiedAt",
contains(testTypes.get(index).getLastModifiedAt()))) contains(testTypes.get(index).getLastModifiedAt())))
.andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].deleted").doesNotExist()) .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].deleted", contains(false)))
.andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].key").doesNotExist()) .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].key", contains(typeName + index + " key")))
.andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')]._links.self.href", .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')]._links.self.href",
contains("http://localhost/rest/v1/targettypes/" + typeId))) contains("http://localhost/rest/v1/targettypes/" + typeId)))
.andExpect( .andExpect(
@@ -179,8 +179,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("$.content.[0].createdAt", equalTo(testTypeC.getCreatedAt()))) .andExpect(jsonPath("$.content.[0].createdAt", equalTo(testTypeC.getCreatedAt())))
.andExpect(jsonPath("$.content.[0].lastModifiedBy", equalTo(TEST_USER))) .andExpect(jsonPath("$.content.[0].lastModifiedBy", equalTo(TEST_USER)))
.andExpect(jsonPath("$.content.[0].lastModifiedAt", equalTo(testTypeC.getLastModifiedAt()))) .andExpect(jsonPath("$.content.[0].lastModifiedAt", equalTo(testTypeC.getLastModifiedAt())))
.andExpect(jsonPath("$.content.[0].deleted").doesNotExist()) .andExpect(jsonPath("$.content.[0].deleted", equalTo(false)))
.andExpect(jsonPath("$.content.[0].key").doesNotExist()) .andExpect(jsonPath("$.content.[0].key", equalTo(typeNameC + " key")))
.andExpect(jsonPath("$.content.[0]._links.self.href", .andExpect(jsonPath("$.content.[0]._links.self.href",
equalTo("http://localhost/rest/v1/targettypes/" + testTypeC.getId()))) equalTo("http://localhost/rest/v1/targettypes/" + testTypeC.getId())))
.andExpect(jsonPath("$.content.[0]._links.compatibledistributionsettypes.href").doesNotExist()) .andExpect(jsonPath("$.content.[0]._links.compatibledistributionsettypes.href").doesNotExist())
@@ -200,8 +200,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("$.content.[0].createdAt", equalTo(testTypeA.getCreatedAt()))) .andExpect(jsonPath("$.content.[0].createdAt", equalTo(testTypeA.getCreatedAt())))
.andExpect(jsonPath("$.content.[0].lastModifiedBy", equalTo(TEST_USER))) .andExpect(jsonPath("$.content.[0].lastModifiedBy", equalTo(TEST_USER)))
.andExpect(jsonPath("$.content.[0].lastModifiedAt", equalTo(testTypeA.getLastModifiedAt()))) .andExpect(jsonPath("$.content.[0].lastModifiedAt", equalTo(testTypeA.getLastModifiedAt())))
.andExpect(jsonPath("$.content.[0].deleted").doesNotExist()) .andExpect(jsonPath("$.content.[0].deleted", equalTo(false)))
.andExpect(jsonPath("$.content.[0].key").doesNotExist()) .andExpect(jsonPath("$.content.[0].key", equalTo(typeNameA + " key")))
.andExpect(jsonPath("$.content.[0]._links.self.href", .andExpect(jsonPath("$.content.[0]._links.self.href",
equalTo("http://localhost/rest/v1/targettypes/" + testTypeA.getId()))) equalTo("http://localhost/rest/v1/targettypes/" + testTypeA.getId())))
.andExpect(jsonPath("$.content.[0]._links.compatibledistributionsettypes.href").doesNotExist()) .andExpect(jsonPath("$.content.[0]._links.compatibledistributionsettypes.href").doesNotExist())
@@ -268,8 +268,9 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
@WithUser(principal = TEST_USER, allSpPermissions = true) @WithUser(principal = TEST_USER, allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/targettypes/{id} GET requests.") @Description("Checks the correct behaviour of /rest/v1/targettypes/{id} GET requests.")
void getUpdatedTargetType() throws Exception { void getUpdatedTargetType() throws Exception {
TargetType testType = createTestTargetTypeInDB("TestTypeGET"); final String initialTypeName = "TestTypeGET";
String typeNameUpdated = "TestTypeGETupdated"; TargetType testType = createTestTargetTypeInDB(initialTypeName);
final String typeNameUpdated = "TestTypeGETupdated";
testType = targetTypeManagement.update(entityFactory.targetType().update(testType.getId()).name(typeNameUpdated) testType = targetTypeManagement.update(entityFactory.targetType().update(testType.getId()).name(typeNameUpdated)
.description("Updated Description").colour("#ffffff")); .description("Updated Description").colour("#ffffff"));
@@ -283,8 +284,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("$.createdAt", equalTo(testType.getCreatedAt()))) .andExpect(jsonPath("$.createdAt", equalTo(testType.getCreatedAt())))
.andExpect(jsonPath("$.lastModifiedBy", equalTo(TEST_USER))) .andExpect(jsonPath("$.lastModifiedBy", equalTo(TEST_USER)))
.andExpect(jsonPath("$.lastModifiedAt", equalTo(testType.getLastModifiedAt()))) .andExpect(jsonPath("$.lastModifiedAt", equalTo(testType.getLastModifiedAt())))
.andExpect(jsonPath("$.deleted").doesNotExist()) .andExpect(jsonPath("$.deleted", equalTo(false)))
.andExpect(jsonPath("$.key").doesNotExist()); .andExpect(jsonPath("$.key", equalTo(initialTypeName + " key")));
} }
@Test @Test
@@ -437,7 +438,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
put(TARGETTYPE_SINGLE_ENDPOINT, testType.getId()).content(body).contentType(MediaType.APPLICATION_JSON)) put(TARGETTYPE_SINGLE_ENDPOINT, testType.getId()).content(body).contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(jsonPath("$.id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$.id", equalTo(testType.getId().intValue())))
.andExpect(jsonPath("$.deleted").doesNotExist()); .andExpect(jsonPath("$.deleted", equalTo(false))); // don't delete with update
} }
@Test @Test
@@ -623,8 +624,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("$[" + index + "].createdAt").exists()) .andExpect(jsonPath("$[" + index + "].createdAt").exists())
.andExpect(jsonPath("$[" + index + "].lastModifiedBy", equalTo(TEST_USER))) .andExpect(jsonPath("$[" + index + "].lastModifiedBy", equalTo(TEST_USER)))
.andExpect(jsonPath("$[" + index + "].lastModifiedAt").exists()) .andExpect(jsonPath("$[" + index + "].lastModifiedAt").exists())
.andExpect(jsonPath("$[" + index + "].key").doesNotExist()) .andExpect(jsonPath("$[" + index + "].deleted", equalTo(false)))
.andExpect(jsonPath("$[" + index + "].deleted").doesNotExist()) .andExpect(jsonPath("$[" + index + "].key", startsWith("TestTypePOST")))
.andExpect(jsonPath("$[" + index + "]._links.self.href", .andExpect(jsonPath("$[" + index + "]._links.self.href",
startsWith("http://localhost/rest/v1/targettypes/"))) startsWith("http://localhost/rest/v1/targettypes/")))
.andExpect( .andExpect(