use of org.neo4j.values.storable.DoubleArray in project neo4j by neo4j.
the class IndexSettingUtilTest method assertDoubleArray.
private static void assertDoubleArray(IndexSetting setting, Object object, double[] expectedResult) {
Value result = IndexSettingUtil.asIndexSettingValue(setting, object);
assertTrue(result instanceof DoubleArray);
assertArrayEquals(expectedResult, ((DoubleArray) result).asObjectCopy());
}
use of org.neo4j.values.storable.DoubleArray in project neo4j by neo4j.
the class GenericNativeIndexProviderTest method completeConfigurationMustNotOverrideExistingSettings.
@Test
void completeConfigurationMustNotOverrideExistingSettings() {
// Given
DatabaseIndexContext context = DatabaseIndexContext.builder(null, null, DEFAULT_DATABASE_NAME).build();
GenericNativeIndexProvider provider = new GenericNativeIndexProvider(context, IndexDirectoryStructure.NONE, null, Config.defaults());
Map<String, Value> existingSettings = new HashMap<>();
CoordinateReferenceSystem existingCrs = CoordinateReferenceSystem.Cartesian;
DoubleArray min = Values.doubleArray(new double[] { 0, 0 });
DoubleArray max = Values.doubleArray(new double[] { 1, 1 });
existingSettings.put(spatialMinSettingForCrs(existingCrs).getSettingName(), min);
existingSettings.put(spatialMaxSettingForCrs(existingCrs).getSettingName(), max);
IndexConfig existingIndexConfig = IndexConfig.with(existingSettings);
LabelSchemaDescriptor incompleteSchema = SchemaDescriptor.forLabel(1, 1);
IndexDescriptor incompleteDescriptor = IndexPrototype.forSchema(incompleteSchema, IndexProviderDescriptor.UNDECIDED).withName("index").materialise(1).withIndexConfig(existingIndexConfig);
// When
IndexDescriptor completedDescriptor = provider.completeConfiguration(incompleteDescriptor);
// Then
IndexConfig completedIndexConfig = completedDescriptor.getIndexConfig();
for (CoordinateReferenceSystem crs : CoordinateReferenceSystem.all()) {
if (crs.equals(existingCrs)) {
// Assert value
assertEquals(min, completedIndexConfig.get(spatialMinSettingForCrs(crs).getSettingName()));
assertEquals(max, completedIndexConfig.get(spatialMaxSettingForCrs(crs).getSettingName()));
} else {
// Simply assert not null
assertNotNull(completedIndexConfig.get(spatialMinSettingForCrs(crs).getSettingName()));
assertNotNull(completedIndexConfig.get(spatialMaxSettingForCrs(crs).getSettingName()));
}
}
}
Aggregations