@Test public void testDelete_NoAttributes() throws Exception { ByteBuffer recordIdBytes = mock(ByteBuffer.class); List<AvroMutationCondition> avroMutationConditions = Lists.newArrayList(mock(AvroMutationCondition.class)); RecordId recordId = mock(RecordId.class); List<MutationCondition> mutationConditions = Lists.newArrayList(mock(MutationCondition.class)); when(avroConverter.convertAvroRecordId(recordIdBytes, repository)).thenReturn(recordId); when(avroConverter.convertFromAvro(avroMutationConditions, repository)).thenReturn(mutationConditions); avroLilyImpl.delete(null, recordIdBytes, repositoryName, Table.RECORD.name, avroMutationConditions, null); verify(table).delete(recordId, mutationConditions); }
@Override public ByteBuffer delete(AvroAuthzContext authzContext, ByteBuffer recordId, String repositoryName, String tableName, List<AvroMutationCondition> conditions, Map<String,String> attributes) throws AvroRepositoryException, AvroInterruptedException { try { AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext)); LRepository repository = repositoryManager.getRepository(repositoryName); LTable table = repository.getTable(tableName); RecordId decodedRecordId = converter.convertAvroRecordId(recordId, repository); Record record = null; if (attributes == null) { record = table.delete(decodedRecordId, converter.convertFromAvro(conditions, repository)); } else if (conditions == null) { Record toDelete = table.newRecord(decodedRecordId); toDelete.setAttributes(attributes); table.delete(toDelete); } else { throw new IllegalStateException("Cannot delete a full record with MutationConditions"); } return record == null ? null : converter.convert(record, repository); } catch (RepositoryException e) { throw converter.convert(e); } catch (InterruptedException e) { throw converter.convert(e); } finally { AuthorizationContextHolder.clearContext(); } }
AvroLilyImpl implements AvroLily { @Override public ByteBuffer delete(AvroAuthzContext authzContext, ByteBuffer recordId, String repositoryName, String tableName, List<AvroMutationCondition> conditions, Map<String,String> attributes) throws AvroRepositoryException, AvroInterruptedException { try { AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext)); LRepository repository = repositoryManager.getRepository(repositoryName); LTable table = repository.getTable(tableName); RecordId decodedRecordId = converter.convertAvroRecordId(recordId, repository); Record record = null; if (attributes == null) { record = table.delete(decodedRecordId, converter.convertFromAvro(conditions, repository)); } else if (conditions == null) { Record toDelete = table.newRecord(decodedRecordId); toDelete.setAttributes(attributes); table.delete(toDelete); } else { throw new IllegalStateException("Cannot delete a full record with MutationConditions"); } return record == null ? null : converter.convert(record, repository); } catch (RepositoryException e) { throw converter.convert(e); } catch (InterruptedException e) { throw converter.convert(e); } finally { AuthorizationContextHolder.clearContext(); } } }
AvroLilyImpl implements AvroLily { @Override public ByteBuffer delete(AvroAuthzContext authzContext, ByteBuffer recordId, String repositoryName, String tableName, List<AvroMutationCondition> conditions, Map<String,String> attributes) throws AvroRepositoryException, AvroInterruptedException { try { AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext)); LRepository repository = repositoryManager.getRepository(repositoryName); LTable table = repository.getTable(tableName); RecordId decodedRecordId = converter.convertAvroRecordId(recordId, repository); Record record = null; if (attributes == null) { record = table.delete(decodedRecordId, converter.convertFromAvro(conditions, repository)); } else if (conditions == null) { Record toDelete = table.newRecord(decodedRecordId); toDelete.setAttributes(attributes); table.delete(toDelete); } else { throw new IllegalStateException("Cannot delete a full record with MutationConditions"); } return record == null ? null : converter.convert(record, repository); } catch (RepositoryException e) { throw converter.convert(e); } catch (InterruptedException e) { throw converter.convert(e); } finally { AuthorizationContextHolder.clearContext(); } } AvroLilyImpl(RepositoryManager repositoryManager, TypeManager typeManager); }
AvroLilyImpl implements AvroLily { @Override public ByteBuffer delete(AvroAuthzContext authzContext, ByteBuffer recordId, String repositoryName, String tableName, List<AvroMutationCondition> conditions, Map<String,String> attributes) throws AvroRepositoryException, AvroInterruptedException { try { AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext)); LRepository repository = repositoryManager.getRepository(repositoryName); LTable table = repository.getTable(tableName); RecordId decodedRecordId = converter.convertAvroRecordId(recordId, repository); Record record = null; if (attributes == null) { record = table.delete(decodedRecordId, converter.convertFromAvro(conditions, repository)); } else if (conditions == null) { Record toDelete = table.newRecord(decodedRecordId); toDelete.setAttributes(attributes); table.delete(toDelete); } else { throw new IllegalStateException("Cannot delete a full record with MutationConditions"); } return record == null ? null : converter.convert(record, repository); } catch (RepositoryException e) { throw converter.convert(e); } catch (InterruptedException e) { throw converter.convert(e); } finally { AuthorizationContextHolder.clearContext(); } } AvroLilyImpl(RepositoryManager repositoryManager, TypeManager typeManager); @VisibleForTesting void setAvroConverter(AvroConverter converter); @Override ByteBuffer create(AvroAuthzContext authzContext, ByteBuffer record, String repositoryName, String tableName); @Override ByteBuffer createOrUpdate(AvroAuthzContext authzContext, ByteBuffer record, String repositoryName,
            String tableName, boolean useLatestRecordType); @Override ByteBuffer delete(AvroAuthzContext authzContext, ByteBuffer recordId, String repositoryName,
            String tableName, List<AvroMutationCondition> conditions, Map<String,String> attributes); @Override ByteBuffer update(AvroAuthzContext authzContext, ByteBuffer record, String repositoryName, String tableName,
            boolean updateVersion, boolean useLatestRecordType, List<AvroMutationCondition> conditions); @Override List<String> getVariants(AvroAuthzContext authzContext, ByteBuffer recordId, String repositoryName,
            String tableName); @Override AvroFieldType createFieldType(AvroFieldType avroFieldType); @Override AvroRecordType createRecordType(AvroRecordType avroRecordType); @Override AvroRecordType createOrUpdateRecordType(AvroRecordType avroRecordType, boolean refreshSubtypes); @Override AvroRecordType getRecordTypeById(AvroSchemaId id, long avroVersion); @Override AvroRecordType getRecordTypeByName(AvroQName name, long avroVersion); @Override AvroRecordType updateRecordType(AvroRecordType recordType, boolean refreshSubtypes); @Override AvroFieldType updateFieldType(AvroFieldType fieldType); @Override AvroFieldType createOrUpdateFieldType(AvroFieldType fieldType); @Override AvroFieldType getFieldTypeById(AvroSchemaId id); @Override AvroFieldType getFieldTypeByName(AvroQName name); @Override List<AvroFieldType> getFieldTypes(); @Override List<AvroRecordType> getRecordTypes(); @Override List<AvroFieldType> getFieldTypesWithoutCache(); @Override List<AvroRecordType> getRecordTypesWithoutCache(); @Override AvroFieldAndRecordTypes getTypesWithoutCache(); @Override AvroTypeBucket getTypeBucketWithoutCache(String bucketId); @Override Object disableSchemaCacheRefresh(); @Override Object enableSchemaCacheRefresh(); @Override boolean isSchemaCacheRefreshEnabled(); @Override Object triggerSchemaCacheRefresh(); @Override Object createTable(String repository, AvroTableCreateDescriptor tableCreateDescriptor); @Override Object dropTable(String repositoryName, String name); @Override List<String> getTables(String repositoryName); @Override boolean tableExists(String repositoryName, String name); }
AvroLilyImpl implements AvroLily { @Override public ByteBuffer delete(AvroAuthzContext authzContext, ByteBuffer recordId, String repositoryName, String tableName, List<AvroMutationCondition> conditions, Map<String,String> attributes) throws AvroRepositoryException, AvroInterruptedException { try { AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext)); LRepository repository = repositoryManager.getRepository(repositoryName); LTable table = repository.getTable(tableName); RecordId decodedRecordId = converter.convertAvroRecordId(recordId, repository); Record record = null; if (attributes == null) { record = table.delete(decodedRecordId, converter.convertFromAvro(conditions, repository)); } else if (conditions == null) { Record toDelete = table.newRecord(decodedRecordId); toDelete.setAttributes(attributes); table.delete(toDelete); } else { throw new IllegalStateException("Cannot delete a full record with MutationConditions"); } return record == null ? null : converter.convert(record, repository); } catch (RepositoryException e) { throw converter.convert(e); } catch (InterruptedException e) { throw converter.convert(e); } finally { AuthorizationContextHolder.clearContext(); } } AvroLilyImpl(RepositoryManager repositoryManager, TypeManager typeManager); @VisibleForTesting void setAvroConverter(AvroConverter converter); @Override ByteBuffer create(AvroAuthzContext authzContext, ByteBuffer record, String repositoryName, String tableName); @Override ByteBuffer createOrUpdate(AvroAuthzContext authzContext, ByteBuffer record, String repositoryName,
            String tableName, boolean useLatestRecordType); @Override ByteBuffer delete(AvroAuthzContext authzContext, ByteBuffer recordId, String repositoryName,
            String tableName, List<AvroMutationCondition> conditions, Map<String,String> attributes); @Override ByteBuffer update(AvroAuthzContext authzContext, ByteBuffer record, String repositoryName, String tableName,
            boolean updateVersion, boolean useLatestRecordType, List<AvroMutationCondition> conditions); @Override List<String> getVariants(AvroAuthzContext authzContext, ByteBuffer recordId, String repositoryName,
            String tableName); @Override AvroFieldType createFieldType(AvroFieldType avroFieldType); @Override AvroRecordType createRecordType(AvroRecordType avroRecordType); @Override AvroRecordType createOrUpdateRecordType(AvroRecordType avroRecordType, boolean refreshSubtypes); @Override AvroRecordType getRecordTypeById(AvroSchemaId id, long avroVersion); @Override AvroRecordType getRecordTypeByName(AvroQName name, long avroVersion); @Override AvroRecordType updateRecordType(AvroRecordType recordType, boolean refreshSubtypes); @Override AvroFieldType updateFieldType(AvroFieldType fieldType); @Override AvroFieldType createOrUpdateFieldType(AvroFieldType fieldType); @Override AvroFieldType getFieldTypeById(AvroSchemaId id); @Override AvroFieldType getFieldTypeByName(AvroQName name); @Override List<AvroFieldType> getFieldTypes(); @Override List<AvroRecordType> getRecordTypes(); @Override List<AvroFieldType> getFieldTypesWithoutCache(); @Override List<AvroRecordType> getRecordTypesWithoutCache(); @Override AvroFieldAndRecordTypes getTypesWithoutCache(); @Override AvroTypeBucket getTypeBucketWithoutCache(String bucketId); @Override Object disableSchemaCacheRefresh(); @Override Object enableSchemaCacheRefresh(); @Override boolean isSchemaCacheRefreshEnabled(); @Override Object triggerSchemaCacheRefresh(); @Override Object createTable(String repository, AvroTableCreateDescriptor tableCreateDescriptor); @Override Object dropTable(String repositoryName, String name); @Override List<String> getTables(String repositoryName); @Override boolean tableExists(String repositoryName, String name);  }