Search in sources :

Example 66 with RuleChain

use of org.thingsboard.server.common.data.rule.RuleChain in project thingsboard by thingsboard.

the class BaseRuleChainServiceTest method setEdgeTemplateRootRuleChain.

@Test
public void setEdgeTemplateRootRuleChain() throws Exception {
    RuleChainId ruleChainId1 = saveRuleChainAndSetAutoAssignToEdge("Default Edge Rule Chain 1");
    RuleChainId ruleChainId2 = saveRuleChainAndSetAutoAssignToEdge("Default Edge Rule Chain 2");
    ruleChainService.setEdgeTemplateRootRuleChain(tenantId, ruleChainId1);
    ruleChainService.setEdgeTemplateRootRuleChain(tenantId, ruleChainId2);
    RuleChain ruleChainById = ruleChainService.findRuleChainById(tenantId, ruleChainId1);
    Assert.assertFalse(ruleChainById.isRoot());
    ruleChainById = ruleChainService.findRuleChainById(tenantId, ruleChainId2);
    Assert.assertTrue(ruleChainById.isRoot());
}
Also used : RuleChain(org.thingsboard.server.common.data.rule.RuleChain) RuleChainId(org.thingsboard.server.common.data.id.RuleChainId) Test(org.junit.Test)

Example 67 with RuleChain

use of org.thingsboard.server.common.data.rule.RuleChain in project thingsboard by thingsboard.

the class BaseRuleChainServiceTest method testSaveRuleChainWithInvalidTenant.

@Test(expected = DataValidationException.class)
public void testSaveRuleChainWithInvalidTenant() {
    RuleChain ruleChain = new RuleChain();
    ruleChain.setName("My RuleChain");
    ruleChain.setTenantId(TenantId.fromUUID(Uuids.timeBased()));
    ruleChainService.saveRuleChain(ruleChain);
}
Also used : RuleChain(org.thingsboard.server.common.data.rule.RuleChain) Test(org.junit.Test)

Aggregations

RuleChain (org.thingsboard.server.common.data.rule.RuleChain)67 RuleChainId (org.thingsboard.server.common.data.id.RuleChainId)26 Test (org.junit.Test)20 RuleNode (org.thingsboard.server.common.data.rule.RuleNode)19 ArrayList (java.util.ArrayList)16 ThingsboardException (org.thingsboard.server.common.data.exception.ThingsboardException)15 RuleChainMetaData (org.thingsboard.server.common.data.rule.RuleChainMetaData)14 ApiOperation (io.swagger.annotations.ApiOperation)13 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)13 Edge (org.thingsboard.server.common.data.edge.Edge)13 TenantId (org.thingsboard.server.common.data.id.TenantId)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)11 PageLink (org.thingsboard.server.common.data.page.PageLink)11 RuleNodeId (org.thingsboard.server.common.data.id.RuleNodeId)10 EntityRelation (org.thingsboard.server.common.data.relation.EntityRelation)10 DataValidationException (org.thingsboard.server.dao.exception.DataValidationException)9 EdgeId (org.thingsboard.server.common.data.id.EdgeId)8 List (java.util.List)7 Device (org.thingsboard.server.common.data.Device)7