refactoring: tests comments1
This commit is contained in:
parent
102787499d
commit
ea04b56076
@ -179,16 +179,16 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyUpdateDeviceCredentials(TenantId tenantId, DeviceId deviceId, CustomerId customerId, Device device,
|
public void notifyUpdateDeviceCredentials(TenantId tenantId, DeviceId deviceId, CustomerId customerId, Device device,
|
||||||
DeviceCredentials deviceCredentials, ActionType actionType, User user) {
|
DeviceCredentials deviceCredentials, User user) {
|
||||||
tbClusterService.pushMsgToCore(new DeviceCredentialsUpdateNotificationMsg(tenantId, deviceCredentials.getDeviceId(), deviceCredentials), null);
|
tbClusterService.pushMsgToCore(new DeviceCredentialsUpdateNotificationMsg(tenantId, deviceCredentials.getDeviceId(), deviceCredentials), null);
|
||||||
sendEntityNotificationMsg(tenantId, deviceId, edgeTypeByActionType(actionType));
|
sendEntityNotificationMsg(tenantId, deviceId, EdgeEventActionType.CREDENTIALS_UPDATED);
|
||||||
logEntityAction(tenantId, deviceId, device, customerId, actionType, user, deviceCredentials);
|
logEntityAction(tenantId, deviceId, device, customerId, ActionType.CREDENTIALS_UPDATED, user, deviceCredentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyAssignDeviceToTenant(TenantId tenantId, TenantId newTenantId, DeviceId deviceId, CustomerId customerId,
|
public void notifyAssignDeviceToTenant(TenantId tenantId, TenantId newTenantId, DeviceId deviceId, CustomerId customerId,
|
||||||
Device device, Tenant tenant, ActionType actionType, User user, Object... additionalInfo) {
|
Device device, Tenant tenant, User user, Object... additionalInfo) {
|
||||||
logEntityAction(tenantId, deviceId, device, customerId, actionType, user, additionalInfo);
|
logEntityAction(tenantId, deviceId, device, customerId, ActionType.ASSIGNED_TO_TENANT, user, additionalInfo);
|
||||||
pushAssignedFromNotification(tenant, newTenantId, device);
|
pushAssignedFromNotification(tenant, newTenantId, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -92,10 +92,10 @@ public interface TbNotificationEntityService {
|
|||||||
List<EdgeId> relatedEdgeIds, User user, Object... additionalInfo);
|
List<EdgeId> relatedEdgeIds, User user, Object... additionalInfo);
|
||||||
|
|
||||||
void notifyUpdateDeviceCredentials(TenantId tenantId, DeviceId deviceId, CustomerId customerId, Device device,
|
void notifyUpdateDeviceCredentials(TenantId tenantId, DeviceId deviceId, CustomerId customerId, Device device,
|
||||||
DeviceCredentials deviceCredentials, ActionType actionType, User user);
|
DeviceCredentials deviceCredentials, User user);
|
||||||
|
|
||||||
void notifyAssignDeviceToTenant(TenantId tenantId, TenantId newTenantId, DeviceId deviceId, CustomerId customerId,
|
void notifyAssignDeviceToTenant(TenantId tenantId, TenantId newTenantId, DeviceId deviceId, CustomerId customerId,
|
||||||
Device device, Tenant tenant, ActionType actionType, User user, Object... additionalInfo);
|
Device device, Tenant tenant, User user, Object... additionalInfo);
|
||||||
|
|
||||||
void notifyEdge(TenantId tenantId, EdgeId edgeId, CustomerId customerId, Edge edge, ActionType actionType,
|
void notifyEdge(TenantId tenantId, EdgeId edgeId, CustomerId customerId, Edge edge, ActionType actionType,
|
||||||
User user, Object... additionalInfo);
|
User user, Object... additionalInfo);
|
||||||
|
|||||||
@ -185,14 +185,13 @@ public class DefaultTbDeviceService extends AbstractTbEntityService implements T
|
|||||||
public DeviceCredentials updateDeviceCredentials(Device device, DeviceCredentials deviceCredentials, User user) throws ThingsboardException {
|
public DeviceCredentials updateDeviceCredentials(Device device, DeviceCredentials deviceCredentials, User user) throws ThingsboardException {
|
||||||
TenantId tenantId = device.getTenantId();
|
TenantId tenantId = device.getTenantId();
|
||||||
DeviceId deviceId = device.getId();
|
DeviceId deviceId = device.getId();
|
||||||
ActionType actionType = ActionType.CREDENTIALS_UPDATED;
|
|
||||||
try {
|
try {
|
||||||
DeviceCredentials result = checkNotNull(deviceCredentialsService.updateDeviceCredentials(tenantId, deviceCredentials));
|
DeviceCredentials result = checkNotNull(deviceCredentialsService.updateDeviceCredentials(tenantId, deviceCredentials));
|
||||||
notificationEntityService.notifyUpdateDeviceCredentials(tenantId, deviceId, device.getCustomerId(), device, result, actionType, user);
|
notificationEntityService.notifyUpdateDeviceCredentials(tenantId, deviceId, device.getCustomerId(), device, result, user);
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
notificationEntityService.logEntityAction(tenantId, emptyId(EntityType.DEVICE),
|
notificationEntityService.logEntityAction(tenantId, emptyId(EntityType.DEVICE),
|
||||||
actionType, user, e, deviceCredentials);
|
ActionType.CREDENTIALS_UPDATED, user, e, deviceCredentials);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,18 +230,17 @@ public class DefaultTbDeviceService extends AbstractTbEntityService implements T
|
|||||||
TenantId tenantId = device.getTenantId();
|
TenantId tenantId = device.getTenantId();
|
||||||
TenantId newTenantId = newTenant.getId();
|
TenantId newTenantId = newTenant.getId();
|
||||||
DeviceId deviceId = device.getId();
|
DeviceId deviceId = device.getId();
|
||||||
ActionType actionType = ActionType.ASSIGNED_TO_TENANT;
|
|
||||||
try {
|
try {
|
||||||
Tenant tenant = tenantService.findTenantById(tenantId);
|
Tenant tenant = tenantService.findTenantById(tenantId);
|
||||||
Device assignedDevice = deviceService.assignDeviceToTenant(newTenantId, device);
|
Device assignedDevice = deviceService.assignDeviceToTenant(newTenantId, device);
|
||||||
|
|
||||||
notificationEntityService.notifyAssignDeviceToTenant(tenantId, newTenantId, deviceId,
|
notificationEntityService.notifyAssignDeviceToTenant(tenantId, newTenantId, deviceId,
|
||||||
assignedDevice.getCustomerId(), assignedDevice, tenant, actionType, user, newTenantId.toString(), newTenant.getName());
|
assignedDevice.getCustomerId(), assignedDevice, tenant, user, newTenantId.toString(), newTenant.getName());
|
||||||
|
|
||||||
return assignedDevice;
|
return assignedDevice;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
notificationEntityService.logEntityAction(tenantId, emptyId(EntityType.DEVICE),
|
notificationEntityService.logEntityAction(tenantId, emptyId(EntityType.DEVICE),
|
||||||
actionType, user, e, deviceId.toString());
|
ActionType.ASSIGNED_TO_TENANT, user, e, deviceId.toString());
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright © 2016-2022 The Thingsboard Authors
|
* Copyright © 2016-2022 The Thingsboard Authors
|
||||||
* <p>
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* <p>
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* <p>
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user