|
|
|
@ -15,7 +15,6 @@ |
|
|
|
*/ |
|
|
|
package org.thingsboard.rule.engine.metadata; |
|
|
|
|
|
|
|
import com.google.common.util.concurrent.Futures; |
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.runner.RunWith; |
|
|
|
@ -31,8 +30,6 @@ import org.thingsboard.server.common.data.id.UserId; |
|
|
|
|
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
import static org.mockito.ArgumentMatchers.any; |
|
|
|
import static org.mockito.ArgumentMatchers.eq; |
|
|
|
import static org.mockito.Mockito.when; |
|
|
|
|
|
|
|
@RunWith(MockitoJUnitRunner.class) |
|
|
|
@ -45,6 +42,7 @@ public class TbGetTenantAttributeNodeTest extends AbstractAttributeNodeTest { |
|
|
|
@Before |
|
|
|
public void initDataForTests() throws TbNodeException { |
|
|
|
init(new TbGetTenantAttributeNode()); |
|
|
|
|
|
|
|
user.setTenantId(tenantId); |
|
|
|
user.setId(new UserId(UUID.randomUUID())); |
|
|
|
|
|
|
|
@ -53,6 +51,8 @@ public class TbGetTenantAttributeNodeTest extends AbstractAttributeNodeTest { |
|
|
|
|
|
|
|
device.setTenantId(tenantId); |
|
|
|
device.setId(new DeviceId(UUID.randomUUID())); |
|
|
|
|
|
|
|
when(ctx.getTenantId()).thenReturn(tenantId); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -67,20 +67,17 @@ public class TbGetTenantAttributeNodeTest extends AbstractAttributeNodeTest { |
|
|
|
|
|
|
|
@Test |
|
|
|
public void errorThrownIfCannotLoadAttributes() { |
|
|
|
mockFindUser(user); |
|
|
|
errorThrownIfCannotLoadAttributes(user); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void errorThrownIfCannotLoadAttributesAsync() { |
|
|
|
mockFindUser(user); |
|
|
|
errorThrownIfCannotLoadAttributesAsync(user); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void failedChainUsedIfCustomerCannotBeFound() { |
|
|
|
when(ctx.getUserService()).thenReturn(userService); |
|
|
|
when(userService.findUserByIdAsync(any(), eq(user.getId()))).thenReturn(Futures.immediateFuture(null)); |
|
|
|
when(ctx.getTenantId()).thenReturn(null); |
|
|
|
failedChainUsedIfCustomerCannotBeFound(user); |
|
|
|
} |
|
|
|
|
|
|
|
@ -91,25 +88,21 @@ public class TbGetTenantAttributeNodeTest extends AbstractAttributeNodeTest { |
|
|
|
|
|
|
|
@Test |
|
|
|
public void usersCustomerAttributesFetched() { |
|
|
|
mockFindUser(user); |
|
|
|
usersCustomerAttributesFetched(user); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void assetsCustomerAttributesFetched() { |
|
|
|
mockFindAsset(asset); |
|
|
|
assetsCustomerAttributesFetched(asset); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void deviceCustomerAttributesFetched() { |
|
|
|
mockFindDevice(device); |
|
|
|
deviceCustomerAttributesFetched(device); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void deviceCustomerTelemetryFetched() throws TbNodeException { |
|
|
|
mockFindDevice(device); |
|
|
|
deviceCustomerTelemetryFetched(device); |
|
|
|
} |
|
|
|
} |
|
|
|
|