Package org.lilyproject.repository.impl.id

Examples of org.lilyproject.repository.impl.id.IdGeneratorImpl.newRecordId()


    public void testUUIDWithVariantSingleProperty() {
        IdGenerator idGenerator = new IdGeneratorImpl();
        RecordId masterRecordId = idGenerator.newRecordId();
        Map<String, String> variantProperties = new HashMap<String, String>();
        variantProperties.put("dim1", "dimvalue1");
        RecordId variantRecordId = idGenerator.newRecordId(masterRecordId, variantProperties);

        // Test it is recognized as variant
        assertFalse(variantRecordId.isMaster());

        // Test string representation is what it is supposed to be
View Full Code Here


                /* length of key (vint) */, 1
                /* the key (letter X) */, 88
                /* length of value (vint) */, 3
                /* the value (ABC) */, 65, 66, 67 };

        RecordId variantId = idGenerator.newRecordId(idGenerator.fromBytes(masterIdBytes),
                Collections.singletonMap("X", "ABC"));
        assertArrayEquals(variantIdBytes, variantId.toBytes());
    }

    @Test
View Full Code Here

    }

    @Test
    public void testUUUIDWithMultipleProperties() {
        IdGenerator idGenerator = new IdGeneratorImpl();
        RecordId masterRecordId = idGenerator.newRecordId();
        Map<String, String> variantProperties = new HashMap<String, String>();
        variantProperties.put("dim1", "dimvalue1");
        variantProperties.put("dim2", "dimvalue2");

        RecordId variantRecordId = idGenerator.newRecordId(masterRecordId, variantProperties);
View Full Code Here

        RecordId masterRecordId = idGenerator.newRecordId();
        Map<String, String> variantProperties = new HashMap<String, String>();
        variantProperties.put("dim1", "dimvalue1");
        variantProperties.put("dim2", "dimvalue2");

        RecordId variantRecordId = idGenerator.newRecordId(masterRecordId, variantProperties);

        // Test string representation is what it is supposed to be
        String variantRecordIdString = masterRecordId.toString() + ".dim1=dimvalue1,dim2=dimvalue2";
        assertEquals(variantRecordIdString, variantRecordId.toString());
        assertEquals(variantRecordId, idGenerator.fromString(variantRecordIdString));
View Full Code Here

    }

    @Test
    public void testUserIdWithVariantProperties() {
        IdGenerator idGenerator = new IdGeneratorImpl();
        RecordId masterId = idGenerator.newRecordId("marvellous");
        Map<String, String> variantProperties = new HashMap<String, String>();
        variantProperties.put("a", "x");
        variantProperties.put("aa", "xx");

        RecordId variantId = idGenerator.newRecordId(masterId, variantProperties);
View Full Code Here

        RecordId masterId = idGenerator.newRecordId("marvellous");
        Map<String, String> variantProperties = new HashMap<String, String>();
        variantProperties.put("a", "x");
        variantProperties.put("aa", "xx");

        RecordId variantId = idGenerator.newRecordId(masterId, variantProperties);

        // Test it is recognized as variant
        assertFalse(variantId.isMaster());

        // Test round-trip string & bytes conversion
View Full Code Here

            fail("Expected an exception when using zero byte in string.");
        } catch (IllegalArgumentException e) {
            // expected
        }
        try {
            idGenerator.newRecordId("hello\u0000world");
            fail("Expected an exception when using zero byte in string.");
        } catch (IllegalArgumentException e) {
            // expected
        }
    }
View Full Code Here

    @Test
    public void testReservedCharacterEscapingInUserId() {
        IdGenerator idGenerator = new IdGeneratorImpl();
        char[] chars = new char[] {'.', ',', '=' };
        for (char c : chars) {
            RecordId recordId = idGenerator.newRecordId("hello" + c + "world");

            String idString = recordId.toString();
            assertEquals("USER.hello\\" + c + "world", idString);
        }
    }
View Full Code Here

    @Test
    public void testScanRecordId() throws Exception {
        IdGenerator idGenerator = new IdGeneratorImpl();

        RecordScan scan = new RecordScan();
        scan.setStartRecordId(idGenerator.newRecordId());
        scan.setStopRecordId(idGenerator.newRecordId("foo"));

        byte[] data = scanToBytes(scan);
        RecordScan parsedScan = scanFromBytes(data);
View Full Code Here

    public void testScanRecordId() throws Exception {
        IdGenerator idGenerator = new IdGeneratorImpl();

        RecordScan scan = new RecordScan();
        scan.setStartRecordId(idGenerator.newRecordId());
        scan.setStopRecordId(idGenerator.newRecordId("foo"));

        byte[] data = scanToBytes(scan);
        RecordScan parsedScan = scanFromBytes(data);

        assertEquals(scan.getStartRecordId(), parsedScan.getStartRecordId());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.