当前位置: 首页>>代码示例>>Java>>正文


Java UUIDs.timeBased方法代码示例

本文整理汇总了Java中com.datastax.driver.core.utils.UUIDs.timeBased方法的典型用法代码示例。如果您正苦于以下问题:Java UUIDs.timeBased方法的具体用法?Java UUIDs.timeBased怎么用?Java UUIDs.timeBased使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.datastax.driver.core.utils.UUIDs的用法示例。


在下文中一共展示了UUIDs.timeBased方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFindAssetsByTenantIdAndCustomerId

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
@Test
public void testFindAssetsByTenantIdAndCustomerId() {
    UUID tenantId1 = UUIDs.timeBased();
    UUID tenantId2 = UUIDs.timeBased();
    UUID customerId1 = UUIDs.timeBased();
    UUID customerId2 = UUIDs.timeBased();
    for (int i = 0; i < 60; i++) {
        UUID assetId = UUIDs.timeBased();
        UUID tenantId = i % 2 == 0 ? tenantId1 : tenantId2;
        UUID customerId = i % 2 == 0 ? customerId1 : customerId2;
        saveAsset(assetId, tenantId, customerId, "ASSET_" + i, "TYPE_1");
    }

    TextPageLink pageLink1 = new TextPageLink(20, "ASSET_");
    List<Asset> assets1 = assetDao.findAssetsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink1);
    assertEquals(20, assets1.size());

    TextPageLink pageLink2 = new TextPageLink(20, "ASSET_", assets1.get(19).getId().getId(), null);
    List<Asset> assets2 = assetDao.findAssetsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink2);
    assertEquals(10, assets2.size());

    TextPageLink pageLink3 = new TextPageLink(20, "ASSET_", assets2.get(9).getId().getId(), null);
    List<Asset> assets3 = assetDao.findAssetsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink3);
    assertEquals(0, assets3.size());
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:26,代码来源:JpaAssetDaoTest.java

示例2: testDeleteRelation

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
@Test
public void testDeleteRelation() throws ExecutionException, InterruptedException {
    AssetId parentId = new AssetId(UUIDs.timeBased());
    AssetId childId = new AssetId(UUIDs.timeBased());
    AssetId subChildId = new AssetId(UUIDs.timeBased());

    EntityRelation relationA = new EntityRelation(parentId, childId, EntityRelation.CONTAINS_TYPE);
    EntityRelation relationB = new EntityRelation(childId, subChildId, EntityRelation.CONTAINS_TYPE);

    saveRelation(relationA);
    saveRelation(relationB);

    Assert.assertTrue(relationService.deleteRelationAsync(relationA).get());

    Assert.assertFalse(relationService.checkRelation(parentId, childId, EntityRelation.CONTAINS_TYPE, RelationTypeGroup.COMMON).get());

    Assert.assertTrue(relationService.checkRelation(childId, subChildId, EntityRelation.CONTAINS_TYPE, RelationTypeGroup.COMMON).get());

    Assert.assertTrue(relationService.deleteRelationAsync(childId, subChildId, EntityRelation.CONTAINS_TYPE, RelationTypeGroup.COMMON).get());
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:21,代码来源:BaseRelationServiceTest.java

示例3: testDeleteEntityRelations

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
@Test
public void testDeleteEntityRelations() throws ExecutionException, InterruptedException {
    AssetId parentId = new AssetId(UUIDs.timeBased());
    AssetId childId = new AssetId(UUIDs.timeBased());
    AssetId subChildId = new AssetId(UUIDs.timeBased());

    EntityRelation relationA = new EntityRelation(parentId, childId, EntityRelation.CONTAINS_TYPE);
    EntityRelation relationB = new EntityRelation(childId, subChildId, EntityRelation.CONTAINS_TYPE);

    saveRelation(relationA);
    saveRelation(relationB);

    Assert.assertTrue(relationService.deleteEntityRelationsAsync(childId).get());

    Assert.assertFalse(relationService.checkRelation(parentId, childId, EntityRelation.CONTAINS_TYPE, RelationTypeGroup.COMMON).get());

    Assert.assertFalse(relationService.checkRelation(childId, subChildId, EntityRelation.CONTAINS_TYPE, RelationTypeGroup.COMMON).get());
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:19,代码来源:BaseRelationServiceTest.java

示例4: testCyclicRecursiveRelation

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
@Test
public void testCyclicRecursiveRelation() throws ExecutionException, InterruptedException {
    // A -> B -> C -> A
    AssetId assetA = new AssetId(UUIDs.timeBased());
    AssetId assetB = new AssetId(UUIDs.timeBased());
    AssetId assetC = new AssetId(UUIDs.timeBased());

    EntityRelation relationA = new EntityRelation(assetA, assetB, EntityRelation.CONTAINS_TYPE);
    EntityRelation relationB = new EntityRelation(assetB, assetC, EntityRelation.CONTAINS_TYPE);
    EntityRelation relationC = new EntityRelation(assetC, assetA, EntityRelation.CONTAINS_TYPE);

    saveRelation(relationA);
    saveRelation(relationB);
    saveRelation(relationC);

    EntityRelationsQuery query = new EntityRelationsQuery();
    query.setParameters(new RelationsSearchParameters(assetA, EntitySearchDirection.FROM, -1));
    query.setFilters(Collections.singletonList(new EntityTypeFilter(EntityRelation.CONTAINS_TYPE, Collections.singletonList(EntityType.ASSET))));
    List<EntityRelation> relations = relationService.findByQuery(query).get();
    Assert.assertEquals(3, relations.size());
    Assert.assertTrue(relations.contains(relationA));
    Assert.assertTrue(relations.contains(relationB));
    Assert.assertTrue(relations.contains(relationC));
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:25,代码来源:BaseRelationServiceTest.java

示例5: testFindByTenantIdAndPageLink

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
@Test
@DatabaseSetup("classpath:dbunit/empty_dataset.xml")
public void testFindByTenantIdAndPageLink() {
    UUID tenantId1 = UUIDs.timeBased();
    UUID tenantId2 = UUIDs.timeBased();
    createPluginsTwoTenants(tenantId1, tenantId2, "plugin_");
    List<PluginMetaData> rules1 = pluginDao.findByTenantIdAndPageLink(
            new TenantId(tenantId1), new TextPageLink(20, "plugin_"));
    assertEquals(20, rules1.size());

    List<PluginMetaData> rules2 = pluginDao.findByTenantIdAndPageLink(new TenantId(tenantId1),
            new TextPageLink(20, "plugin_", rules1.get(19).getId().getId(), null));
    assertEquals(10, rules2.size());

    List<PluginMetaData> rules3 = pluginDao.findByTenantIdAndPageLink(new TenantId(tenantId1),
            new TextPageLink(20, "plugin_", rules2.get(9).getId().getId(), null));
    assertEquals(0, rules3.size());
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:19,代码来源:JpaBasePluginDaoTest.java

示例6: saveUser

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
private void saveUser(UUID tenantId, UUID customerId) {
    User user = new User();
    UUID id = UUIDs.timeBased();
    user.setId(new UserId(id));
    user.setTenantId(new TenantId(tenantId));
    user.setCustomerId(new CustomerId(customerId));
    if (customerId == NULL_UUID) {
        user.setAuthority(Authority.TENANT_ADMIN);
    } else {
        user.setAuthority(Authority.CUSTOMER_USER);
    }
    String idString = id.toString();
    String email = idString.substring(0, idString.indexOf('-')) + "@thingsboard.org";
    user.setEmail(email);
    userDao.save(user);
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:17,代码来源:JpaUserDaoTest.java

示例7: generateRule

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
protected RuleMetaData generateRule(TenantId tenantId, Integer weight, String pluginToken) throws IOException {
    if (tenantId == null) {
        tenantId = new TenantId(UUIDs.timeBased());
    }
    if (weight == null) {
        weight = ThreadLocalRandom.current().nextInt();
    }

    RuleMetaData ruleMetaData = new RuleMetaData();
    ruleMetaData.setName("Testing");
    ruleMetaData.setTenantId(tenantId);
    ruleMetaData.setWeight(weight);
    ruleMetaData.setPluginToken(pluginToken);

    ruleMetaData.setAction(createNode(ComponentScope.TENANT, ComponentType.ACTION,
            "org.thingsboard.component.ActionTest", "TestJsonDescriptor.json", "TestJsonData.json"));
    ruleMetaData.setProcessor(createNode(ComponentScope.TENANT, ComponentType.PROCESSOR,
            "org.thingsboard.component.ProcessorTest", "TestJsonDescriptor.json", "TestJsonData.json"));
    ruleMetaData.setFilters(mapper.createArrayNode().add(
            createNode(ComponentScope.TENANT, ComponentType.FILTER,
                    "org.thingsboard.component.FilterTest", "TestJsonDescriptor.json", "TestJsonData.json")
    ));

    ruleMetaData.setAdditionalInfo(mapper.readTree("{}"));
    return ruleMetaData;
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:27,代码来源:AbstractServiceTest.java

示例8: testFindDevicesByTenantId

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
@Test
public void testFindDevicesByTenantId() {
    UUID tenantId1 = UUIDs.timeBased();
    UUID tenantId2 = UUIDs.timeBased();
    UUID customerId1 = UUIDs.timeBased();
    UUID customerId2 = UUIDs.timeBased();
    createDevices(tenantId1, tenantId2, customerId1, customerId2, 40);

    TextPageLink pageLink1 = new TextPageLink(15, "SEARCH_TEXT");
    List<Device> devices1 = deviceDao.findDevicesByTenantId(tenantId1, pageLink1);
    assertEquals(15, devices1.size());

    TextPageLink pageLink2 = new TextPageLink(15, "SEARCH_TEXT",  devices1.get(14).getId().getId(), null);
    List<Device> devices2 = deviceDao.findDevicesByTenantId(tenantId1, pageLink2);
    assertEquals(5, devices2.size());
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:17,代码来源:JpaDeviceDaoTest.java

示例9: findAll

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
@Test
public void findAll() throws Exception {
    DeviceId deviceId = new DeviceId(UUIDs.timeBased());

    KvEntry attrAOldValue = new StringDataEntry("A", "value1");
    AttributeKvEntry attrAOld = new BaseAttributeKvEntry(attrAOldValue, 42L);
    KvEntry attrANewValue = new StringDataEntry("A", "value2");
    AttributeKvEntry attrANew = new BaseAttributeKvEntry(attrANewValue, 73L);
    KvEntry attrBNewValue = new StringDataEntry("B", "value3");
    AttributeKvEntry attrBNew = new BaseAttributeKvEntry(attrBNewValue, 73L);

    attributesService.save(deviceId, DataConstants.CLIENT_SCOPE, Collections.singletonList(attrAOld)).get();
    attributesService.save(deviceId, DataConstants.CLIENT_SCOPE, Collections.singletonList(attrANew)).get();
    attributesService.save(deviceId, DataConstants.CLIENT_SCOPE, Collections.singletonList(attrBNew)).get();

    List<AttributeKvEntry> saved = attributesService.findAll(deviceId, DataConstants.CLIENT_SCOPE).get();

    Assert.assertNotNull(saved);
    Assert.assertEquals(2, saved.size());

    Assert.assertEquals(attrANew, saved.get(0));
    Assert.assertEquals(attrBNew, saved.get(1));
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:24,代码来源:BaseAttributesServiceTest.java

示例10: testFindAssetsByTenantId

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
@Test
public void testFindAssetsByTenantId() {
    UUID tenantId1 = UUIDs.timeBased();
    UUID tenantId2 = UUIDs.timeBased();
    UUID customerId1 = UUIDs.timeBased();
    UUID customerId2 = UUIDs.timeBased();
    for (int i = 0; i < 60; i++) {
        UUID assetId = UUIDs.timeBased();
        UUID tenantId = i % 2 == 0 ? tenantId1 : tenantId2;
        UUID customerId = i % 2 == 0 ? customerId1 : customerId2;
        saveAsset(assetId, tenantId, customerId, "ASSET_" + i, "TYPE_1");
    }
    assertEquals(60, assetDao.find().size());

    TextPageLink pageLink1 = new TextPageLink(20, "ASSET_");
    List<Asset> assets1 = assetDao.findAssetsByTenantId(tenantId1, pageLink1);
    assertEquals(20, assets1.size());

    TextPageLink pageLink2 = new TextPageLink(20, "ASSET_", assets1.get(19).getId().getId(), null);
    List<Asset> assets2 = assetDao.findAssetsByTenantId(tenantId1, pageLink2);
    assertEquals(10, assets2.size());

    TextPageLink pageLink3 = new TextPageLink(20, "ASSET_", assets2.get(9).getId().getId(), null);
    List<Asset> assets3 = assetDao.findAssetsByTenantId(tenantId1, pageLink3);
    assertEquals(0, assets3.size());
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:27,代码来源:JpaAssetDaoTest.java

示例11: testFindDevicesByTenantIdAndIdsAsync

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
@Test
public void testFindDevicesByTenantIdAndIdsAsync() throws ExecutionException, InterruptedException {
    UUID tenantId1 = UUIDs.timeBased();
    UUID customerId1 = UUIDs.timeBased();
    UUID tenantId2 = UUIDs.timeBased();
    UUID customerId2 = UUIDs.timeBased();

    List<UUID> deviceIds = new ArrayList<>();

    for(int i = 0; i < 5; i++) {
        UUID deviceId1 = UUIDs.timeBased();
        UUID deviceId2 = UUIDs.timeBased();
        deviceDao.save(getDevice(tenantId1, customerId1, deviceId1));
        deviceDao.save(getDevice(tenantId2, customerId2, deviceId2));
        deviceIds.add(deviceId1);
        deviceIds.add(deviceId2);
    }

    ListenableFuture<List<Device>> devicesFuture = deviceDao.findDevicesByTenantIdAndIdsAsync(tenantId1, deviceIds);
    List<Device> devices = devicesFuture.get();
    assertEquals(5, devices.size());
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:23,代码来源:JpaDeviceDaoTest.java

示例12: testFindDashboardsByTenantAndCustomerId

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
@Test
public void testFindDashboardsByTenantAndCustomerId() {
    UUID tenantId1 = UUIDs.timeBased();
    UUID customerId1 = UUIDs.timeBased();
    UUID tenantId2 = UUIDs.timeBased();
    UUID customerId2 = UUIDs.timeBased();

    for (int i = 0; i < 20; i++) {
        createDashboard(tenantId1, customerId1, i);
        createDashboard(tenantId2, customerId2, i * 2);
    }

    TextPageLink pageLink1 = new TextPageLink(15, "DASHBOARD");
    List<DashboardInfo> dashboardInfos1 = dashboardInfoDao.findDashboardsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink1);
    assertEquals(15, dashboardInfos1.size());

    TextPageLink pageLink2 = new TextPageLink(15, "DASHBOARD", dashboardInfos1.get(14).getId().getId(), null);
    List<DashboardInfo> dashboardInfos2 = dashboardInfoDao.findDashboardsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink2);
    assertEquals(5, dashboardInfos2.size());
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:21,代码来源:JpaDashboardInfoDaoTest.java

示例13: main

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
public static void main(String[] args) {
	Session session = Connection.connect();
			
	SimpleStatement statement1 = new SimpleStatement("insert into user (id, name, age) values (?, ?, ?)",
			UUIDs.timeBased(), "user01", 30);
	
	statement1.setConsistencyLevel(ConsistencyLevel.ONE);

	try {
		
		ResultSet rs = session.execute(statement1);
		System.out.println(rs);
	} catch (Exception ex) {
		ex.printStackTrace();
	}

	SimpleStatement statement2 = new SimpleStatement("select id, name, age from user");

	ResultSet rs2 = session.execute(statement2);

	System.out.println(rs2);

	for (Row row : rs2) {
		System.out.printf("id: %s, name: %s, age: %d\n", row.get(0, UUID.class), 
				  row.getString(1), row.getInt(2));
	}

	Connection.close();
}
 
开发者ID:abulbasar,项目名称:cassandra-java-driver-examples,代码行数:30,代码来源:SimpleStatementExample.java

示例14: testFindCustomersByTenantIdAndTitle

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
@Test
public void testFindCustomersByTenantIdAndTitle() {
    UUID tenantId = UUIDs.timeBased();

    for (int i = 0; i < 10; i++) {
        createCustomer(tenantId, i);
    }

    Optional<Customer> customerOpt = customerDao.findCustomersByTenantIdAndTitle(tenantId, "CUSTOMER_5");
    assertTrue(customerOpt.isPresent());
    assertEquals("CUSTOMER_5", customerOpt.get().getTitle());
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:13,代码来源:JpaCustomerDaoTest.java

示例15: findPluginByTenantIdAndApiToken

import com.datastax.driver.core.utils.UUIDs; //导入方法依赖的package包/类
@Test
public void findPluginByTenantIdAndApiToken() throws Exception {
  String token = UUID.randomUUID().toString();
  TenantId tenantId = new TenantId(UUIDs.timeBased());
  pluginService.savePlugin(generatePlugin(null, null));
  pluginService.savePlugin(generatePlugin(tenantId, null));
  pluginService.savePlugin(generatePlugin(tenantId, null));
  pluginService.savePlugin(generatePlugin(tenantId, null));
  PluginMetaData expected = pluginService.savePlugin(generatePlugin(tenantId, token));
  Assert.assertNotNull(expected.getId());
  PluginMetaData found = pluginService.findPluginByApiToken(token);
  Assert.assertEquals(expected, found);
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:14,代码来源:BasePluginServiceTest.java


注:本文中的com.datastax.driver.core.utils.UUIDs.timeBased方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。