use of org.thingsboard.server.dao.attributes.AttributesService in project thingsboard by thingsboard.
the class DefaultActorServiceTest method before.
@Before
public void before() throws Exception {
actorService = new DefaultActorService();
actorContext = new ActorSystemContext();
tenantService = mock(TenantService.class);
pluginService = mock(PluginService.class);
ruleService = mock(RuleService.class);
deviceAuthService = mock(DeviceAuthService.class);
deviceService = mock(DeviceService.class);
tsService = mock(TimeseriesService.class);
rpcService = mock(ClusterRpcService.class);
discoveryService = mock(DiscoveryService.class);
routingService = mock(ClusterRoutingService.class);
attributesService = mock(AttributesService.class);
componentService = mock(ComponentDiscoveryService.class);
eventService = mock(EventService.class);
serverInstance = new ServerInstance(ServerInstanceProtos.ServerInfo.newBuilder().setHost("localhost").setPort(8080).build());
ReflectionTestUtils.setField(actorService, "actorContext", actorContext);
ReflectionTestUtils.setField(actorService, "rpcService", rpcService);
ReflectionTestUtils.setField(actorService, "discoveryService", discoveryService);
ReflectionTestUtils.setField(actorContext, "syncSessionTimeout", 10000L);
ReflectionTestUtils.setField(actorContext, "pluginActorTerminationDelay", 10000L);
ReflectionTestUtils.setField(actorContext, "pluginErrorPersistFrequency", 10000L);
ReflectionTestUtils.setField(actorContext, "ruleActorTerminationDelay", 10000L);
ReflectionTestUtils.setField(actorContext, "ruleErrorPersistFrequency", 10000L);
ReflectionTestUtils.setField(actorContext, "pluginProcessingTimeout", 60000L);
ReflectionTestUtils.setField(actorContext, "tenantService", tenantService);
ReflectionTestUtils.setField(actorContext, "pluginService", pluginService);
ReflectionTestUtils.setField(actorContext, "ruleService", ruleService);
ReflectionTestUtils.setField(actorContext, "deviceAuthService", deviceAuthService);
ReflectionTestUtils.setField(actorContext, "deviceService", deviceService);
ReflectionTestUtils.setField(actorContext, "tsService", tsService);
ReflectionTestUtils.setField(actorContext, "rpcService", rpcService);
ReflectionTestUtils.setField(actorContext, "discoveryService", discoveryService);
ReflectionTestUtils.setField(actorContext, "tsService", tsService);
ReflectionTestUtils.setField(actorContext, "routingService", routingService);
ReflectionTestUtils.setField(actorContext, "attributesService", attributesService);
ReflectionTestUtils.setField(actorContext, "componentService", componentService);
ReflectionTestUtils.setField(actorContext, "eventService", eventService);
when(routingService.resolveById((EntityId) any())).thenReturn(Optional.empty());
when(discoveryService.getCurrentServer()).thenReturn(serverInstance);
ruleMock = mock(RuleMetaData.class);
when(ruleMock.getId()).thenReturn(ruleId);
when(ruleMock.getState()).thenReturn(ComponentLifecycleState.ACTIVE);
when(ruleMock.getPluginToken()).thenReturn("telemetry");
TextPageData<RuleMetaData> systemRules = new TextPageData<>(Collections.emptyList(), null, false);
TextPageData<RuleMetaData> tenantRules = new TextPageData<>(Collections.singletonList(ruleMock), null, false);
when(ruleService.findSystemRules(any())).thenReturn(systemRules);
when(ruleService.findTenantRules(any(), any())).thenReturn(tenantRules);
when(ruleService.findRuleById(ruleId)).thenReturn(ruleMock);
pluginMock = mock(PluginMetaData.class);
when(pluginMock.getTenantId()).thenReturn(SYSTEM_TENANT);
when(pluginMock.getId()).thenReturn(pluginId);
when(pluginMock.getState()).thenReturn(ComponentLifecycleState.ACTIVE);
TextPageData<PluginMetaData> systemPlugins = new TextPageData<>(Collections.singletonList(pluginMock), null, false);
TextPageData<PluginMetaData> tenantPlugins = new TextPageData<>(Collections.emptyList(), null, false);
when(pluginService.findSystemPlugins(any())).thenReturn(systemPlugins);
when(pluginService.findTenantPlugins(any(), any())).thenReturn(tenantPlugins);
when(pluginService.findPluginByApiToken("telemetry")).thenReturn(pluginMock);
when(pluginService.findPluginById(pluginId)).thenReturn(pluginMock);
TextPageData<Tenant> tenants = new TextPageData<>(Collections.emptyList(), null, false);
when(tenantService.findTenants(any())).thenReturn(tenants);
}
Aggregations