Merge branch 'fix_wrong_error_response' of https://github.com/bsinno/hawkbit.git into fix_wrong_error_response
This commit is contained in:
@@ -24,6 +24,7 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi;
|
|||||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi;
|
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi;
|
||||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.ConstraintViolationException;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||||
@@ -43,6 +44,9 @@ public final class MgmtSoftwareModuleMapper {
|
|||||||
|
|
||||||
private static SoftwareModuleType getSoftwareModuleTypeFromKeyString(final String type,
|
private static SoftwareModuleType getSoftwareModuleTypeFromKeyString(final String type,
|
||||||
final SoftwareManagement softwareManagement) {
|
final SoftwareManagement softwareManagement) {
|
||||||
|
if (type == null) {
|
||||||
|
throw new ConstraintViolationException("type cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
final SoftwareModuleType smType = softwareManagement.findSoftwareModuleTypeByKey(type.trim());
|
final SoftwareModuleType smType = softwareManagement.findSoftwareModuleTypeByKey(type.trim());
|
||||||
|
|
||||||
|
|||||||
@@ -672,7 +672,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verfies that a mandatory properteis of new targets are validated as not null.")
|
@Description("Verfies that a mandatory properties of new targets are validated as not null.")
|
||||||
public void createTargetWithMissingMandatoryPropertyBadRequest() throws Exception {
|
public void createTargetWithMissingMandatoryPropertyBadRequest() throws Exception {
|
||||||
final Target test1 = entityFactory.generateTarget("id1", "token");
|
final Target test1 = entityFactory.generateTarget("id1", "token");
|
||||||
test1.setName(null);
|
test1.setName(null);
|
||||||
|
|||||||
@@ -31,7 +31,18 @@ public class ConstraintViolationException extends AbstractServerRtException {
|
|||||||
* thrown
|
* thrown
|
||||||
*/
|
*/
|
||||||
public ConstraintViolationException(final javax.validation.ConstraintViolationException ex) {
|
public ConstraintViolationException(final javax.validation.ConstraintViolationException ex) {
|
||||||
super(getExceptionMessage(ex), SpServerError.SP_REPO_CONSTRAINT_VIOLATION);
|
this(getExceptionMessage(ex));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link ConstraintViolationException} with the error code
|
||||||
|
* {@link SpServerError#SP_REPO_CONSTRAINT_VIOLATION}.
|
||||||
|
*
|
||||||
|
* @param msgText
|
||||||
|
* the message text for this exception
|
||||||
|
*/
|
||||||
|
public ConstraintViolationException(final String msgText) {
|
||||||
|
super(msgText, SpServerError.SP_REPO_CONSTRAINT_VIOLATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user