Skip to content

Commit

Permalink
Fixed tests on release-1.x
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Feb 3, 2023
1 parent 8a79194 commit da545d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
import org.eclipse.kapua.commons.security.KapuaSecurityUtils;
import org.eclipse.kapua.commons.util.ArgumentValidator;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.model.KapuaEntity;
import org.eclipse.kapua.model.KapuaEntityAttributes;
import org.eclipse.kapua.model.KapuaUpdatableEntity;
import org.eclipse.kapua.model.domain.Actions;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.model.query.KapuaQuery;
import org.eclipse.kapua.service.authorization.AuthorizationService;
import org.eclipse.kapua.service.authorization.group.Group;
import org.eclipse.kapua.service.authorization.group.GroupService;
import org.eclipse.kapua.service.authorization.permission.Permission;
import org.eclipse.kapua.service.authorization.permission.PermissionFactory;
import org.eclipse.kapua.service.device.registry.Device;
import org.eclipse.kapua.service.device.registry.DeviceCreator;
Expand All @@ -42,7 +41,6 @@
import org.eclipse.kapua.service.device.registry.event.DeviceEventService;
import org.eclipse.kapua.service.device.registry.internal.DeviceRegistryServiceImpl;
import org.eclipse.kapua.service.tag.TagService;
import org.eclipse.kapua.service.user.User;

import java.util.List;

Expand Down Expand Up @@ -82,9 +80,8 @@ private DeviceValidation() {
* Validates the {@link DeviceCreator}.
*
* @param deviceCreator The {@link DeviceCreator} to validate.
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the {@link DeviceCreator} fields is invalid.
* @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s
* @throws KapuaException if there are other errors.
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the {@link DeviceCreator} fields is invalid.
* @throws KapuaException if there are other errors.
* @since 1.0.0
*/
public static void validateCreatePreconditions(DeviceCreator deviceCreator) throws KapuaException {
Expand Down Expand Up @@ -258,12 +255,11 @@ public static void validateCreatePreconditions(DeviceCreator deviceCreator) thro
}

/**
* Validates the {@link Device} for {@link DeviceRegistryService#update(KapuaUpdatableEntity)} operation.
* Validates the {@link Device} for {@link DeviceRegistryService#update(KapuaEntity)} operation.
*
* @param device The {@link Device} to validate.
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the {@link Device} fields is invalid.
* @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s
* @throws KapuaException if there are other errors.
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the {@link Device} fields is invalid.
* @throws KapuaException if there are other errors.
* @since 1.0.0
*/
public static void validateUpdatePreconditions(Device device) throws KapuaException {
Expand Down Expand Up @@ -453,9 +449,8 @@ public static void validateUpdatePreconditions(Device device) throws KapuaExcept
*
* @param scopeId The {@link Device#getScopeId()}
* @param deviceId The {@link Device#getId()}
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the parameters is invalid.
* @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s
* @throws KapuaException if there are other errors.
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the parameters is invalid.
* @throws KapuaException if there are other errors.
* @since 1.0.0
*/
public static void validateFindPreconditions(KapuaId scopeId, KapuaId deviceId) throws KapuaException {
Expand All @@ -474,9 +469,8 @@ public static void validateFindPreconditions(KapuaId scopeId, KapuaId deviceId)
* Validates the {@link KapuaQuery} for {@link DeviceRegistryService#query(KapuaQuery)} operation.
*
* @param query The {@link KapuaQuery} to validate.
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the {@link KapuaQuery} fields is invalid.
* @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s
* @throws KapuaException if there are other errors.
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the {@link KapuaQuery} fields is invalid.
* @throws KapuaException if there are other errors.
* @since 1.0.0
*/
public static void validateQueryPreconditions(KapuaQuery query) throws KapuaException {
Expand All @@ -501,9 +495,8 @@ public static void validateQueryPreconditions(KapuaQuery query) throws KapuaExce
* Validates the {@link KapuaQuery} for {@link DeviceRegistryService#count(KapuaQuery)} operation.
*
* @param query The {@link KapuaQuery} to validate.
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the {@link KapuaQuery} fields is invalid.
* @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s
* @throws KapuaException if there are other errors.
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the {@link KapuaQuery} fields is invalid.
* @throws KapuaException if there are other errors.
* @since 1.0.0
*/
public static void validateCountPreconditions(KapuaQuery query) throws KapuaException {
Expand All @@ -521,9 +514,8 @@ public static void validateCountPreconditions(KapuaQuery query) throws KapuaExce
*
* @param scopeId The {@link Device#getScopeId()}
* @param deviceId The {@link Device#getId()}
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the parameters is invalid.
* @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s
* @throws KapuaException if there are other errors.
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the parameters is invalid.
* @throws KapuaException if there are other errors.
* @since 1.0.0
*/
public static void validateDeletePreconditions(KapuaId scopeId, KapuaId deviceId) throws KapuaException {
Expand All @@ -543,9 +535,8 @@ public static void validateDeletePreconditions(KapuaId scopeId, KapuaId deviceId
*
* @param scopeId The {@link Device#getScopeId()}
* @param clientId The {@link Device#getClientId()}
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the parameters is invalid.
* @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s
* @throws KapuaException if there are other errors.
* @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the parameters is invalid.
* @throws KapuaException if there are other errors.
* @since 1.0.0
*/
public static void validateFindByClientIdPreconditions(KapuaId scopeId, String clientId) throws KapuaException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ public void createABirthMessage(String clientId)
tmpMsg.setDeviceId(null);
}

deviceLifeCycleService.birth(getKapuaId(), tmpMsg);
deviceLifeCycleService.birth(null, tmpMsg);
}

@Given("^A disconnect message from device \"(.+)\"$")
Expand Down Expand Up @@ -1944,7 +1944,7 @@ public void createADeathMessage(String clientId)

try {
primeException();
deviceLifeCycleService.death(getKapuaId(), tmpMsg);
deviceLifeCycleService.death(null, tmpMsg);
} catch (KapuaException ex) {
verifyException(ex);
}
Expand Down Expand Up @@ -1982,7 +1982,7 @@ public void createAMissingMessage(String clientId)

try {
primeException();
deviceLifeCycleService.missing(getKapuaId(), tmpMsg);
deviceLifeCycleService.missing(null, tmpMsg);
} catch (KapuaException ex) {
verifyException(ex);
}
Expand Down Expand Up @@ -2020,7 +2020,7 @@ public void createAnApplicationMessage(String clientId)

try {
primeException();
deviceLifeCycleService.applications(getKapuaId(), tmpMsg);
deviceLifeCycleService.applications(null, tmpMsg);
} catch (KapuaException ex) {
verifyException(ex);
}
Expand Down Expand Up @@ -2240,7 +2240,7 @@ private DeviceCreator prepareRegularDeviceCreator(KapuaId accountId, String clie

DeviceCreator tmpDeviceCreator = deviceFactory.newCreator(accountId, client);

tmpDeviceCreator.setConnectionId(getKapuaId());
// tmpDeviceCreator.setConnectionId(getKapuaId());
tmpDeviceCreator.setDisplayName(TEST_DEVICE_NAME);
tmpDeviceCreator.setSerialNumber("serialNumber");
tmpDeviceCreator.setModelId("modelId");
Expand Down Expand Up @@ -2271,7 +2271,7 @@ private Device prepareRegularDevice(KapuaId accountId, KapuaId deviceId) {
Device tmpDevice = deviceFactory.newEntity(accountId);

tmpDevice.setId(deviceId);
tmpDevice.setConnectionId(getKapuaId());
// tmpDevice.setConnectionId(getKapuaId());
tmpDevice.setDisplayName(TEST_DEVICE_NAME);
tmpDevice.setSerialNumber("serialNumber");
tmpDevice.setModelId("modelId");
Expand Down Expand Up @@ -2758,7 +2758,7 @@ public void tagIsAssignedToDevice(String tagName, String deviceName) throws Thro
}

@When("^I remove device \"([^\"]*)\" from all groups$")
public void iChangeDevicesGroupToNoGroup(String deviceName) throws Exception{
public void iChangeDevicesGroupToNoGroup(String deviceName) throws Exception {

try {
DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId());
Expand Down Expand Up @@ -3024,7 +3024,7 @@ public void iSearchForADeviceWithName(String clientID) throws Throwable {
}

@Given("^I create a device with null clientID$")
public void iCreateADeviceWithNullClientID() throws Throwable{
public void iCreateADeviceWithNullClientID() throws Throwable {
DeviceCreator deviceCreator = deviceFactory.newCreator(getCurrentScopeId());
deviceCreator.setClientId(null);
stepData.put("DeviceCreator", deviceCreator);
Expand Down

0 comments on commit da545d3

Please sign in to comment.