java.util.UUID

Here are the examples of the java api class java.util.UUID taken from open source projects.

1. UUIDTest#test_version()

Project: j2objc
Source File: UUIDTest.java
View license
/**
     * @see UUID#version()
     */
public void test_version() {
    UUID uuid = new UUID(0, 0);
    assertEquals(0, uuid.version());
    uuid = new UUID(0x0000000000001000L, 0);
    assertEquals(1, uuid.version());
    uuid = new UUID(0x0000000000002000L, 0);
    assertEquals(2, uuid.version());
    uuid = new UUID(0x0000000000003000L, 0);
    assertEquals(3, uuid.version());
    uuid = new UUID(0x0000000000004000L, 0);
    assertEquals(4, uuid.version());
    uuid = new UUID(0x0000000000005000L, 0);
    assertEquals(5, uuid.version());
}

2. UUIDTest#test_clockSequence()

Project: j2objc
Source File: UUIDTest.java
View license
/**
     * @see UUID#clockSequence()
     */
public void test_clockSequence() {
    UUID uuid = new UUID(0x0000000000001000L, 0x8000000000000000L);
    assertEquals(0x0, uuid.clockSequence());
    uuid = new UUID(0x0000000000001000L, 0x8FFF000000000000L);
    assertEquals(0x0FFF, uuid.clockSequence());
    uuid = new UUID(0x0000000000001000L, 0xBFFF000000000000L);
    assertEquals(0x3FFF, uuid.clockSequence());
    uuid = new UUID(0x0000000000000000L, 0x8000000000000000L);
    try {
        uuid.clockSequence();
        fail("No UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
    }
    uuid = new UUID(0x0000000000002000L, 0x8000000000000000L);
    try {
        uuid.clockSequence();
        fail("No UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
    }
}

3. UUIDTest#test_equalsObject()

Project: j2objc
Source File: UUIDTest.java
View license
/**
     * @see UUID#equals(Object)
     */
public void test_equalsObject() {
    UUID uuid1 = new UUID(0, 0);
    assertEquals(uuid1, uuid1);
    assertFalse(uuid1.equals(null));
    assertFalse(uuid1.equals("NOT A UUID"));
    UUID uuid2 = new UUID(0, 0);
    assertEquals(uuid1, uuid2);
    assertEquals(uuid2, uuid1);
    uuid1 = new UUID(0xf81d4fae7dec11d0L, 0xa76500a0c91e6bf6L);
    uuid2 = new UUID(0xf81d4fae7dec11d0L, 0xa76500a0c91e6bf6L);
    assertEquals(uuid1, uuid2);
    assertEquals(uuid2, uuid1);
    uuid2 = new UUID(0xf81d4fae7dec11d0L, 0xa76500a0c91e6bf7L);
    assertFalse(uuid1.equals(uuid2));
    assertFalse(uuid2.equals(uuid1));
}

4. TestInvoicePaymentControlDao#testPluginAutoPayOffMutlitpleEntries()

View license
@Test(groups = "slow")
public void testPluginAutoPayOffMutlitpleEntries() {
    final UUID accountId = UUID.randomUUID();
    final UUID attemptId = UUID.randomUUID();
    final UUID paymentId1 = UUID.randomUUID();
    final UUID methodId = UUID.randomUUID();
    final BigDecimal amount = new BigDecimal("13.33");
    final DateTime utcNow = clock.getUTCNow();
    final PluginAutoPayOffModelDao entry1 = new PluginAutoPayOffModelDao(attemptId, "key1", "tkey1", accountId, "XXX", paymentId1, methodId, amount, Currency.USD, "lulu", utcNow);
    dao.insertAutoPayOff(entry1);
    final UUID paymentId2 = UUID.randomUUID();
    final PluginAutoPayOffModelDao entry2 = new PluginAutoPayOffModelDao(attemptId, "key2", "tkey2", accountId, "XXX", paymentId2, methodId, amount, Currency.USD, "lulu", utcNow);
    dao.insertAutoPayOff(entry2);
    final List<PluginAutoPayOffModelDao> entries = dao.getAutoPayOffEntry(accountId);
    assertEquals(entries.size(), 2);
}

5. ContentLockToolCheck#doCheck()

View license
@Override
protected ToolCheckResponse doCheck(ToolUser user, String url, Map<String, Object> parameters) {
    UUID contentId = ObjectUtils.to(UUID.class, parameters.get("contentId"));
    UUID oldOwnerId = ObjectUtils.to(UUID.class, parameters.get("ownerId"));
    UUID newOwnerId = user.lockContent(contentId).getId();
    if (newOwnerId.equals(oldOwnerId)) {
        return null;
    } else {
        return new ToolCheckResponse("newOwner", "id", newOwnerId);
    }
}

6. UUIDTest#test_timestamp()

Project: j2objc
Source File: UUIDTest.java
View license
/**
     * @see UUID#timestamp()
     */
public void test_timestamp() {
    UUID uuid = new UUID(0x0000000000001000L, 0x8000000000000000L);
    assertEquals(0x0, uuid.timestamp());
    uuid = new UUID(0x7777777755551333L, 0x8000000000000000L);
    assertEquals(0x333555577777777L, uuid.timestamp());
    uuid = new UUID(0x0000000000000000L, 0x8000000000000000L);
    try {
        uuid.timestamp();
        fail("No UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
    }
    uuid = new UUID(0x0000000000002000L, 0x8000000000000000L);
    try {
        uuid.timestamp();
        fail("No UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
    }
}

7. UUIDTest#test_node()

Project: j2objc
Source File: UUIDTest.java
View license
/**
     * @see UUID#node()
     */
public void test_node() {
    UUID uuid = new UUID(0x0000000000001000L, 0x8000000000000000L);
    assertEquals(0x0, uuid.node());
    uuid = new UUID(0x0000000000001000L, 0x8000FFFFFFFFFFFFL);
    assertEquals(0xFFFFFFFFFFFFL, uuid.node());
    uuid = new UUID(0x0000000000000000L, 0x8000000000000000L);
    try {
        uuid.node();
        fail("No UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
    }
    uuid = new UUID(0x0000000000002000L, 0x8000000000000000L);
    try {
        uuid.node();
        fail("No UnsupportedOperationException");
    } catch (UnsupportedOperationException e) {
    }
}

8. TestInvoiceItemDao#testGetInvoiceItemsByAccountId()

Project: killbill
Source File: TestInvoiceItemDao.java
View license
@Test(groups = "slow")
public void testGetInvoiceItemsByAccountId() throws EntityPersistenceException {
    final UUID accountId = account.getId();
    final UUID bundleId = UUID.randomUUID();
    final LocalDate targetDate = new LocalDate(2011, 5, 23);
    final DefaultInvoice invoice = new DefaultInvoice(accountId, clock.getUTCToday(), targetDate, Currency.USD);
    invoiceUtil.createInvoice(invoice, true, context);
    final UUID invoiceId = invoice.getId();
    final LocalDate startDate = new LocalDate(2011, 3, 1);
    final BigDecimal rate = new BigDecimal("20.00");
    final UUID subscriptionId = UUID.randomUUID();
    final RecurringInvoiceItem item = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, "test plan", "test phase", startDate, startDate.plusMonths(1), rate, rate, Currency.USD);
    invoiceUtil.createInvoiceItem(item, context);
    final List<InvoiceItemModelDao> items = invoiceUtil.getInvoiceItemByAccountId(context);
    assertEquals(items.size(), 1);
}

9. TestInvoicePaymentControlDao#testPluginAutoPayOffSimple()

View license
@Test(groups = "slow")
public void testPluginAutoPayOffSimple() {
    final UUID accountId = UUID.randomUUID();
    final UUID attemptId = UUID.randomUUID();
    final UUID paymentId = UUID.randomUUID();
    final UUID methodId = UUID.randomUUID();
    final BigDecimal amount = new BigDecimal("13.33");
    final DateTime utcNow = clock.getUTCNow();
    final PluginAutoPayOffModelDao entry1 = new PluginAutoPayOffModelDao(attemptId, "key1", "tkey1", accountId, "XXX", paymentId, methodId, amount, Currency.USD, "lulu", utcNow);
    dao.insertAutoPayOff(entry1);
    final List<PluginAutoPayOffModelDao> entries = dao.getAutoPayOffEntry(accountId);
    assertEquals(entries.size(), 1);
    assertEquals(entries.get(0).getPaymentExternalKey(), "key1");
    assertEquals(entries.get(0).getTransactionExternalKey(), "tkey1");
    assertEquals(entries.get(0).getAccountId(), accountId);
    assertEquals(entries.get(0).getPluginName(), "XXX");
    assertEquals(entries.get(0).getPaymentId(), paymentId);
    assertEquals(entries.get(0).getPaymentMethodId(), methodId);
    assertEquals(entries.get(0).getAmount().compareTo(amount), 0);
    assertEquals(entries.get(0).getCurrency(), Currency.USD);
    assertEquals(entries.get(0).getCreatedBy(), "lulu");
    assertEquals(entries.get(0).getCreatedDate(), utcNow);
}

10. TestInvoicePaymentControlDao#testPluginAutoPayOffNoEntries()

View license
@Test(groups = "slow")
public void testPluginAutoPayOffNoEntries() {
    final UUID accountId = UUID.randomUUID();
    final UUID paymentId1 = UUID.randomUUID();
    final UUID attemptId = UUID.randomUUID();
    final UUID methodId = UUID.randomUUID();
    final BigDecimal amount = new BigDecimal("13.33");
    final DateTime utcNow = clock.getUTCNow();
    final PluginAutoPayOffModelDao entry1 = new PluginAutoPayOffModelDao(attemptId, "key1", "tkey1", accountId, "XXX", paymentId1, methodId, amount, Currency.USD, "lulu", utcNow);
    dao.insertAutoPayOff(entry1);
    final List<PluginAutoPayOffModelDao> entries = dao.getAutoPayOffEntry(UUID.randomUUID());
    assertEquals(entries.size(), 0);
}

11. TestExternalPaymentProviderPlugin#testProcessPayment()

View license
@Test(groups = "fast")
public void testProcessPayment() throws Exception {
    final List<PluginProperty> properties = ImmutableList.<PluginProperty>of();
    final UUID accountId = UUID.randomUUID();
    final UUID paymentId = UUID.randomUUID();
    final UUID kbTransactionId = UUID.randomUUID();
    final UUID paymentMethodId = UUID.randomUUID();
    final BigDecimal amount = BigDecimal.TEN;
    final PaymentTransactionInfoPlugin paymentInfoPlugin = plugin.purchasePayment(accountId, paymentId, kbTransactionId, paymentMethodId, amount, Currency.BRL, properties, callContext);
    Assert.assertEquals(paymentInfoPlugin.getAmount(), amount);
    Assert.assertNull(paymentInfoPlugin.getGatewayError());
    Assert.assertNull(paymentInfoPlugin.getGatewayErrorCode());
    Assert.assertEquals(paymentInfoPlugin.getStatus(), PaymentPluginStatus.PROCESSED);
    final List<PaymentTransactionInfoPlugin> retrievedPaymentTransactionInfoPlugin = plugin.getPaymentInfo(accountId, paymentId, properties, callContext);
// getPaymentInfo mock is not implemented (yet)
//Assert.assertEquals(retrievedPaymentTransactionInfoPlugin.get(0).getStatus(), PaymentPluginStatus.PROCESSED);
}

12. TestDefaultControlTagCreationEvent#testSerialization()

View license
@Test(groups = "fast")
public void testSerialization() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();
    final UUID tagId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = UUID.randomUUID();
    final DefaultControlTagCreationEvent event = new DefaultControlTagCreationEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID());
    final String json = objectMapper.writeValueAsString(event);
    final DefaultControlTagCreationEvent fromJson = objectMapper.readValue(json, DefaultControlTagCreationEvent.class);
    Assert.assertEquals(fromJson, event);
}

13. TestDefaultControlTagDeletionEvent#testSerialization()

View license
@Test(groups = "fast")
public void testSerialization() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();
    final UUID tagId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = UUID.randomUUID();
    final DefaultControlTagDeletionEvent event = new DefaultControlTagDeletionEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID());
    final String json = objectMapper.writeValueAsString(event);
    final DefaultControlTagDeletionEvent fromJson = objectMapper.readValue(json, DefaultControlTagDeletionEvent.class);
    Assert.assertEquals(fromJson, event);
}

14. TestDefaultUserTagCreationEvent#testSerialization()

View license
@Test(groups = "fast")
public void testSerialization() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();
    final UUID tagId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = UUID.randomUUID();
    final DefaultUserTagCreationEvent event = new DefaultUserTagCreationEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID());
    final String json = objectMapper.writeValueAsString(event);
    final DefaultUserTagCreationEvent fromJson = objectMapper.readValue(json, DefaultUserTagCreationEvent.class);
    Assert.assertEquals(fromJson, event);
}

15. TestDefaultUserTagDeletionEvent#testSerialization()

View license
@Test(groups = "fast")
public void testSerialization() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();
    final UUID tagId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = UUID.randomUUID();
    final DefaultUserTagDeletionEvent event = new DefaultUserTagDeletionEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID());
    final String json = objectMapper.writeValueAsString(event);
    final DefaultUserTagDeletionEvent fromJson = objectMapper.readValue(json, DefaultUserTagDeletionEvent.class);
    Assert.assertEquals(fromJson, event);
}

16. TestTagEventBuilder#testNewUserTagCreationEvent()

Project: killbill
Source File: TestTagEventBuilder.java
View license
@Test(groups = "fast")
public void testNewUserTagCreationEvent() throws Exception {
    final UUID tagId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = internalCallContext.getUserToken();
    final TagEventBuilder tagEventBuilder = new TagEventBuilder();
    final TagInternalEvent event = tagEventBuilder.newUserTagCreationEvent(tagId, objectId, objectType, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
    Assert.assertTrue(event instanceof UserTagCreationInternalEvent);
    Assert.assertEquals(event, new DefaultUserTagCreationEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(new DefaultUserTagCreationEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID())));
    verifyTagEvent(tagId, objectId, objectType, tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}

17. TestTagEventBuilder#testNewUserTagDeletionEvent()

Project: killbill
Source File: TestTagEventBuilder.java
View license
@Test(groups = "fast")
public void testNewUserTagDeletionEvent() throws Exception {
    final UUID tagId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = internalCallContext.getUserToken();
    final TagEventBuilder tagEventBuilder = new TagEventBuilder();
    final TagInternalEvent event = tagEventBuilder.newUserTagDeletionEvent(tagId, objectId, objectType, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
    Assert.assertTrue(event instanceof UserTagDeletionInternalEvent);
    Assert.assertEquals(event, new DefaultUserTagDeletionEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(new DefaultUserTagDeletionEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID())));
    verifyTagEvent(tagId, objectId, objectType, tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}

18. TestTagEventBuilder#testNewControlTagCreationEvent()

Project: killbill
Source File: TestTagEventBuilder.java
View license
@Test(groups = "fast")
public void testNewControlTagCreationEvent() throws Exception {
    final UUID tagId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final UUID tagDefinitionId = ControlTagType.AUTO_PAY_OFF.getId();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = true;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = internalCallContext.getUserToken();
    final TagEventBuilder tagEventBuilder = new TagEventBuilder();
    final TagInternalEvent event = tagEventBuilder.newControlTagCreationEvent(tagId, objectId, objectType, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
    Assert.assertTrue(event instanceof ControlTagCreationInternalEvent);
    Assert.assertEquals(event, new DefaultControlTagCreationEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(new DefaultControlTagCreationEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID())));
    verifyTagEvent(tagId, objectId, objectType, tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}

19. TestTagEventBuilder#testNewControlTagDeletionEvent()

Project: killbill
Source File: TestTagEventBuilder.java
View license
@Test(groups = "fast")
public void testNewControlTagDeletionEvent() throws Exception {
    final UUID tagId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final UUID tagDefinitionId = ControlTagType.AUTO_PAY_OFF.getId();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = true;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = internalCallContext.getUserToken();
    final TagEventBuilder tagEventBuilder = new TagEventBuilder();
    final TagInternalEvent event = tagEventBuilder.newControlTagDeletionEvent(tagId, objectId, objectType, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
    Assert.assertTrue(event instanceof ControlTagDeletionInternalEvent);
    Assert.assertEquals(event, new DefaultControlTagDeletionEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(new DefaultControlTagDeletionEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID())));
    verifyTagEvent(tagId, objectId, objectType, tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}

20. BrokerRecovererTest#testCreateBrokerWithMultipleAuthenticationProvidersAndPorts()

Project: qpid-java
Source File: BrokerRecovererTest.java
View license
public void testCreateBrokerWithMultipleAuthenticationProvidersAndPorts() {
    UUID authProviderId = UUID.randomUUID();
    UUID portId = UUID.randomUUID();
    UUID authProvider2Id = UUID.randomUUID();
    UUID port2Id = UUID.randomUUID();
    resolveObjects(_brokerEntry, createAuthProviderRecord(authProviderId, "authProvider"), createPortRecord(portId, 5672, "authProvider"), createAuthProviderRecord(authProvider2Id, "authProvider2"), createPortRecord(port2Id, 5673, "authProvider2"));
    Broker<?> broker = _systemConfig.getBroker();
    assertNotNull(broker);
    broker.open();
    assertEquals(_brokerId, broker.getId());
    assertEquals(2, broker.getPorts().size());
    assertEquals("Unexpected number of authentication providers", 2, broker.getAuthenticationProviders().size());
}

21. V1MarshallerTest#testUuidSet()

Project: aws-sdk-java
Source File: V1MarshallerTest.java
View license
@Test
public void testUuidSet() {
    final UUID one = UUID.randomUUID();
    final UUID two = UUID.randomUUID();
    final UUID three = UUID.randomUUID();
    assertEquals(Collections.singletonList(one.toString()), convert("getUuidSet", Collections.singleton(one)).getSS());
    assertEquals(Collections.singletonList(two.toString()), convert("getUuidSet", Collections.singleton(two)).getSS());
    assertEquals(Arrays.asList(one.toString(), two.toString(), three.toString()), convert("getUuidSet", new LinkedHashSet<UUID>() {

        {
            add(one);
            add(two);
            add(three);
        }
    }).getSS());
}

22. V2CompatMarshallerTest#testUuidSet()

View license
@Test
public void testUuidSet() {
    final UUID one = UUID.randomUUID();
    final UUID two = UUID.randomUUID();
    final UUID three = UUID.randomUUID();
    assertEquals(Collections.singletonList(one.toString()), convert("getUuidSet", Collections.singleton(one)).getSS());
    assertEquals(Collections.singletonList(two.toString()), convert("getUuidSet", Collections.singleton(two)).getSS());
    assertEquals(Arrays.asList(one.toString(), two.toString(), three.toString()), convert("getUuidSet", new LinkedHashSet<UUID>() {

        {
            add(one);
            add(two);
            add(three);
        }
    }).getSS());
}

23. V2MarshallerTest#testUuidSet()

Project: aws-sdk-java
Source File: V2MarshallerTest.java
View license
@Test
public void testUuidSet() {
    final UUID one = UUID.randomUUID();
    final UUID two = UUID.randomUUID();
    final UUID three = UUID.randomUUID();
    assertEquals(Collections.singletonList(one.toString()), convert("getUuidSet", Collections.singleton(one)).getSS());
    assertEquals(Collections.singletonList(two.toString()), convert("getUuidSet", Collections.singleton(two)).getSS());
    assertEquals(Arrays.asList(one.toString(), two.toString(), three.toString()), convert("getUuidSet", new LinkedHashSet<UUID>() {

        {
            add(one);
            add(two);
            add(three);
        }
    }).getSS());
}

24. TimeUUIDTypeTest#testSmaller()

Project: cassandra
Source File: TimeUUIDTypeTest.java
View license
@Test
public void testSmaller() {
    UUID a = UUIDGen.getTimeUUID();
    UUID b = UUIDGen.getTimeUUID();
    UUID c = UUIDGen.getTimeUUID();
    timeUUIDType.validate(ByteBuffer.wrap(UUIDGen.decompose(a)));
    timeUUIDType.validate(ByteBuffer.wrap(UUIDGen.decompose(b)));
    timeUUIDType.validate(ByteBuffer.wrap(UUIDGen.decompose(c)));
    assert timeUUIDType.compare(ByteBuffer.wrap(UUIDGen.decompose(a)), ByteBuffer.wrap(UUIDGen.decompose(b))) < 0;
    assert timeUUIDType.compare(ByteBuffer.wrap(UUIDGen.decompose(b)), ByteBuffer.wrap(UUIDGen.decompose(c))) < 0;
    assert timeUUIDType.compare(ByteBuffer.wrap(UUIDGen.decompose(a)), ByteBuffer.wrap(UUIDGen.decompose(c))) < 0;
}

25. TimeUUIDTypeTest#testBigger()

Project: cassandra
Source File: TimeUUIDTypeTest.java
View license
@Test
public void testBigger() {
    UUID a = UUIDGen.getTimeUUID();
    UUID b = UUIDGen.getTimeUUID();
    UUID c = UUIDGen.getTimeUUID();
    timeUUIDType.validate(ByteBuffer.wrap(UUIDGen.decompose(a)));
    timeUUIDType.validate(ByteBuffer.wrap(UUIDGen.decompose(b)));
    timeUUIDType.validate(ByteBuffer.wrap(UUIDGen.decompose(c)));
    assert timeUUIDType.compare(ByteBuffer.wrap(UUIDGen.decompose(c)), ByteBuffer.wrap(UUIDGen.decompose(b))) > 0;
    assert timeUUIDType.compare(ByteBuffer.wrap(UUIDGen.decompose(b)), ByteBuffer.wrap(UUIDGen.decompose(a))) > 0;
    assert timeUUIDType.compare(ByteBuffer.wrap(UUIDGen.decompose(c)), ByteBuffer.wrap(UUIDGen.decompose(a))) > 0;
}

26. RunIdsTest#testTimeBasedRunId()

Project: cdap
Source File: RunIdsTest.java
View license
@Test
public void testTimeBasedRunId() throws Exception {
    long time = System.currentTimeMillis();
    // Generate UUID based on time, and extract time from it.
    UUID uuid1 = RunIds.generateUUIDForTime(time);
    Assert.assertEquals(time, RunIds.getTime(RunIds.fromString(uuid1.toString()), TimeUnit.MILLISECONDS));
    // Generate another UUID for the same time, the new UUID should be different from the previous one.
    UUID uuid2 = RunIds.generateUUIDForTime(time);
    Assert.assertEquals(time, RunIds.getTime(RunIds.fromString(uuid2.toString()), TimeUnit.MILLISECONDS));
    Assert.assertNotEquals(uuid1.toString(), uuid2.toString());
    // Generate UUID for a different time
    long newTime = time + 1;
    UUID uuid3 = RunIds.generateUUIDForTime(newTime);
    Assert.assertEquals(newTime, RunIds.getTime(RunIds.fromString(uuid3.toString()), TimeUnit.MILLISECONDS));
    Assert.assertNotEquals(uuid1.toString(), uuid3.toString());
    Assert.assertNotEquals(uuid2.toString(), uuid3.toString());
    // Time from a random UUID should be -1
    Assert.assertEquals(-1, RunIds.getTime(RunIds.fromString(UUID.randomUUID().toString()), TimeUnit.MILLISECONDS));
}

27. TestEventJson#testBusExternalEvent()

Project: killbill
Source File: TestEventJson.java
View license
@Test(groups = "fast")
public void testBusExternalEvent() throws Exception {
    final UUID objectId = UUID.randomUUID();
    final UUID accountId = UUID.randomUUID();
    final UUID tenantId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT;
    final ExtBusEventType extBusEventType = ExtBusEventType.ACCOUNT_CREATION;
    final DefaultBusExternalEvent e = new DefaultBusExternalEvent(objectId, objectType, extBusEventType, accountId, tenantId, null, 1L, 2L, UUID.randomUUID());
    final String json = mapper.writeValueAsString(e);
    final Class<?> claz = Class.forName(DefaultBusExternalEvent.class.getName());
    final ExtBusEvent obj = (ExtBusEvent) mapper.readValue(json, claz);
    Assert.assertEquals(obj.getAccountId(), accountId);
    Assert.assertEquals(obj.getObjectId(), objectId);
    Assert.assertEquals(obj.getTenantId(), tenantId);
    Assert.assertEquals(obj.getObjectType(), objectType);
    Assert.assertEquals(obj.getEventType(), extBusEventType);
}

28. TestInvoiceItemDao#testGetInvoiceItemsBySubscriptionId()

Project: killbill
Source File: TestInvoiceItemDao.java
View license
@Test(groups = "slow")
public void testGetInvoiceItemsBySubscriptionId() throws EntityPersistenceException {
    final UUID accountId = account.getId();
    final UUID subscriptionId = UUID.randomUUID();
    final UUID bundleId = UUID.randomUUID();
    final LocalDate startDate = new LocalDate(2011, 3, 1);
    final BigDecimal rate = new BigDecimal("20.00");
    for (int i = 0; i < 3; i++) {
        final UUID invoiceId = UUID.randomUUID();
        final RecurringInvoiceItem item = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, "test plan", "test phase", startDate.plusMonths(i), startDate.plusMonths(i + 1), rate, rate, Currency.USD);
        invoiceUtil.createInvoiceItem(item, context);
    }
    final List<InvoiceItemModelDao> items = invoiceUtil.getInvoiceItemBySubscriptionId(subscriptionId, context);
    assertEquals(items.size(), 3);
}

29. TestInvoiceItemDao#testGetInvoiceItemsByInvoiceId()

Project: killbill
Source File: TestInvoiceItemDao.java
View license
@Test(groups = "slow")
public void testGetInvoiceItemsByInvoiceId() throws EntityPersistenceException {
    final UUID accountId = account.getId();
    final UUID invoiceId = UUID.randomUUID();
    final UUID bundleId = UUID.randomUUID();
    final LocalDate startDate = new LocalDate(2011, 3, 1);
    final BigDecimal rate = new BigDecimal("20.00");
    for (int i = 0; i < 5; i++) {
        final UUID subscriptionId = UUID.randomUUID();
        final BigDecimal amount = rate.multiply(new BigDecimal(i + 1));
        final RecurringInvoiceItem item = new RecurringInvoiceItem(invoiceId, accountId, bundleId, subscriptionId, "test plan", "test phase", startDate, startDate.plusMonths(1), amount, amount, Currency.USD);
        invoiceUtil.createInvoiceItem(item, context);
    }
    final List<InvoiceItemModelDao> items = invoiceUtil.getInvoiceItemByInvoiceId(invoiceId, context);
    assertEquals(items.size(), 5);
}

30. TestInvoiceItemDao#testExternalChargeInvoiceSqlDao()

Project: killbill
Source File: TestInvoiceItemDao.java
View license
@Test(groups = "slow")
public void testExternalChargeInvoiceSqlDao() throws Exception {
    final UUID invoiceId = UUID.randomUUID();
    final UUID accountId = account.getId();
    final UUID bundleId = UUID.randomUUID();
    final String description = UUID.randomUUID().toString();
    final LocalDate startDate = new LocalDate(2012, 4, 1);
    final InvoiceItem externalChargeInvoiceItem = new ExternalChargeInvoiceItem(invoiceId, accountId, bundleId, description, startDate, TEN, Currency.USD);
    invoiceUtil.createInvoiceItem(externalChargeInvoiceItem, context);
    final InvoiceItemModelDao savedItem = invoiceUtil.getInvoiceItemById(externalChargeInvoiceItem.getId(), context);
    assertSameInvoiceItem(externalChargeInvoiceItem, savedItem);
}

31. TestSubscriptionItemTree#verifyJson()

View license
@Test(groups = "fast")
public void verifyJson() throws IOException {
    final SubscriptionItemTree tree = new SubscriptionItemTree(subscriptionId, invoiceId);
    final UUID id1 = UUID.fromString("e8ba6ce7-9bd4-417d-af53-70951ecaa99f");
    final InvoiceItem yearly1 = new RecurringInvoiceItem(id1, new DateTime(), invoiceId, accountId, bundleId, subscriptionId, planName, phaseName, new LocalDate("2014-01-01"), new LocalDate("2015-01-01"), BigDecimal.TEN, BigDecimal.TEN, currency);
    tree.addItem(yearly1);
    final UUID id2 = UUID.fromString("48db1317-9a6e-4666-bcc5-fc7d3d0defc8");
    final InvoiceItem newItem = new RecurringInvoiceItem(id2, new DateTime(), invoiceId, accountId, bundleId, subscriptionId, "other-plan", "other-plan", new LocalDate("2014-08-01"), new LocalDate("2015-01-01"), BigDecimal.ONE, BigDecimal.ONE, currency);
    tree.addItem(newItem);
    final UUID id3 = UUID.fromString("02ec57f5-2723-478b-86ba-ebeaedacb9db");
    final InvoiceItem repair = new RepairAdjInvoiceItem(id3, new DateTime(), invoiceId, accountId, new LocalDate("2014-08-01"), new LocalDate("2015-01-01"), BigDecimal.TEN.negate(), currency, yearly1.getId());
    tree.addItem(repair);
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    tree.getRoot().jsonSerializeTree(new ObjectMapper(), outputStream);
    final String json = outputStream.toString("UTF-8");
    final String expectedJson = "[{\"start\":\"2014-01-01\",\"end\":\"2015-01-01\",\"items\":[{\"id\":\"e8ba6ce7-9bd4-417d-af53-70951ecaa99f\",\"startDate\":\"2014-01-01\",\"endDate\":\"2015-01-01\",\"amount\":10.00,\"currency\":\"USD\",\"linkedId\":null,\"action\":\"ADD\"}]},[{\"start\":\"2014-08-01\",\"end\":\"2015-01-01\",\"items\":[{\"id\":\"48db1317-9a6e-4666-bcc5-fc7d3d0defc8\",\"startDate\":\"2014-08-01\",\"endDate\":\"2015-01-01\",\"amount\":1.00,\"currency\":\"USD\",\"linkedId\":null,\"action\":\"ADD\"},{\"id\":\"02ec57f5-2723-478b-86ba-ebeaedacb9db\",\"startDate\":\"2014-08-01\",\"endDate\":\"2015-01-01\",\"amount\":10.00,\"currency\":\"USD\",\"linkedId\":\"e8ba6ce7-9bd4-417d-af53-70951ecaa99f\",\"action\":\"CANCEL\"}]}]]";
    assertEquals(json, expectedJson);
}

32. TestDefaultCustomFieldDeletionEvent#testPojo()

View license
@Test(groups = "fast")
public void testPojo() throws Exception {
    final UUID customFieldId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final UUID userToken = UUID.randomUUID();
    final DefaultCustomFieldDeletionEvent event = new DefaultCustomFieldDeletionEvent(customFieldId, objectId, objectType, 1L, 2L, UUID.randomUUID());
    Assert.assertEquals(event.getBusEventType(), BusInternalEventType.CUSTOM_FIELD_DELETION);
    Assert.assertEquals(event.getObjectId(), objectId);
    Assert.assertEquals(event.getObjectType(), objectType);
    Assert.assertEquals(event, event);
    Assert.assertEquals(event, new DefaultCustomFieldDeletionEvent(customFieldId, objectId, objectType, 1L, 2L, UUID.randomUUID()));
}

33. TestDefaultCustomFieldDeletionEvent#testSerialization()

View license
@Test(groups = "fast")
public void testSerialization() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();
    final UUID customFieldId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final UUID userToken = UUID.randomUUID();
    final DefaultCustomFieldDeletionEvent event = new DefaultCustomFieldDeletionEvent(customFieldId, objectId, objectType, 1L, 2L, UUID.randomUUID());
    final String json = objectMapper.writeValueAsString(event);
    final DefaultCustomFieldDeletionEvent fromJson = objectMapper.readValue(json, DefaultCustomFieldDeletionEvent.class);
    Assert.assertEquals(fromJson, event);
}

34. TimeUUIDTypeTest#testSmaller()

View license
@Test
public void testSmaller() {
    UUID a = UUIDGen.getTimeUUID();
    UUID b = UUIDGen.getTimeUUID();
    UUID c = UUIDGen.getTimeUUID();
    timeUUIDType.validate(ByteBuffer.wrap(UUIDGen.decompose(a)));
    timeUUIDType.validate(ByteBuffer.wrap(UUIDGen.decompose(b)));
    timeUUIDType.validate(ByteBuffer.wrap(UUIDGen.decompose(c)));
    assert timeUUIDType.compare(ByteBuffer.wrap(UUIDGen.decompose(a)), ByteBuffer.wrap(UUIDGen.decompose(b))) < 0;
    assert timeUUIDType.compare(ByteBuffer.wrap(UUIDGen.decompose(b)), ByteBuffer.wrap(UUIDGen.decompose(c))) < 0;
    assert timeUUIDType.compare(ByteBuffer.wrap(UUIDGen.decompose(a)), ByteBuffer.wrap(UUIDGen.decompose(c))) < 0;
}

35. TimeUUIDTypeTest#testBigger()

View license
@Test
public void testBigger() {
    UUID a = UUIDGen.getTimeUUID();
    UUID b = UUIDGen.getTimeUUID();
    UUID c = UUIDGen.getTimeUUID();
    timeUUIDType.validate(ByteBuffer.wrap(UUIDGen.decompose(a)));
    timeUUIDType.validate(ByteBuffer.wrap(UUIDGen.decompose(b)));
    timeUUIDType.validate(ByteBuffer.wrap(UUIDGen.decompose(c)));
    assert timeUUIDType.compare(ByteBuffer.wrap(UUIDGen.decompose(c)), ByteBuffer.wrap(UUIDGen.decompose(b))) > 0;
    assert timeUUIDType.compare(ByteBuffer.wrap(UUIDGen.decompose(b)), ByteBuffer.wrap(UUIDGen.decompose(a))) > 0;
    assert timeUUIDType.compare(ByteBuffer.wrap(UUIDGen.decompose(c)), ByteBuffer.wrap(UUIDGen.decompose(a))) > 0;
}

36. UuidEntityManagerTest#uuid_updates_work()

View license
@Test
public void uuid_updates_work() {
    UuidEntityManager uuidManager = new UuidEntityManager();
    World world = new World(new WorldConfiguration().setSystem(uuidManager));
    Entity entity = world.createEntity();
    UUID uuid0 = uuidManager.getUuid(entity);
    Assert.assertNotNull(uuid0);
    UUID uuid1 = UUID.randomUUID();
    assertEquals(uuid0, uuidManager.getUuid(entity));
    uuidManager.setUuid(entity, uuid1);
    assertEquals(uuid1, uuidManager.getUuid(entity));
    assertNotEquals(uuid0, uuid1);
    assertNull(uuidManager.getEntity(uuid0));
    assertEquals(entity, uuidManager.getEntity(uuid1));
}

37. TimeUUIDTest#testAddMicrosReslution()

Project: astyanax
Source File: TimeUUIDTest.java
View license
@Test
public void testAddMicrosReslution() {
    UUID uuid = TimeUUIDUtils.getUniqueTimeUUIDinMicros();
    long uuidTime = TimeUUIDUtils.getMicrosTimeFromUUID(uuid);
    UUID uuidPlusOneDay = TimeUUIDUtils.getMicrosTimeUUID(uuidTime + TimeUnit.DAYS.toMicros(1));
    long uuidTimePlusOneDay = TimeUUIDUtils.getMicrosTimeFromUUID(uuidPlusOneDay);
    Assert.assertEquals(TimeUnit.DAYS.toMicros(1), uuidTimePlusOneDay - uuidTime);
}

38. UnmarshallerTest#testUuidSet()

Project: aws-sdk-java
Source File: UnmarshallerTest.java
View license
@Test
public void testUuidSet() {
    Assert.assertNull(unconvert("getUuidSet", "setUuidSet", new AttributeValue().withNULL(true)));
    final UUID one = UUID.randomUUID();
    final UUID two = UUID.randomUUID();
    assertEquals(new HashSet<UUID>() {

        {
            add(one);
            add(two);
        }
    }, unconvert("getUuidSet", "setUuidSet", new AttributeValue().withSS(one.toString(), two.toString())));
}

39. ContentFormFields#doService()

View license
@Override
@SuppressWarnings("unchecked")
protected void doService(ToolPageContext page) throws IOException, ServletException {
    UUID typeId = page.param(UUID.class, "typeId");
    UUID id = page.param(UUID.class, "id");
    String data = page.param(String.class, "data");
    Object object = ObjectType.getInstance(typeId).createObject(id);
    State.getInstance(object).setResolveInvisible(true);
    if (data != null) {
        State.getInstance(object).putAll((Map<String, Object>) ObjectUtils.fromJson(data));
    }
    page.writeFormFields(object);
}

40. RemoteWidgetFilter#createObject()

View license
// --- AbstractFilter support ---
// Creates an object that originates from the given {@code database}
// based on the given {@code json} string.
private Object createObject(Database database, String json) {
    @SuppressWarnings("unchecked") Map<String, Object> jsonValues = (Map<String, Object>) ObjectUtils.fromJson(json);
    UUID id = ObjectUtils.to(UUID.class, jsonValues.remove("_id"));
    UUID typeId = ObjectUtils.to(UUID.class, jsonValues.remove("_typeId"));
    ObjectType type = database.getEnvironment().getTypeById(typeId);
    if (type == null) {
        throw new IllegalArgumentException(String.format("[%s] is not a valid type ID!", typeId));
    } else {
        Object object = type.createObject(id);
        State state = State.getInstance(object);
        state.setResolveInvisible(true);
        state.setValues(jsonValues);
        return object;
    }
}

41. Utils#getDeviceId()

Project: CallerInfo
Source File: Utils.java
View license
public static String getDeviceId(Context context) {
    final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    final String tmDevice, tmSerial, androidId;
    tmDevice = "" + tm.getDeviceId();
    tmSerial = "" + tm.getSimSerialNumber();
    androidId = "" + Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
    UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    return deviceUuid.toString();
}

42. CreateTest#testSparseCompositeTable()

Project: cassandra
Source File: CreateTest.java
View license
/**
     * Creation and basic operations on a composite table,
     * migrated from cql_tests.py:TestCQL.sparse_cf_test()
     */
@Test
public void testSparseCompositeTable() throws Throwable {
    createTable("CREATE TABLE %s (userid uuid, posted_month int, posted_day int, body text, posted_by text, PRIMARY KEY (userid, posted_month, posted_day))");
    UUID id1 = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
    UUID id2 = UUID.fromString("f47ac10b-58cc-4372-a567-0e02b2c3d479");
    execute("INSERT INTO %s (userid, posted_month, posted_day, body, posted_by) VALUES (?, 1, 12, 'Something else', 'Frodo Baggins')", id1);
    execute("INSERT INTO %s (userid, posted_month, posted_day, body, posted_by) VALUES (?, 1, 24, 'Something something', 'Frodo Baggins')", id1);
    execute("UPDATE %s SET body = 'Yo Froddo', posted_by = 'Samwise Gamgee' WHERE userid = ? AND posted_month = 1 AND posted_day = 3", id2);
    execute("UPDATE %s SET body = 'Yet one more message' WHERE userid = ? AND posted_month = 1 and posted_day = 30", id1);
    assertRows(execute("SELECT body, posted_by FROM %s WHERE userid = ? AND posted_month = 1 AND posted_day = 24", id1), row("Something something", "Frodo Baggins"));
    assertRows(execute("SELECT posted_day, body, posted_by FROM %s WHERE userid = ? AND posted_month = 1 AND posted_day > 12", id1), row(24, "Something something", "Frodo Baggins"), row(30, "Yet one more message", null));
    assertRows(execute("SELECT posted_day, body, posted_by FROM %s WHERE userid = ? AND posted_month = 1", id1), row(12, "Something else", "Frodo Baggins"), row(24, "Something something", "Frodo Baggins"), row(30, "Yet one more message", null));
}

43. SelectTest#testSelectKeyIn()

Project: cassandra
Source File: SelectTest.java
View license
/**
     * Check query with KEY IN clause
     * migrated from cql_tests.py:TestCQL.select_key_in_test()
     */
@Test
public void testSelectKeyIn() throws Throwable {
    createTable("CREATE TABLE %s (userid uuid PRIMARY KEY, firstname text, lastname text, age int)");
    UUID id1 = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
    UUID id2 = UUID.fromString("f47ac10b-58cc-4372-a567-0e02b2c3d479");
    execute("INSERT INTO %s (userid, firstname, lastname, age) VALUES (?, 'Frodo', 'Baggins', 32)", id1);
    execute("INSERT INTO %s (userid, firstname, lastname, age) VALUES (?, 'Samwise', 'Gamgee', 33)", id2);
    assertRowCount(execute("SELECT firstname, lastname FROM %s WHERE userid IN (?, ?)", id1, id2), 2);
}

44. RoundTripTest#testTimeUUID()

Project: cassandra
Source File: RoundTripTest.java
View license
@Test
public void testTimeUUID() {
    UUID uuid = UUIDGen.getTimeUUID();
    assert TimeUUIDType.instance.getString(TimeUUIDType.instance.fromString(uuid.toString())).equals(uuid.toString());
    assert TimeUUIDType.instance.fromString(TimeUUIDType.instance.getString(ByteBuffer.wrap(UUIDGen.decompose(uuid)))).equals(ByteBuffer.wrap(UUIDGen.decompose(uuid)));
    assert TimeUUIDType.instance.compose(ByteBuffer.wrap(UUIDGen.decompose(uuid))).equals(uuid);
    assert uuid.equals(TimeUUIDType.instance.compose(TimeUUIDType.instance.fromString(uuid.toString())));
    assert UUIDSerializer.instance.toString(uuid).equals(uuid.toString());
}

45. TypeCompareTest#testTimeUUID()

Project: cassandra
Source File: TypeCompareTest.java
View license
@Test
public void testTimeUUID() {
    // two different UUIDs w/ the same timestamp
    UUID uuid1 = UUID.fromString("1077e700-c7f2-11de-86d5-f5bcc793a028");
    byte[] bytes1 = new byte[16];
    ByteBuffer bb1 = ByteBuffer.wrap(bytes1);
    bb1.putLong(uuid1.getMostSignificantBits());
    bb1.putLong(uuid1.getLeastSignificantBits());
    UUID uuid2 = UUID.fromString("1077e700-c7f2-11de-982e-6fad363d5f29");
    byte[] bytes2 = new byte[16];
    ByteBuffer bb2 = ByteBuffer.wrap(bytes2);
    bb2.putLong(uuid2.getMostSignificantBits());
    bb2.putLong(uuid2.getLeastSignificantBits());
    assert new TimeUUIDType().compare(ByteBuffer.wrap(bytes1), ByteBuffer.wrap(bytes2)) != 0;
}

46. ASMDatumCodecTest#testUUID()

Project: cdap
Source File: ASMDatumCodecTest.java
View license
@Test
public void testUUID() throws UnsupportedTypeException, IOException {
    TypeToken<UUID> type = new TypeToken<UUID>() {
    };
    PipedOutputStream os = new PipedOutputStream();
    PipedInputStream is = new PipedInputStream(os);
    DatumWriter<UUID> writer = getWriter(type);
    UUID uuid = UUID.randomUUID();
    writer.encode(uuid, new BinaryEncoder(os));
    ReflectionDatumReader<UUID> reader = new ReflectionDatumReader<>(getSchema(type), type);
    UUID value = reader.read(new BinaryDecoder(is), getSchema(type));
    Assert.assertEquals(uuid, value);
}

47. EnderRailController#doTick()

Project: EnderIO
Source File: EnderRailController.java
View license
public void doTick() {
    if (cartList != null) {
        loadCartsToSpawn();
        cartList = null;
    }
    spawnRecievedCart();
    List<EntityMinecart> carts = getMinecartsOnTrack();
    List<UUID> toRemove = new ArrayList<UUID>();
    //any cart in the newly spawned list no longer on the track needs to be removed    
    for (UUID recievedCartUID : newlySpawnedCarts) {
        EntityMinecart minecart = getMinecartWthUUID(recievedCartUID, carts);
        if (minecart == null) {
            toRemove.add(recievedCartUID);
        }
    }
    for (UUID recievedCart : toRemove) {
        newlySpawnedCarts.remove(recievedCart);
    }
}

48. RailcraftLinkUtil#recreateLink()

Project: EnderIO
Source File: RailcraftLinkUtil.java
View license
public void recreateLink(EntityMinecart existingCart, EntityMinecart newCart) {
    if (existingCart == null || newCart == null) {
        return;
    }
    ILinkageManager linkMan = CartTools.getLinkageManager(existingCart.worldObj);
    if (linkMan == null) {
        return;
    }
    UUID linkA = getLinkA(newCart);
    if (linkA != null && linkA.equals(existingCart.getPersistentID())) {
        if (!linkMan.areLinked(existingCart, newCart)) {
            boolean res = linkMan.createLink(existingCart, newCart);
        }
        return;
    }
    UUID linkB = getLinkB(newCart);
    if (linkB != null && linkB.equals(existingCart.getPersistentID())) {
        if (!linkMan.areLinked(existingCart, newCart)) {
            boolean res = linkMan.createLink(existingCart, newCart);
        }
        return;
    }
}

49. PlayerUtil#isSameGameProfile()

Project: ForestryMC
Source File: PlayerUtil.java
View license
public static boolean isSameGameProfile(GameProfile player1, GameProfile player2) {
    if (player1 == null || player2 == null) {
        return false;
    }
    UUID id1 = player1.getId();
    UUID id2 = player2.getId();
    if (id1 != null && id2 != null && !id1.equals(emptyUUID) && !id2.equals(emptyUUID)) {
        return id1.equals(id2);
    }
    return player1.getName() != null && player1.getName().equals(player2.getName());
}

50. TimeUUIDUtilsTest#testTimeUUIDWithClockResolution()

Project: hector
Source File: TimeUUIDUtilsTest.java
View license
/**
   * This test must be placed FIRST. Please don't change the order.
   * @throws Exception
   */
@Test
@Ignore
public void testTimeUUIDWithClockResolution() throws Exception {
    ClockResolution clock = new MicrosecondsClockResolution();
    long time = clock.createClock();
    // Invoke twice with same time. Both generated UUID should be the same.
    // Test improved algorithm.
    assertEquals(TimeUUIDUtils.getTimeUUID(time), java.util.UUID.fromString(new com.eaio.uuid.UUID(UUIDGen.createTime(time), UUIDGen.getClockSeqAndNode()).toString()));
    clock = new MicrosecondsSyncClockResolution();
    // Invoke twice with a clockResolution that guarantees unique timestamp. The second must be greater
    // than the first one.
    java.util.UUID first = TimeUUIDUtils.getTimeUUID(clock);
    java.util.UUID second = TimeUUIDUtils.getTimeUUID(clock);
    assertTrue(second.compareTo(first) > 0);
}

51. GridClockMessage#fromBytes()

Project: ignite
Source File: GridClockMessage.java
View license
/**
     * Constructs message from bytes.
     *
     * @param buf Bytes.
     * @param off Offset.
     * @param len Packet length.
     * @return Assembled message.
     * @throws IgniteCheckedException If message length is invalid.
     */
public static GridClockMessage fromBytes(byte[] buf, int off, int len) throws IgniteCheckedException {
    if (len < PACKET_SIZE)
        throw new IgniteCheckedException("Failed to assemble time server packet (message is too short).");
    long lsb = U.bytesToLong(buf, off);
    long msb = U.bytesToLong(buf, off + 8);
    UUID origNodeId = new UUID(msb, lsb);
    lsb = U.bytesToLong(buf, off + 16);
    msb = U.bytesToLong(buf, off + 24);
    UUID targetNodeId = new UUID(msb, lsb);
    long origTs = U.bytesToLong(buf, off + 32);
    long replyTs = U.bytesToLong(buf, off + 40);
    return new GridClockMessage(origNodeId, targetNodeId, origTs, replyTs);
}

52. GridAffinitySelfTest#testAffinity()

Project: ignite
Source File: GridAffinitySelfTest.java
View license
/**
     * @throws IgniteCheckedException If failed.
     */
public void testAffinity() throws Exception {
    Ignite g1 = grid(1);
    Ignite g2 = grid(2);
    assert caches(g1).size() == 0;
    assert F.first(caches(g2)).getCacheMode() == PARTITIONED;
    awaitPartitionMapExchange();
    Map<ClusterNode, Collection<String>> map = g1.<String>affinity(null).mapKeysToNodes(F.asList("1"));
    assertNotNull(map);
    assertEquals("Invalid map size: " + map.size(), 1, map.size());
    assertEquals(F.first(map.keySet()), g2.cluster().localNode());
    UUID id1 = g1.affinity(null).mapKeyToNode("2").id();
    assertNotNull(id1);
    assertEquals(g2.cluster().localNode().id(), id1);
    UUID id2 = g1.affinity(null).mapKeyToNode("3").id();
    assertNotNull(id2);
    assertEquals(g2.cluster().localNode().id(), id2);
}

53. GridNodeFilterSelfTest#testSynchronousExecute()

Project: ignite
Source File: GridNodeFilterSelfTest.java
View license
/**
     * @throws Exception If failed.
     */
public void testSynchronousExecute() throws Exception {
    UUID nodeId = ignite.cluster().localNode().id();
    UUID rmtNodeId = rmtIgnite.cluster().localNode().id();
    Collection<ClusterNode> locNodes = ignite.cluster().forNodeId(nodeId).nodes();
    assert locNodes.size() == 1;
    assert locNodes.iterator().next().id().equals(nodeId);
    Collection<ClusterNode> rmtNodes = ignite.cluster().forNodeId(rmtNodeId).nodes();
    assert rmtNodes.size() == 1;
    assert rmtNodes.iterator().next().id().equals(rmtNodeId);
}

54. HadoopJobTracker#printPlan()

Project: ignite
Source File: HadoopJobTracker.java
View license
/**
     * @param jobId  Job ID.
     * @param plan Map-reduce plan.
     */
@SuppressWarnings({ "unused", "ConstantConditions" })
private void printPlan(HadoopJobId jobId, HadoopMapReducePlan plan) {
    log.info("Plan for " + jobId);
    SB b = new SB();
    b.a("   Map: ");
    for (UUID nodeId : plan.mapperNodeIds()) b.a(nodeId).a("=").a(plan.mappers(nodeId).size()).a(' ');
    log.info(b.toString());
    b = new SB();
    b.a("   Reduce: ");
    for (UUID nodeId : plan.reducerNodeIds()) b.a(nodeId).a("=").a(Arrays.toString(plan.reducers(nodeId))).a(' ');
    log.info(b.toString());
}

55. SchemaAgreementTest#should_check_agreement_through_cluster_metadata()

View license
@Test(groups = "short")
public void should_check_agreement_through_cluster_metadata() {
    Cluster controlCluster = register(TestUtils.buildControlCluster(cluster(), ccm()));
    Session controlSession = controlCluster.connect();
    Row localRow = controlSession.execute("SELECT schema_version FROM system.local").one();
    UUID localVersion = localRow.getUUID("schema_version");
    Row peerRow = controlSession.execute("SELECT peer, schema_version FROM system.peers").one();
    InetAddress peerAddress = peerRow.getInet("peer");
    UUID peerVersion = peerRow.getUUID("schema_version");
    // The two nodes should be in agreement at this point, but check just in case:
    assertThat(localVersion).isEqualTo(peerVersion);
    // Now check the method under test:
    assertThat(cluster().getMetadata().checkSchemaAgreement()).isTrue();
    // Insert a fake version to simulate a disagreement:
    forceSchemaVersion(controlSession, peerAddress, UUIDs.random());
    assertThat(cluster().getMetadata().checkSchemaAgreement()).isFalse();
    forceSchemaVersion(controlSession, peerAddress, peerVersion);
}

56. SessionInfoTest#equalsHashCodeTest()

Project: kaa
Source File: SessionInfoTest.java
View license
@Test
public void equalsHashCodeTest() {
    UUID uuid1 = UUID.randomUUID();
    UUID uuid2 = UUID.randomUUID();
    SessionInfo info1 = new SessionInfo(uuid1, Constants.KAA_PLATFORM_PROTOCOL_AVRO_ID, null, null, null, null, null, null, 0, false);
    SessionInfo info2 = new SessionInfo(uuid1, Constants.KAA_PLATFORM_PROTOCOL_AVRO_ID, null, null, null, null, null, null, 0, false);
    SessionInfo info3 = new SessionInfo(uuid2, Constants.KAA_PLATFORM_PROTOCOL_AVRO_ID, null, null, null, null, null, null, 0, false);
    SessionInfo info4 = new SessionInfo(null, Constants.KAA_PLATFORM_PROTOCOL_AVRO_ID, null, null, null, null, null, null, 0, false);
    Assert.assertEquals(info1, info2);
    Assert.assertEquals(info1.hashCode(), info2.hashCode());
    Assert.assertNotEquals(info1, info3);
    Assert.assertNotEquals(info1.hashCode(), info3.hashCode());
    Assert.assertEquals(info1, info1);
    Assert.assertNotEquals(info1, null);
    Assert.assertNotEquals(info1, new Object());
    Assert.assertNotEquals(info4, info1);
}

57. TestInvoiceDao#testAccountBalanceWithCredit()

Project: killbill
Source File: TestInvoiceDao.java
View license
@Test(groups = "slow")
public void testAccountBalanceWithCredit() throws EntityPersistenceException {
    final UUID accountId = account.getId();
    final UUID bundleId = UUID.randomUUID();
    final LocalDate targetDate1 = new LocalDate(2011, 10, 6);
    final Invoice invoice1 = new DefaultInvoice(accountId, clock.getUTCToday(), targetDate1, Currency.USD);
    invoiceUtil.createInvoice(invoice1, true, context);
    final LocalDate startDate = new LocalDate(2011, 3, 1);
    final LocalDate endDate = startDate.plusMonths(1);
    final BigDecimal rate1 = new BigDecimal("17.0");
    final RecurringInvoiceItem item1 = new RecurringInvoiceItem(invoice1.getId(), accountId, bundleId, UUID.randomUUID(), "test plan", "test phase A", startDate, endDate, rate1, rate1, Currency.USD);
    invoiceUtil.createInvoiceItem(item1, context);
    final CreditAdjInvoiceItem creditItem = new CreditAdjInvoiceItem(invoice1.getId(), accountId, new LocalDate(), rate1.negate(), Currency.USD);
    invoiceUtil.createInvoiceItem(creditItem, context);
    final BigDecimal balance = invoiceDao.getAccountBalance(accountId, context);
    assertEquals(balance.compareTo(BigDecimal.ZERO), 0);
}

58. TestInvoiceDao#testAccountBalanceWithNoPayments()

Project: killbill
Source File: TestInvoiceDao.java
View license
@Test(groups = "slow")
public void testAccountBalanceWithNoPayments() throws EntityPersistenceException {
    final UUID accountId = account.getId();
    final UUID bundleId = UUID.randomUUID();
    final LocalDate targetDate1 = new LocalDate(2011, 10, 6);
    final Invoice invoice1 = new DefaultInvoice(accountId, clock.getUTCToday(), targetDate1, Currency.USD);
    invoiceUtil.createInvoice(invoice1, true, context);
    final LocalDate startDate = new LocalDate(2011, 3, 1);
    final LocalDate endDate = startDate.plusMonths(1);
    final BigDecimal rate1 = new BigDecimal("17.0");
    final BigDecimal rate2 = new BigDecimal("42.0");
    final RecurringInvoiceItem item1 = new RecurringInvoiceItem(invoice1.getId(), accountId, bundleId, UUID.randomUUID(), "test plan", "test phase A", startDate, endDate, rate1, rate1, Currency.USD);
    invoiceUtil.createInvoiceItem(item1, context);
    final RecurringInvoiceItem item2 = new RecurringInvoiceItem(invoice1.getId(), accountId, bundleId, UUID.randomUUID(), "test plan", "test phase B", startDate, endDate, rate2, rate2, Currency.USD);
    invoiceUtil.createInvoiceItem(item2, context);
    final BigDecimal balance = invoiceDao.getAccountBalance(accountId, context);
    assertEquals(balance.compareTo(rate1.add(rate2)), 0);
}

59. TestInvoiceItemDao#testCreditBalanceInvoiceSqlDao()

Project: killbill
Source File: TestInvoiceItemDao.java
View license
@Test(groups = "slow")
public void testCreditBalanceInvoiceSqlDao() throws EntityPersistenceException {
    final UUID invoiceId = UUID.randomUUID();
    final UUID accountId = account.getId();
    final LocalDate creditDate = new LocalDate(2012, 4, 1);
    final InvoiceItem creditInvoiceItem = new CreditBalanceAdjInvoiceItem(invoiceId, accountId, creditDate, TEN, Currency.USD);
    invoiceUtil.createInvoiceItem(creditInvoiceItem, context);
    final InvoiceItemModelDao savedItem = invoiceUtil.getInvoiceItemById(creditInvoiceItem.getId(), context);
    assertSameInvoiceItem(creditInvoiceItem, savedItem);
}

60. TestInvoiceItemDao#testFixedPriceInvoiceSqlDao()

Project: killbill
Source File: TestInvoiceItemDao.java
View license
@Test(groups = "slow")
public void testFixedPriceInvoiceSqlDao() throws EntityPersistenceException {
    final UUID invoiceId = UUID.randomUUID();
    final UUID accountId = account.getId();
    final LocalDate startDate = new LocalDate(2012, 4, 1);
    final InvoiceItem fixedPriceInvoiceItem = new FixedPriceInvoiceItem(invoiceId, accountId, UUID.randomUUID(), UUID.randomUUID(), "test plan", "test phase", startDate, TEN, Currency.USD);
    invoiceUtil.createInvoiceItem(fixedPriceInvoiceItem, context);
    final InvoiceItemModelDao savedItem = invoiceUtil.getInvoiceItemById(fixedPriceInvoiceItem.getId(), context);
    assertSameInvoiceItem(fixedPriceInvoiceItem, savedItem);
}

61. TestPaymentMethodProcessorNoDB#testPaymentMethodExternalKeySetByPluginIfNonSpecified()

View license
@Test(groups = "fast")
public void testPaymentMethodExternalKeySetByPluginIfNonSpecified() throws Exception {
    final Account account = Mockito.mock(Account.class);
    final UUID accountId = UUID.randomUUID();
    Mockito.when(account.getId()).thenReturn(accountId);
    Mockito.when(account.getExternalKey()).thenReturn(accountId.toString());
    final PaymentMethodPlugin paymentMethodPlugin = Mockito.mock(PaymentMethodPlugin.class);
    final Iterable<PluginProperty> properties = ImmutableList.<PluginProperty>of();
    // By default, the external payment plugin sets the external payment method id to "unknown"
    final UUID paymentMethodId2 = paymentMethodProcessor.addPaymentMethod(null, "__EXTERNAL_PAYMENT__", account, false, paymentMethodPlugin, properties, callContext, internalCallContext);
    final PaymentMethod paymentMethod2 = paymentMethodProcessor.getPaymentMethodById(paymentMethodId2, false, false, properties, callContext, internalCallContext);
    Assert.assertEquals(paymentMethod2.getExternalKey(), "unknown");
}

62. TestPaymentMethodProcessorRefreshWithDB#testRefreshWithNewPaymentMethod()

View license
@Test(groups = "slow")
public void testRefreshWithNewPaymentMethod() throws Exception {
    final Account account = testHelper.createTestAccount("foo@bar.com", true);
    Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, PLUGIN_PROPERTIES, callContext).size(), 1);
    final UUID existingPMId = account.getPaymentMethodId();
    // Add new payment in plugin directly
    final UUID newPmId = UUID.randomUUID();
    getPluginApi().addPaymentMethod(account.getId(), newPmId, new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), false, ImmutableList.<PluginProperty>of()), false, PLUGIN_PROPERTIES, callContext);
    // Verify that the refresh does indeed show 2 PMs
    final List<PaymentMethod> methods = paymentMethodProcessor.refreshPaymentMethods(MockPaymentProviderPlugin.PLUGIN_NAME, account, PLUGIN_PROPERTIES, callContext, internalCallContext);
    Assert.assertEquals(methods.size(), 2);
    checkPaymentMethodExistsWithStatus(methods, existingPMId, true);
    checkPaymentMethodExistsWithStatus(methods, newPmId, true);
}

63. TestPaymentMethodProcessorRefreshWithDB#testRefreshWithDeletedPaymentMethod()

View license
@Test(groups = "slow")
public void testRefreshWithDeletedPaymentMethod() throws Exception {
    final Account account = testHelper.createTestAccount("super@bar.com", true);
    Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, PLUGIN_PROPERTIES, callContext).size(), 1);
    final UUID firstPmId = account.getPaymentMethodId();
    String secondPaymentMethodExternalKey = UUID.randomUUID().toString();
    final UUID secondPmId = paymentApi.addPaymentMethod(account, secondPaymentMethodExternalKey, MockPaymentProviderPlugin.PLUGIN_NAME, true, new DefaultNoOpPaymentMethodPlugin(secondPaymentMethodExternalKey, false, null), PLUGIN_PROPERTIES, callContext);
    Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, PLUGIN_PROPERTIES, callContext).size(), 2);
    Assert.assertEquals(paymentApi.getAccountPaymentMethods(account.getId(), false, PLUGIN_PROPERTIES, callContext).size(), 2);
    // Remove second PM from plugin
    getPluginApi().deletePaymentMethod(account.getId(), secondPmId, PLUGIN_PROPERTIES, callContext);
    Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, PLUGIN_PROPERTIES, callContext).size(), 1);
    Assert.assertEquals(paymentApi.getAccountPaymentMethods(account.getId(), false, PLUGIN_PROPERTIES, callContext).size(), 2);
    // Verify that the refresh sees that PM as being deleted now
    final List<PaymentMethod> methods = paymentMethodProcessor.refreshPaymentMethods(MockPaymentProviderPlugin.PLUGIN_NAME, account, PLUGIN_PROPERTIES, callContext, internalCallContext);
    Assert.assertEquals(methods.size(), 1);
    checkPaymentMethodExistsWithStatus(methods, firstPmId, true);
    final PaymentMethodModelDao deletedPMModel = paymentDao.getPaymentMethodIncludedDeleted(secondPmId, internalCallContext);
    Assert.assertNotNull(deletedPMModel);
    Assert.assertFalse(deletedPMModel.isActive());
}

64. TestDefaultNoOpPaymentInfoPlugin#testEquals()

View license
@Test(groups = "fast")
public void testEquals() throws Exception {
    final UUID kbPaymentId = UUID.randomUUID();
    final UUID kbTransactionId = UUID.randomUUID();
    final BigDecimal amount = new BigDecimal("1.394810E-3");
    final DateTime effectiveDate = clock.getUTCNow().plusDays(1);
    final DateTime createdDate = clock.getUTCNow();
    final PaymentPluginStatus status = PaymentPluginStatus.UNDEFINED;
    final String error = UUID.randomUUID().toString();
    final DefaultNoOpPaymentInfoPlugin info = new DefaultNoOpPaymentInfoPlugin(kbPaymentId, kbTransactionId, TransactionType.PURCHASE, amount, Currency.USD, effectiveDate, createdDate, status, error, null);
    Assert.assertEquals(info, info);
    final DefaultNoOpPaymentInfoPlugin sameInfo = new DefaultNoOpPaymentInfoPlugin(kbPaymentId, kbTransactionId, TransactionType.PURCHASE, amount, Currency.USD, effectiveDate, createdDate, status, error, null);
    Assert.assertEquals(sameInfo, info);
    final DefaultNoOpPaymentInfoPlugin otherInfo = new DefaultNoOpPaymentInfoPlugin(kbPaymentId, kbTransactionId, TransactionType.PURCHASE, amount, Currency.USD, effectiveDate, createdDate, status, UUID.randomUUID().toString(), null);
    Assert.assertNotEquals(otherInfo, info);
}

65. AuditLogModelDaoMapper#map()

View license
@Override
public AuditLogModelDao map(final int index, final ResultSet r, final StatementContext ctx) throws SQLException {
    final UUID id = getUUID(r, "id");
    final String tableName = r.getString("table_name");
    final long targetRecordId = r.getLong("target_record_id");
    final String changeType = r.getString("change_type");
    final DateTime createdDate = getDateTime(r, "created_date");
    final String createdBy = r.getString("created_by");
    final String reasonCode = r.getString("reason_code");
    final String comments = r.getString("comments");
    final UUID userToken = getUUID(r, "user_token");
    final EntityAudit entityAudit = new EntityAudit(id, TableName.valueOf(tableName), targetRecordId, ChangeType.valueOf(changeType), createdDate);
    // TODO - we have the tenant_record_id but not the tenant id here
    final CallContext callContext = new DefaultCallContext(null, createdBy, createdDate, reasonCode, comments, userToken);
    return new AuditLogModelDao(entityAudit, callContext);
}

66. TestDefaultAuditLog#testGetters()

Project: killbill
Source File: TestDefaultAuditLog.java
View license
@Test(groups = "fast")
public void testGetters() throws Exception {
    final TableName tableName = TableName.ACCOUNT_EMAIL_HISTORY;
    final long recordId = Long.MAX_VALUE;
    final ChangeType changeType = ChangeType.DELETE;
    final EntityAudit entityAudit = new EntityAudit(tableName, recordId, changeType, null);
    final UUID tenantId = UUID.randomUUID();
    final String userName = UUID.randomUUID().toString();
    final CallOrigin callOrigin = CallOrigin.EXTERNAL;
    final UserType userType = UserType.CUSTOMER;
    final UUID userToken = UUID.randomUUID();
    final ClockMock clock = new ClockMock();
    final CallContext callContext = new DefaultCallContext(tenantId, userName, callOrigin, userType, userToken, clock);
    final AuditLog auditLog = new DefaultAuditLog(new AuditLogModelDao(entityAudit, callContext), ObjectType.ACCOUNT_EMAIL, UUID.randomUUID());
    Assert.assertEquals(auditLog.getChangeType(), changeType);
    Assert.assertNull(auditLog.getComment());
    Assert.assertNotNull(auditLog.getCreatedDate());
    Assert.assertNull(auditLog.getReasonCode());
    Assert.assertEquals(auditLog.getUserName(), userName);
    Assert.assertEquals(auditLog.getUserToken(), userToken.toString());
}

67. TestDefaultCallContext#testGetters()

View license
@Test(groups = "fast")
public void testGetters() throws Exception {
    final UUID tenantId = UUID.randomUUID();
    final String userName = UUID.randomUUID().toString();
    final DateTime createdDate = clock.getUTCNow();
    final String reasonCode = UUID.randomUUID().toString();
    final String comment = UUID.randomUUID().toString();
    final UUID userToken = UUID.randomUUID();
    final DefaultCallContext callContext = new DefaultCallContext(tenantId, userName, createdDate, reasonCode, comment, userToken);
    Assert.assertEquals(callContext.getTenantId(), tenantId);
    Assert.assertEquals(callContext.getCreatedDate(), createdDate);
    Assert.assertNull(callContext.getCallOrigin());
    Assert.assertEquals(callContext.getComments(), comment);
    Assert.assertEquals(callContext.getReasonCode(), reasonCode);
    Assert.assertEquals(callContext.getUserName(), userName);
    Assert.assertEquals(callContext.getUpdatedDate(), createdDate);
    Assert.assertEquals(callContext.getUserToken(), userToken);
    Assert.assertNull(callContext.getUserType());
}

68. TestDefaultCallContext#testEquals()

View license
@Test(groups = "fast")
public void testEquals() throws Exception {
    final UUID tenantId = UUID.randomUUID();
    final String userName = UUID.randomUUID().toString();
    final DateTime createdDate = clock.getUTCNow();
    final String reasonCode = UUID.randomUUID().toString();
    final String comment = UUID.randomUUID().toString();
    final UUID userToken = UUID.randomUUID();
    final DefaultCallContext callContext = new DefaultCallContext(tenantId, userName, createdDate, reasonCode, comment, userToken);
    Assert.assertEquals(callContext, callContext);
    final DefaultCallContext sameCallContext = new DefaultCallContext(tenantId, userName, createdDate, reasonCode, comment, userToken);
    Assert.assertEquals(sameCallContext, callContext);
    final DefaultCallContext otherCallContext = new DefaultCallContext(tenantId, UUID.randomUUID().toString(), createdDate, reasonCode, comment, userToken);
    Assert.assertNotEquals(otherCallContext, callContext);
}

69. TestDefaultCustomFieldCreationEvent#testPojo()

View license
@Test(groups = "fast")
public void testPojo() throws Exception {
    final UUID customFieldId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final DefaultCustomFieldCreationEvent event = new DefaultCustomFieldCreationEvent(customFieldId, objectId, objectType, 1L, 2L, UUID.randomUUID());
    Assert.assertEquals(event.getBusEventType(), BusInternalEventType.CUSTOM_FIELD_CREATION);
    Assert.assertEquals(event.getObjectId(), objectId);
    Assert.assertEquals(event.getObjectType(), objectType);
    Assert.assertEquals(event, event);
    Assert.assertEquals(event, new DefaultCustomFieldCreationEvent(customFieldId, objectId, objectType, 1L, 2L, UUID.randomUUID()));
}

70. TestDefaultCustomFieldCreationEvent#testSerialization()

View license
@Test(groups = "fast")
public void testSerialization() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();
    final UUID customFieldId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
    final DefaultCustomFieldCreationEvent event = new DefaultCustomFieldCreationEvent(customFieldId, objectId, objectType, 1L, 2L, UUID.randomUUID());
    final String json = objectMapper.writeValueAsString(event);
    final DefaultCustomFieldCreationEvent fromJson = objectMapper.readValue(json, DefaultCustomFieldCreationEvent.class);
    Assert.assertEquals(fromJson, event);
}

71. TestDefaultControlTagDefinitionCreationEvent#testPojo()

View license
@Test(groups = "fast")
public void testPojo() throws Exception {
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = UUID.randomUUID();
    final DefaultControlTagDefinitionCreationEvent event = new DefaultControlTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID());
    Assert.assertEquals(event.getBusEventType(), BusInternalEvent.BusInternalEventType.CONTROL_TAGDEFINITION_CREATION);
    Assert.assertEquals(event.getTagDefinitionId(), tagDefinitionId);
    Assert.assertEquals(event.getTagDefinition(), tagDefinition);
    Assert.assertEquals(event.getTagDefinition().getId(), tagDefinitionId);
    Assert.assertEquals(event.getTagDefinition().getName(), tagDefinitionName);
    Assert.assertEquals(event.getTagDefinition().getDescription(), tagDefinitionDescription);
    Assert.assertEquals(event, event);
    Assert.assertEquals(event, new DefaultControlTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(event));
    Assert.assertTrue(event.equals(new DefaultControlTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID())));
}

72. TestDefaultControlTagDefinitionCreationEvent#testSerialization()

View license
@Test(groups = "fast")
public void testSerialization() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = UUID.randomUUID();
    final DefaultControlTagDefinitionCreationEvent event = new DefaultControlTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID());
    final String json = objectMapper.writeValueAsString(event);
    final DefaultControlTagDefinitionCreationEvent fromJson = objectMapper.readValue(json, DefaultControlTagDefinitionCreationEvent.class);
    Assert.assertEquals(fromJson, event);
}

73. TestDefaultControlTagDefinitionDeletionEvent#testPojo()

View license
@Test(groups = "fast")
public void testPojo() throws Exception {
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = UUID.randomUUID();
    final DefaultControlTagDefinitionDeletionEvent event = new DefaultControlTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID());
    Assert.assertEquals(event.getBusEventType(), BusInternalEvent.BusInternalEventType.CONTROL_TAGDEFINITION_DELETION);
    Assert.assertEquals(event.getTagDefinitionId(), tagDefinitionId);
    Assert.assertEquals(event.getTagDefinition(), tagDefinition);
    Assert.assertEquals(event.getTagDefinition().getId(), tagDefinitionId);
    Assert.assertEquals(event.getTagDefinition().getName(), tagDefinitionName);
    Assert.assertEquals(event.getTagDefinition().getDescription(), tagDefinitionDescription);
    Assert.assertEquals(event, event);
    Assert.assertEquals(event, new DefaultControlTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(event));
    Assert.assertTrue(event.equals(new DefaultControlTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID())));
}

74. TestDefaultControlTagDefinitionDeletionEvent#testSerialization()

View license
@Test(groups = "fast")
public void testSerialization() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = UUID.randomUUID();
    final DefaultControlTagDefinitionDeletionEvent event = new DefaultControlTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID());
    final String json = objectMapper.writeValueAsString(event);
    final DefaultControlTagDefinitionDeletionEvent fromJson = objectMapper.readValue(json, DefaultControlTagDefinitionDeletionEvent.class);
    Assert.assertEquals(fromJson, event);
}

75. TestDefaultUserTagDefinitionCreationEvent#testPojo()

View license
@Test(groups = "fast")
public void testPojo() throws Exception {
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = UUID.randomUUID();
    final DefaultUserTagDefinitionCreationEvent event = new DefaultUserTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID());
    Assert.assertEquals(event.getBusEventType(), BusInternalEvent.BusInternalEventType.USER_TAGDEFINITION_CREATION);
    Assert.assertEquals(event.getTagDefinitionId(), tagDefinitionId);
    Assert.assertEquals(event.getTagDefinition(), tagDefinition);
    Assert.assertEquals(event.getTagDefinition().getId(), tagDefinitionId);
    Assert.assertEquals(event.getTagDefinition().getName(), tagDefinitionName);
    Assert.assertEquals(event.getTagDefinition().getDescription(), tagDefinitionDescription);
    Assert.assertEquals(event, event);
    Assert.assertEquals(event, new DefaultUserTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(event));
    Assert.assertTrue(event.equals(new DefaultUserTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID())));
}

76. TestDefaultUserTagDefinitionCreationEvent#testSerialization()

View license
@Test(groups = "fast")
public void testSerialization() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = UUID.randomUUID();
    final DefaultUserTagDefinitionCreationEvent event = new DefaultUserTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID());
    final String json = objectMapper.writeValueAsString(event);
    final DefaultUserTagDefinitionCreationEvent fromJson = objectMapper.readValue(json, DefaultUserTagDefinitionCreationEvent.class);
    Assert.assertEquals(fromJson, event);
}

77. TestDefaultUserTagDefinitionDeletionEvent#testPojo()

View license
@Test(groups = "fast")
public void testPojo() throws Exception {
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = UUID.randomUUID();
    final DefaultUserTagDefinitionDeletionEvent event = new DefaultUserTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID());
    Assert.assertEquals(event.getBusEventType(), BusInternalEvent.BusInternalEventType.USER_TAGDEFINITION_DELETION);
    Assert.assertEquals(event.getTagDefinitionId(), tagDefinitionId);
    Assert.assertEquals(event.getTagDefinition(), tagDefinition);
    Assert.assertEquals(event.getTagDefinition().getId(), tagDefinitionId);
    Assert.assertEquals(event.getTagDefinition().getName(), tagDefinitionName);
    Assert.assertEquals(event.getTagDefinition().getDescription(), tagDefinitionDescription);
    Assert.assertEquals(event, event);
    Assert.assertEquals(event, new DefaultUserTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(event));
    Assert.assertTrue(event.equals(new DefaultUserTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID())));
}

78. TestDefaultUserTagDefinitionDeletionEvent#testSerialization()

View license
@Test(groups = "fast")
public void testSerialization() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = UUID.randomUUID();
    final DefaultUserTagDefinitionDeletionEvent event = new DefaultUserTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID());
    final String json = objectMapper.writeValueAsString(event);
    final DefaultUserTagDefinitionDeletionEvent fromJson = objectMapper.readValue(json, DefaultUserTagDefinitionDeletionEvent.class);
    Assert.assertEquals(fromJson, event);
}

79. TestTagEventBuilder#testNewUserTagDefinitionCreationEvent()

Project: killbill
Source File: TestTagEventBuilder.java
View license
@Test(groups = "fast")
public void testNewUserTagDefinitionCreationEvent() throws Exception {
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = internalCallContext.getUserToken();
    final TagEventBuilder tagEventBuilder = new TagEventBuilder();
    final TagDefinitionInternalEvent event = tagEventBuilder.newUserTagDefinitionCreationEvent(tagDefinitionId, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
    Assert.assertTrue(event instanceof UserTagDefinitionCreationInternalEvent);
    Assert.assertEquals(event, new DefaultUserTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(new DefaultUserTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID())));
    verifyTagDefinitionEvent(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}

80. TestTagEventBuilder#testNewUserTagDefinitionDeletionEvent()

Project: killbill
Source File: TestTagEventBuilder.java
View license
@Test(groups = "fast")
public void testNewUserTagDefinitionDeletionEvent() throws Exception {
    final UUID tagDefinitionId = UUID.randomUUID();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = false;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = internalCallContext.getUserToken();
    final TagEventBuilder tagEventBuilder = new TagEventBuilder();
    final TagDefinitionInternalEvent event = tagEventBuilder.newUserTagDefinitionDeletionEvent(tagDefinitionId, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
    Assert.assertTrue(event instanceof UserTagDefinitionDeletionInternalEvent);
    Assert.assertEquals(event, new DefaultUserTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(new DefaultUserTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID())));
    verifyTagDefinitionEvent(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}

81. TestTagEventBuilder#testNewControlTagDefinitionCreationEvent()

Project: killbill
Source File: TestTagEventBuilder.java
View license
@Test(groups = "fast")
public void testNewControlTagDefinitionCreationEvent() throws Exception {
    final UUID tagDefinitionId = ControlTagType.AUTO_PAY_OFF.getId();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = true;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = internalCallContext.getUserToken();
    final TagEventBuilder tagEventBuilder = new TagEventBuilder();
    final TagDefinitionInternalEvent event = tagEventBuilder.newControlTagDefinitionCreationEvent(tagDefinitionId, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
    Assert.assertTrue(event instanceof ControlTagDefinitionCreationInternalEvent);
    Assert.assertEquals(event, new DefaultControlTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(new DefaultControlTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID())));
    verifyTagDefinitionEvent(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}

82. TestTagEventBuilder#testNewControlTagDefinitionDeletionEvent()

Project: killbill
Source File: TestTagEventBuilder.java
View license
@Test(groups = "fast")
public void testNewControlTagDefinitionDeletionEvent() throws Exception {
    final UUID tagDefinitionId = ControlTagType.AUTO_PAY_OFF.getId();
    final String tagDefinitionName = UUID.randomUUID().toString();
    final String tagDefinitionDescription = UUID.randomUUID().toString();
    final boolean controlTag = true;
    final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
    final UUID userToken = internalCallContext.getUserToken();
    final TagEventBuilder tagEventBuilder = new TagEventBuilder();
    final TagDefinitionInternalEvent event = tagEventBuilder.newControlTagDefinitionDeletionEvent(tagDefinitionId, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
    Assert.assertTrue(event instanceof ControlTagDefinitionDeletionInternalEvent);
    Assert.assertEquals(event, new DefaultControlTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID()));
    Assert.assertTrue(event.equals(new DefaultControlTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID())));
    verifyTagDefinitionEvent(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}

83. TestReflectLogicalTypes#testReadUUIDArray()

View license
@Test
public void testReadUUIDArray() throws IOException {
    Schema uuidArraySchema = SchemaBuilder.record(RecordWithUUIDArray.class.getName()).fields().name("uuids").type().array().items().stringType().noDefault().endRecord();
    LogicalTypes.uuid().addToSchema(uuidArraySchema.getField("uuids").schema().getElementType());
    UUID u1 = UUID.randomUUID();
    UUID u2 = UUID.randomUUID();
    GenericRecord r = new GenericData.Record(uuidArraySchema);
    r.put("uuids", Arrays.asList(u1.toString(), u2.toString()));
    RecordWithUUIDArray expected = new RecordWithUUIDArray();
    expected.uuids = new UUID[] { u1, u2 };
    File test = write(uuidArraySchema, r);
    Assert.assertEquals("Should convert Strings to UUIDs", expected, read(REFLECT, uuidArraySchema, test).get(0));
}

84. TestReflectLogicalTypes#testReadUUIDList()

View license
@Test
public void testReadUUIDList() throws IOException {
    Schema uuidListSchema = SchemaBuilder.record(RecordWithUUIDList.class.getName()).fields().name("uuids").type().array().items().stringType().noDefault().endRecord();
    uuidListSchema.getField("uuids").schema().addProp(SpecificData.CLASS_PROP, List.class.getName());
    LogicalTypes.uuid().addToSchema(uuidListSchema.getField("uuids").schema().getElementType());
    UUID u1 = UUID.randomUUID();
    UUID u2 = UUID.randomUUID();
    GenericRecord r = new GenericData.Record(uuidListSchema);
    r.put("uuids", Arrays.asList(u1.toString(), u2.toString()));
    RecordWithUUIDList expected = new RecordWithUUIDList();
    expected.uuids = Arrays.asList(u1, u2);
    File test = write(uuidListSchema, r);
    Assert.assertEquals("Should convert Strings to UUIDs", expected, read(REFLECT, uuidListSchema, test).get(0));
}

85. UUIDTest#testUUID()

Project: pgjdbc
Source File: UUIDTest.java
View license
public void testUUID() throws SQLException {
    UUID uuid = UUID.randomUUID();
    PreparedStatement ps = _conn.prepareStatement("INSERT INTO uuidtest VALUES (?)");
    ps.setObject(1, uuid, Types.OTHER);
    ps.executeUpdate();
    ps.close();
    Statement stmt = _conn.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT id FROM uuidtest");
    assertTrue(rs.next());
    UUID uuid2 = (UUID) rs.getObject(1);
    assertEquals(uuid, rs.getObject(1));
    assertEquals(uuid.toString(), rs.getString(1));
    rs.close();
    stmt.close();
}

86. UUIDTest#testUUID()

Project: pgjdbc-ng
Source File: UUIDTest.java
View license
@Test
public void testUUID() throws SQLException {
    UUID uuid = UUID.randomUUID();
    PreparedStatement ps = conn.prepareStatement("INSERT INTO uuidtest VALUES (?)");
    ps.setObject(1, uuid, Types.OTHER);
    ps.executeUpdate();
    ps.close();
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT id FROM uuidtest");
    assertTrue(rs.next());
    @SuppressWarnings("unused") UUID uuid2 = (UUID) rs.getObject(1);
    assertEquals(uuid, rs.getObject(1));
    assertEquals(uuid.toString(), rs.getString(1));
    rs.close();
    stmt.close();
}

87. PreferencesTest#testPreferenceHasUuid()

Project: qpid-java
Source File: PreferencesTest.java
View license
public void testPreferenceHasUuid() {
    Preference p1 = _testObject.getUserPreferences().createPreference(null, "X-TESTPREF", "testProp1", "", null, Collections.<String, Object>emptyMap());
    Preference p2 = _testObject.getUserPreferences().createPreference(null, "X-TESTPREF", "testProp2", "", Collections.<Principal>emptySet(), Collections.<String, Object>emptyMap());
    UUID id1 = p1.getId();
    UUID id2 = p2.getId();
    assertNotNull("preference id must not be null", id1);
    assertNotNull("preference id must not be null", id2);
    assertTrue("preference ids must be unique", !id1.equals(id2));
}

88. UUIDGeneratorTest#testQueueIdGeneration()

Project: qpid-java
Source File: UUIDGeneratorTest.java
View license
public void testQueueIdGeneration() throws Exception {
    //check repeated generation is deterministic
    UUID queue1 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_1);
    UUID queue2 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_1);
    assertEquals("Queue IDs should be equal", queue1, queue2);
    //check different name gives different ID
    queue1 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_1);
    queue2 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_2, VIRTUAL_HOST_NAME_1);
    assertFalse("Queue IDs should not be equal", queue1.equals(queue2));
    //check different vhost name gives different ID
    queue1 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_1);
    queue2 = UUIDGenerator.generateQueueUUID(QUEUE_NAME_1, VIRTUAL_HOST_NAME_2);
    assertFalse("Queue IDs should not be equal", queue1.equals(queue2));
}

89. UUIDGeneratorTest#testExchangeIdGeneration()

Project: qpid-java
Source File: UUIDGeneratorTest.java
View license
public void testExchangeIdGeneration() throws Exception {
    //check repeated generation is deterministic
    UUID exchange1 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_1);
    UUID exchange2 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_1);
    assertEquals("Exchange IDs should be equal", exchange1, exchange2);
    //check different name gives different ID
    exchange1 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_1);
    exchange2 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_2, VIRTUAL_HOST_NAME_1);
    assertFalse("Exchange IDs should not be equal", exchange1.equals(exchange2));
    //check different vhost name gives different ID
    exchange1 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_1);
    exchange2 = UUIDGenerator.generateExchangeUUID(EXCHANGE_NAME_1, VIRTUAL_HOST_NAME_2);
    assertFalse("Exchange IDs should not be equal", exchange1.equals(exchange2));
}

90. UUIDGeneratorTest#testBindingIdGeneration()

Project: qpid-java
Source File: UUIDGeneratorTest.java
View license
public void testBindingIdGeneration() throws Exception {
    //check repeated generation is deterministic
    UUID binding1 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1, BINDING_KEY_1, VIRTUAL_HOST_NAME_1);
    UUID binding2 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1, BINDING_KEY_1, VIRTUAL_HOST_NAME_1);
    assertEquals("Binding IDs should be equal", binding1, binding2);
    //check different name gives different ID
    binding1 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1, BINDING_KEY_1, VIRTUAL_HOST_NAME_1);
    binding2 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1, BINDING_KEY_2, VIRTUAL_HOST_NAME_1);
    assertFalse("Binding IDs should not be equal", binding1.equals(binding2));
    //check different vhost name gives different ID
    binding1 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1, BINDING_KEY_1, VIRTUAL_HOST_NAME_1);
    binding2 = UUIDGenerator.generateBindingUUID(EXCHANGE_NAME_1, QUEUE_NAME_1, BINDING_KEY_1, VIRTUAL_HOST_NAME_2);
    assertFalse("Binding IDs should not be equal", binding1.equals(binding2));
}

91. UUIDGeneratorTest#testVhostIdGeneration()

Project: qpid-java
Source File: UUIDGeneratorTest.java
View license
public void testVhostIdGeneration() throws Exception {
    //check repeated generation is deterministic
    UUID vhost1 = UUIDGenerator.generateVhostUUID(VIRTUAL_HOST_NAME_1);
    UUID vhost2 = UUIDGenerator.generateVhostUUID(VIRTUAL_HOST_NAME_1);
    assertTrue("Virtualhost IDs should be equal", vhost1.equals(vhost2));
    //check different vhost name gives different ID
    vhost1 = UUIDGenerator.generateVhostUUID(VIRTUAL_HOST_NAME_1);
    vhost2 = UUIDGenerator.generateVhostUUID(VIRTUAL_HOST_NAME_2);
    assertFalse("Virtualhost IDs should not be equal", vhost1.equals(vhost2));
}

92. UUIDGeneratorTest#testVhostAliasIdGeneration()

Project: qpid-java
Source File: UUIDGeneratorTest.java
View license
public void testVhostAliasIdGeneration() throws Exception {
    //check repeated generation is deterministic
    UUID alias1 = UUIDGenerator.generateVhostAliasUUID(VHOST_ALIAS_1, PORT_1);
    UUID alias2 = UUIDGenerator.generateVhostAliasUUID(VHOST_ALIAS_1, PORT_1);
    assertTrue("Virtualhost Alias IDs should be equal", alias1.equals(alias2));
    //check different port name gives different ID
    alias1 = UUIDGenerator.generateVhostAliasUUID(VHOST_ALIAS_1, PORT_1);
    alias2 = UUIDGenerator.generateVhostAliasUUID(VHOST_ALIAS_2, PORT_1);
    assertFalse("Virtualhost Alias IDs should not be equal", alias1.equals(alias2));
    //check different alias name gives different ID
    alias1 = UUIDGenerator.generateVhostAliasUUID(VHOST_ALIAS_1, PORT_1);
    alias2 = UUIDGenerator.generateVhostAliasUUID(VHOST_ALIAS_1, PORT_2);
    assertFalse("Virtualhost Alias IDs should not be equal", alias1.equals(alias2));
}

93. UUIDGeneratorTest#testUserIdGeneration()

Project: qpid-java
Source File: UUIDGeneratorTest.java
View license
public void testUserIdGeneration() throws Exception {
    //check repeated generation is deterministic
    UUID user1 = UUIDGenerator.generateUserUUID(PROVIDER_1, USER_1);
    UUID user2 = UUIDGenerator.generateUserUUID(PROVIDER_1, USER_1);
    assertTrue("User IDs should be equal", user1.equals(user2));
    //check different name gives different ID
    user1 = UUIDGenerator.generateUserUUID(PROVIDER_1, USER_1);
    user2 = UUIDGenerator.generateUserUUID(PROVIDER_1, USER_2);
    assertFalse("User IDs should not be equal", user1.equals(user2));
    //check different provider gives different ID
    user1 = UUIDGenerator.generateUserUUID(PROVIDER_1, USER_1);
    user2 = UUIDGenerator.generateUserUUID(PROVIDER_2, USER_1);
    assertFalse("User IDs should not be equal", user1.equals(user2));
}

94. BrokerRecovererTest#testCreateBrokerWithPorts()

Project: qpid-java
Source File: BrokerRecovererTest.java
View license
public void testCreateBrokerWithPorts() {
    UUID authProviderId = UUID.randomUUID();
    UUID portId = UUID.randomUUID();
    resolveObjects(_brokerEntry, createAuthProviderRecord(authProviderId, "authProvider"), createPortRecord(portId, 5672, "authProvider"));
    Broker<?> broker = _systemConfig.getBroker();
    assertNotNull(broker);
    broker.open();
    assertEquals(_brokerId, broker.getId());
    assertEquals(1, broker.getPorts().size());
}

95. UpdateProcessor#findUpdatesWithinTimeframe()

Project: Rhombus
Source File: UpdateProcessor.java
View license
protected List<Map<String, Object>> findUpdatesWithinTimeframe(IndexUpdateRow row, Long timeInNannos) {
    List<Map<String, Object>> ret = Lists.newArrayList();
    UUID newer = null;
    int i = 0;
    for (UUID current : row.getIds()) {
        if (newer != null) {
            ///do stuff
            Long difference = newer.timestamp() - current.timestamp();
            if (difference < timeInNannos) {
                Map<String, Object> toadd = Maps.newHashMap();
                toadd.put("rowkey", row.getRowKey());
                toadd.put("new-item", row.getIndexValues().get(i));
                toadd.put("old-item", row.getIndexValues().get(i - 1));
                toadd.put("difference", difference);
                ret.add(toadd);
            }
        }
        newer = current;
        i++;
    }
    return ret;
}

96. FakeIdRangeTest#getMillisAtShardKeyMonthlyTest()

Project: Rhombus
Source File: FakeIdRangeTest.java
View license
//	@Test
//	public void  makeTimeUUIDFromTimeUnitTest(){
//
//		long expectedTimestamp = System.currentTimeMillis();
//		System.out.println(expectedTimestamp);
//		UUID actual = FakeIdRange.makeTimeUUIDFromLowestTimeUnit(expectedTimestamp);
//		System.out.println(actual.toString());
//		UUIDs.
//		assertEquals(expectedTimestamp*100000L, actual.timestamp());
//
//		//assert that its always the same
////		Long timestamp = 13948172300040000L;
////		UUID uuid = FakeIdRange.makeTimeUUIDFromLowestTimeUnit(timestamp);
////		assertEquals("ef35b740-8dc9-1031-802a-010000000000",uuid.toString());
//
//		//assert that the date converts to something sane
//		assertEquals("SOMETHING SANE",UuidUtil.getDateFromUUID(actual).toString());;
//	}
@Test
public void getMillisAtShardKeyMonthlyTest() throws RhombusException {
    Long millistamp = System.currentTimeMillis();
    UUID startingUUID = UUIDs.startOf(millistamp);
    //System.out.println("UUID of start is "+startingUUID+" (DATE= "+UuidUtil.getDateFromUUID(startingUUID)+" )");
    TimebasedShardingStrategy shardingStrategy = new ShardingStrategyMonthly();
    FakeIdRange subject = new FakeIdRange(CField.CDataType.TIMEUUID, startingUUID, 95L, 10L, shardingStrategy, "testing");
    long counter = 90L;
    UUID id = (UUID) subject.getIdAtCounter(counter, shardingStrategy);
    //System.out.println("UUID of the id is "+id+" (DATE= "+UuidUtil.getDateFromUUID(id)+" ) Millis:"+UuidUtil.convertUUIDToJavaMillis(id));
    long actual = subject.getCounterAtId(id);
    assertEquals(counter, actual);
}

97. FakeIdRangeTest#getMillisAtShardKeyWeeklyTest()

Project: Rhombus
Source File: FakeIdRangeTest.java
View license
@Test
public void getMillisAtShardKeyWeeklyTest() throws RhombusException {
    Long millistamp = System.currentTimeMillis();
    UUID startingUUID = UUIDs.startOf(millistamp);
    //System.out.println("UUID of start is "+startingUUID+" (DATE= "+UuidUtil.getDateFromUUID(startingUUID)+" )");
    TimebasedShardingStrategy shardingStrategy = new ShardingStrategyWeekly();
    FakeIdRange subject = new FakeIdRange(CField.CDataType.TIMEUUID, startingUUID, 950L, 3L, shardingStrategy, "testing");
    long counter = 8L;
    UUID id = (UUID) subject.getIdAtCounter(counter, shardingStrategy);
    //System.out.println("UUID of the id is "+id+" (DATE= "+UuidUtil.getDateFromUUID(id)+" ) Millis:"+UuidUtil.convertUUIDToJavaMillis(id));
    long actual = subject.getCounterAtId(id);
    assertEquals(counter, actual);
}

98. FakeIdRangeTest#getMillisAtShardKeyDailyTest()

Project: Rhombus
Source File: FakeIdRangeTest.java
View license
@Test
public void getMillisAtShardKeyDailyTest() throws RhombusException {
    Long millistamp = System.currentTimeMillis();
    UUID startingUUID = UUIDs.startOf(millistamp);
    //System.out.println("UUID of start is "+startingUUID+" (DATE= "+UuidUtil.getDateFromUUID(startingUUID)+" )");
    TimebasedShardingStrategy shardingStrategy = new ShardingStrategyDaily();
    FakeIdRange subject = new FakeIdRange(CField.CDataType.TIMEUUID, startingUUID, 950L, 3L, shardingStrategy, "testing");
    long counter = 8L;
    UUID id = (UUID) subject.getIdAtCounter(counter, shardingStrategy);
    //System.out.println("UUID of the id is "+id+" (DATE= "+UuidUtil.getDateFromUUID(id)+" ) Millis:"+UuidUtil.convertUUIDToJavaMillis(id));
    long actual = subject.getCounterAtId(id);
    assertEquals(counter, actual);
}

99. FakeIdRangeTest#getMillisAtShardKeyNoneTest()

Project: Rhombus
Source File: FakeIdRangeTest.java
View license
@Test
public void getMillisAtShardKeyNoneTest() throws RhombusException {
    Long millistamp = System.currentTimeMillis();
    UUID startingUUID = UUIDs.startOf(millistamp);
    //System.out.println("UUID of start is "+startingUUID+" (DATE= "+UuidUtil.getDateFromUUID(startingUUID)+" )");
    TimebasedShardingStrategy shardingStrategy = new ShardingStrategyNone();
    FakeIdRange subject = new FakeIdRange(CField.CDataType.TIMEUUID, startingUUID, 950L, 3L, shardingStrategy, "testing");
    long counter = 8L;
    UUID id = (UUID) subject.getIdAtCounter(counter, shardingStrategy);
    //System.out.println("UUID of the id is "+id+" (DATE= "+UuidUtil.getDateFromUUID(id)+" ) Millis:"+UuidUtil.convertUUIDToJavaMillis(id));
    long actual = subject.getCounterAtId(id);
    assertEquals(counter, actual);
}

100. ModifiableIdentifierMapTest#testUUIDs()

View license
/**
     * Tests with UUIDs.
     */
@Test
public void testUUIDs() {
    final List<Identifier> identifiers = new ArrayList<Identifier>();
    final IdentifierMap map = new ModifiableIdentifierMap(identifiers);
    final java.util.UUID id1 = fromString("434f3107-c6d2-4c8c-bb25-553f68641c5c");
    final java.util.UUID id2 = fromString("42924124-032a-4dfe-b06e-113e3cb81cf0");
    // Add first UUID.
    assertNull(map.putSpecialized(UUID, id1));
    // Replace UUID by a new one.
    assertSame(id1, map.putSpecialized(UUID, id2));
}