[#37] Add tree service methods: getRange(), getRangeHash(), patchObject(). Maven project version inheritance.
All checks were successful
DCO / DCO (pull_request) Successful in 25s
Verify code phase / Verify code (pull_request) Successful in 1m32s

Signed-off-by: Ori Bruk <o.bruk@yadro.com>
This commit is contained in:
Ori Bruk 2025-01-29 14:44:59 +03:00
parent 1ccb1f2013
commit 33f7198ace
26 changed files with 642 additions and 20 deletions

View file

@ -4,10 +4,39 @@ import frostfs.object.Types;
import info.frostfs.sdk.dto.object.ObjectAttribute;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
public class ObjectAttributeMapperTest {
@Test
void toGrpcMessages_success() {
//Given
var objectAttribute1 = new ObjectAttribute("key1", "value1");
var objectAttribute2 = new ObjectAttribute("key2", "value2");
//When
var result = ObjectAttributeMapper.toGrpcMessages(Arrays.asList(objectAttribute1, objectAttribute2));
//Then
assertNotNull(result);
assertThat(result).isNotNull().hasSize(2);
assertEquals(objectAttribute1.getKey(), result.get(0).getKey());
assertEquals(objectAttribute1.getValue(), result.get(0).getValue());
assertEquals(objectAttribute2.getKey(), result.get(1).getKey());
assertEquals(objectAttribute2.getValue(), result.get(1).getValue());
}
@Test
void toGrpcMessages_null() {
//When + Then
assertNull(ObjectAttributeMapper.toGrpcMessages(null));
assertNull(ObjectAttributeMapper.toGrpcMessages(Collections.emptyList()));
}
@Test
void toGrpcMessage_success() {
//Given

View file

@ -0,0 +1,39 @@
package info.frostfs.sdk.mappers.object.patch;
import info.frostfs.sdk.dto.container.ContainerId;
import info.frostfs.sdk.dto.object.ObjectId;
import info.frostfs.sdk.dto.object.patch.Address;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class AddressMapperTest {
@Test
void toGrpcMessage_success() {
//Given
var objectId = new ObjectId("85orCLKSu3X1jGiTFmwmTUsBU88RBARNwuRwrEy5pyww");
var containerId = new ContainerId("EQGx2QeYHJb53uRwYGzcQaW191sZpdNrjutk6veUSV2R");
var address = new Address(objectId, containerId);
//When
var result = AddressMapper.toGrpcMessage(address);
//Then
assertNotNull(result);
assertEquals(
address.getContainerId().getValue(),
new ContainerId(result.getContainerId().getValue().toByteArray()).getValue()
);
assertEquals(
address.getObjectId().getValue(),
new ObjectId(result.getObjectId().getValue().toByteArray()).getValue()
);
}
@Test
void toGrpcMessage_null() {
//When + Then
assertNull(AddressMapper.toGrpcMessage(null));
}
}

View file

@ -0,0 +1,58 @@
package info.frostfs.sdk.mappers.object.patch;
import info.frostfs.sdk.dto.object.patch.Range;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
public class RangeMapperTest {
@Test
void toGrpcMessages_success() {
//Given
var range1 = new Range(1, 10);
var range2 = new Range(2, 20);
//When
var result = RangeMapper.toGrpcMessages(Arrays.asList(range1, range2));
//Then
assertNotNull(result);
assertThat(result).isNotNull().hasSize(2);
assertEquals(range1.getOffset(), result.get(0).getOffset());
assertEquals(range1.getLength(), result.get(0).getLength());
assertEquals(range2.getOffset(), result.get(1).getOffset());
assertEquals(range2.getLength(), result.get(1).getLength());
}
@Test
void toGrpcMessages_null() {
//When + Then
assertNull(RangeMapper.toGrpcMessages(null));
assertNull(RangeMapper.toGrpcMessages(Collections.emptyList()));
}
@Test
void toGrpcMessage_success() {
//Given
var range = new Range(1, 10);
//When
var result = RangeMapper.toGrpcMessage(range);
//Then
assertNotNull(result);
assertEquals(range.getOffset(), result.getOffset());
assertEquals(range.getLength(), result.getLength());
}
@Test
void toGrpcMessage_null() {
//When + Then
assertNull(RangeMapper.toGrpcMessage(null));
}
}