Package org.lilyproject.repository.impl.id

Examples of org.lilyproject.repository.impl.id.SchemaIdImpl


    public void testFieldType() throws Exception {
        ValueType valueType = new StringValueType();
        typeManager.getValueType("STRING");
        expectLastCall().andReturn(valueType);
        QName name = new QName("aNamespace", "aName");
        SchemaId fieldTypeId = new SchemaIdImpl(UUID.randomUUID());
        FieldType fieldType = new FieldTypeImpl(fieldTypeId, valueType, name, Scope.NON_VERSIONED);
        typeManager.newFieldType(fieldTypeId, valueType, name, Scope.NON_VERSIONED);
        expectLastCall().andReturn(fieldType);

        control.replay();
        converter = new AvroConverter();
        AvroFieldType avroFieldType = new AvroFieldType();
        AvroSchemaId avroSchemaId = new AvroSchemaId();
        avroSchemaId.idBytes = ByteBuffer.wrap(fieldTypeId.getBytes());
        avroFieldType.id = avroSchemaId;
        AvroQName avroQName = new AvroQName();
        avroQName.namespace = "aNamespace";
        avroQName.name = "aName";
        avroFieldType.name = avroQName;
View Full Code Here


    }

    @Test
    public void testEmptyRecordType() throws Exception {
        QName name = new QName("aNamespace", "aName");
        SchemaId id = new SchemaIdImpl(UUID.randomUUID());
        RecordType recordType = new RecordTypeImpl(id, name);
        typeManager.newRecordType(id, name);
        expectLastCall().andReturn(recordType);

        control.replay();
        converter = new AvroConverter();
        AvroRecordType avroRecordType = new AvroRecordType();
        AvroSchemaId avroSchemaId = new AvroSchemaId();
        avroSchemaId.idBytes = ByteBuffer.wrap(id.getBytes());
        avroRecordType.id = avroSchemaId;
        AvroQName avroQName = new AvroQName();
        avroQName.namespace = "aNamespace";
        avroQName.name = "aName";
        avroRecordType.name = avroQName;
View Full Code Here

    }

    @Test
    public void testRecordTypeVersion() throws Exception {
        QName name = new QName("aNamespace", "aName");
        SchemaId id = new SchemaIdImpl(UUID.randomUUID());
        RecordType recordType = new RecordTypeImpl(id, name);
        typeManager.newRecordType(id, name);
        expectLastCall().andReturn(recordType);

        control.replay();
        converter = new AvroConverter();
        recordType.setVersion(1L);
        AvroRecordType avroRecordType = new AvroRecordType();
        AvroSchemaId avroSchemaId = new AvroSchemaId();
        avroSchemaId.idBytes = ByteBuffer.wrap(id.getBytes());
        avroRecordType.id = avroSchemaId;
        AvroQName avroQName = new AvroQName();
        avroQName.namespace = "aNamespace";
        avroQName.name = "aName";
        avroRecordType.name = avroQName;
View Full Code Here

    }

    @Test
    public void testRecordTypeFieldTypeEntries() throws Exception {
        QName name = new QName("aNamespace", "aName");
        SchemaId recordTypeId = new SchemaIdImpl(UUID.randomUUID());
        RecordType recordType = new RecordTypeImpl(recordTypeId, name);
        typeManager.newRecordType(recordTypeId, name);
        expectLastCall().andReturn(recordType);

        SchemaId fieldTypeId1 = new SchemaIdImpl(UUID.randomUUID());
        SchemaId fieldTypeId2 = new SchemaIdImpl(UUID.randomUUID());
        FieldTypeEntryImpl fieldTypeEntry1 = new FieldTypeEntryImpl(fieldTypeId1, true);
        FieldTypeEntryImpl fieldTypeEntry2 = new FieldTypeEntryImpl(fieldTypeId2, false);
        typeManager.newFieldTypeEntry(fieldTypeId1, true);
        expectLastCall().andReturn(fieldTypeEntry1);
        typeManager.newFieldTypeEntry(fieldTypeId2, false);
        expectLastCall().andReturn(fieldTypeEntry2);

        control.replay();
        converter = new AvroConverter();
        recordType.addFieldTypeEntry(fieldTypeEntry1);
        recordType.addFieldTypeEntry(fieldTypeEntry2);
        AvroRecordType avroRecordType = new AvroRecordType();
        AvroSchemaId avroRecordTypeId = new AvroSchemaId();
        avroRecordTypeId.idBytes = ByteBuffer.wrap(recordTypeId.getBytes());
        avroRecordType.id = avroRecordTypeId;
        AvroQName avroQName = new AvroQName();
        avroQName.namespace = "aNamespace";
        avroQName.name = "aName";
        avroRecordType.name = avroQName;
        // fieldTypeEntries and supertypes are by default empty instead of null
        avroRecordType.fieldTypeEntries =
                new GenericData.Array<AvroFieldTypeEntry>(0, Schema.createArray(AvroFieldTypeEntry.SCHEMA$));
        AvroFieldTypeEntry avroFieldTypeEntry = new AvroFieldTypeEntry();
        AvroSchemaId avroFieldTypeId1 = new AvroSchemaId();
        avroFieldTypeId1.idBytes = ByteBuffer.wrap(fieldTypeId1.getBytes());
        avroFieldTypeEntry.id = avroFieldTypeId1;
        avroFieldTypeEntry.mandatory = true;
        avroRecordType.fieldTypeEntries.add(avroFieldTypeEntry);
        Set<AvroFieldTypeEntry> expectedFieldTypeEntries = new HashSet<AvroFieldTypeEntry>();
        expectedFieldTypeEntries.add(avroFieldTypeEntry);
        avroFieldTypeEntry = new AvroFieldTypeEntry();
        AvroSchemaId avroFieldTypeId2 = new AvroSchemaId();
        avroFieldTypeId2.idBytes = ByteBuffer.wrap(fieldTypeId2.getBytes());
        avroFieldTypeEntry.id = avroFieldTypeId2;
        avroFieldTypeEntry.mandatory = false;
        avroRecordType.fieldTypeEntries.add(avroFieldTypeEntry);
        expectedFieldTypeEntries.add(avroFieldTypeEntry);
        avroRecordType.supertypes = new GenericData.Array<AvroSupertype>(0, Schema.createArray(AvroSupertype.SCHEMA$));
View Full Code Here

    }

    @Test
    public void testRecordTypeSupertypes() throws Exception {
        QName name = new QName("aNamespace", "aName");
        SchemaId recordTypeId = new SchemaIdImpl(UUID.randomUUID());
        RecordType recordType = new RecordTypeImpl(recordTypeId, name);
        typeManager.newRecordType(recordTypeId, name);
        expectLastCall().andReturn(recordType);

        control.replay();
        converter = new AvroConverter();
        SchemaId supertypeId1 = new SchemaIdImpl(UUID.randomUUID());
        recordType.addSupertype(supertypeId1, 1L);
        SchemaId supertypeId2 = new SchemaIdImpl(UUID.randomUUID());
        recordType.addSupertype(supertypeId2, 2L);
        AvroRecordType avroRecordType = new AvroRecordType();
        AvroSchemaId avroRecordTypeId = new AvroSchemaId();
        avroRecordTypeId.idBytes = ByteBuffer.wrap(recordTypeId.getBytes());
        avroRecordType.id = avroRecordTypeId;
        AvroQName avroQName = new AvroQName();
        avroQName.namespace = "aNamespace";
        avroQName.name = "aName";
        avroRecordType.name = avroQName;
        // fieldTypeEntries and supertypes are by default empty instead of null
        avroRecordType.fieldTypeEntries =
                new GenericData.Array<AvroFieldTypeEntry>(0, Schema.createArray(AvroFieldTypeEntry.SCHEMA$));
        avroRecordType.supertypes = new GenericData.Array<AvroSupertype>(0, Schema.createArray(AvroSupertype.SCHEMA$));
        AvroSupertype avroSupertype1 = new AvroSupertype();
        AvroSchemaId avroSupertypeId1 = new AvroSchemaId();
        avroSupertypeId1.idBytes = ByteBuffer.wrap(supertypeId1.getBytes());
        avroSupertype1.recordTypeId = avroSupertypeId1;
        avroSupertype1.recordTypeVersion = 1L;
        avroRecordType.supertypes.add(avroSupertype1);
        Set<AvroSupertype> expectedSupertypes = new HashSet<AvroSupertype>();
        expectedSupertypes.add(avroSupertype1);
        AvroSupertype avroSupertype2 = new AvroSupertype();
        AvroSchemaId avroSupertypeId2 = new AvroSchemaId();
        avroSupertypeId2.idBytes = ByteBuffer.wrap(supertypeId2.getBytes());
        avroSupertype2.recordTypeId = avroSupertypeId2;
        avroSupertype2.recordTypeVersion = 2L;
        avroRecordType.supertypes.add(avroSupertype2);
        expectedSupertypes.add(avroSupertype2);
        assertEquals(recordType, converter.convert(avroRecordType, typeManager));
View Full Code Here

            System.out.println("Expecting RecordTypeNotFoundException");
            typeManager.updateRecordType(recordType);
            fail();
        } catch (RecordTypeNotFoundException expected) {
        }
        recordType.setId(new SchemaIdImpl(UUID.randomUUID()));
        try {
            System.out.println("Expecting RecordTypeNotFoundException");
            typeManager.updateRecordType(recordType);
            fail();
        } catch (RecordTypeNotFoundException expected) {
View Full Code Here

    @Test
    public void testFieldTypeExistsOnCreate() throws Exception {
        QName name = new QName("testNS", "testUpdateNonExistingRecordTypeFails");
        RecordType recordType = typeManager.newRecordType(name);
        recordType.addFieldTypeEntry(typeManager.newFieldTypeEntry(new SchemaIdImpl(UUID.randomUUID()), false));
        try {
            System.out.println("Expecting FieldTypeNotFoundException");
            typeManager.createRecordType(recordType);
            fail();
        } catch (FieldTypeNotFoundException expected) {
View Full Code Here

    public void testFieldTypeExistsOnUpdate() throws Exception {
        QName name = new QName("testNS", "testFieldGroupExistsOnUpdate");
        RecordType recordType = typeManager.newRecordType(name);
        recordType = typeManager.createRecordType(recordType);

        recordType.addFieldTypeEntry(typeManager.newFieldTypeEntry(new SchemaIdImpl(UUID.randomUUID()), false));
        try {
            System.out.println("Expecting FieldTypeNotFoundException");
            typeManager.updateRecordType(recordType);
            fail();
        } catch (FieldTypeNotFoundException expected) {
View Full Code Here

    }

    @Override
    public RecordType createOrUpdateRecordType(RecordType recordType) throws RepositoryException, InterruptedException {
        if (recordType.getId() == null) {
            recordType.setId(new SchemaIdImpl(UUID.randomUUID()));
        }
        Long version = recordType.getVersion();
        if (version == null) {
            version = new Long(0l);
        }
View Full Code Here

    }

    @Override
    public FieldType createOrUpdateFieldType(FieldType fieldType) throws RepositoryException, InterruptedException {
        if (fieldType.getId() == null) {
            fieldType.setId(new SchemaIdImpl(UUID.randomUUID()));
        }
        fieldTypesByName.put(fieldType.getName(), fieldType);
        fieldTypes.put(fieldType.getId(), fieldType);
        return fieldType;
    }
View Full Code Here

TOP

Related Classes of org.lilyproject.repository.impl.id.SchemaIdImpl

Copyright © 2018 www.massapicom. 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.