[#14] add lombok and refactor exceptions. Provide validator.
All checks were successful
DCO / DCO (pull_request) Successful in 34s
All checks were successful
DCO / DCO (pull_request) Successful in 34s
Signed-off-by: Ori Bruk <o.bruk@yadro.com>
This commit is contained in:
parent
15cf0893c7
commit
388428af76
87 changed files with 819 additions and 970 deletions
|
@ -1,5 +1,6 @@
|
|||
package info.frostfs.sdk;
|
||||
|
||||
import info.frostfs.sdk.exceptions.ValidationFrostFSException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -25,7 +26,7 @@ public class UuidExtensionTest {
|
|||
@Test
|
||||
void uuidAsBytes_givenParamsIsNull() {
|
||||
//When + Then
|
||||
assertThrows(IllegalArgumentException.class, () -> UuidExtension.asBytes(null));
|
||||
assertThrows(ValidationFrostFSException.class, () -> UuidExtension.asBytes(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -40,7 +41,7 @@ public class UuidExtensionTest {
|
|||
@Test
|
||||
void bytesAsUuid_givenParamsIsNull() {
|
||||
//When + Then
|
||||
assertThrows(IllegalArgumentException.class, () -> UuidExtension.asUuid(null));
|
||||
assertThrows(ValidationFrostFSException.class, () -> UuidExtension.asUuid(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -51,7 +52,7 @@ public class UuidExtensionTest {
|
|||
|
||||
|
||||
//When + Then
|
||||
assertThrows(IllegalArgumentException.class, () -> UuidExtension.asUuid(valueLength15));
|
||||
assertThrows(IllegalArgumentException.class, () -> UuidExtension.asUuid(valueLength17));
|
||||
assertThrows(ValidationFrostFSException.class, () -> UuidExtension.asUuid(valueLength15));
|
||||
assertThrows(ValidationFrostFSException.class, () -> UuidExtension.asUuid(valueLength17));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import info.frostfs.sdk.dto.container.Container;
|
|||
import info.frostfs.sdk.dto.netmap.PlacementPolicy;
|
||||
import info.frostfs.sdk.dto.netmap.Replica;
|
||||
import info.frostfs.sdk.enums.BasicAcl;
|
||||
import info.frostfs.sdk.exceptions.ProcessFrostFSException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
@ -21,7 +22,7 @@ public class ContainerMapperTest {
|
|||
@Test
|
||||
void toGrpcMessage_success() {
|
||||
//Given
|
||||
var placementPolicy = new PlacementPolicy(true, new Replica[]{new Replica(1)});
|
||||
var placementPolicy = new PlacementPolicy(new Replica[]{new Replica(1)}, true);
|
||||
var container = new Container(BasicAcl.PUBLIC_RW, placementPolicy);
|
||||
|
||||
//When
|
||||
|
@ -111,6 +112,6 @@ public class ContainerMapperTest {
|
|||
.build();
|
||||
|
||||
//When + Then
|
||||
assertThrows(IllegalArgumentException.class, () -> ContainerMapper.toModel(container));
|
||||
assertThrows(ProcessFrostFSException.class, () -> ContainerMapper.toModel(container));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.google.protobuf.ByteString;
|
|||
import frostfs.netmap.Service;
|
||||
import frostfs.netmap.Types;
|
||||
import info.frostfs.sdk.enums.NodeState;
|
||||
import info.frostfs.sdk.exceptions.ProcessFrostFSException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
@ -117,7 +118,7 @@ public class NodeInfoMapperTest {
|
|||
mockStatic.when(() -> NodeState.get(Types.NodeInfo.State.ONLINE.getNumber()))
|
||||
.thenReturn(null);
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> NodeInfoMapper.toModel(body));
|
||||
assertThrows(ProcessFrostFSException.class, () -> NodeInfoMapper.toModel(body));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public class PlacementPolicyMapperTest {
|
|||
var replica1 = new Replica(1, "test1");
|
||||
var replica2 = new Replica(2, "test2");
|
||||
|
||||
var placementPolicy = new PlacementPolicy(true, new Replica[]{replica1, replica2});
|
||||
var placementPolicy = new PlacementPolicy(new Replica[]{replica1, replica2}, true);
|
||||
|
||||
//When
|
||||
var result = PlacementPolicyMapper.toGrpcMessage(placementPolicy);
|
||||
|
|
|
@ -3,6 +3,7 @@ package info.frostfs.sdk.mappers.object;
|
|||
import frostfs.object.Types;
|
||||
import info.frostfs.sdk.dto.object.ObjectFilter;
|
||||
import info.frostfs.sdk.enums.ObjectMatchType;
|
||||
import info.frostfs.sdk.exceptions.ProcessFrostFSException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
@ -47,7 +48,7 @@ public class ObjectFilterMapperTest {
|
|||
mockStatic.when(() -> Types.MatchType.forNumber(objectFilter.getMatchType().value))
|
||||
.thenReturn(null);
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> ObjectFilterMapper.toGrpcMessage(objectFilter));
|
||||
assertThrows(ProcessFrostFSException.class, () -> ObjectFilterMapper.toGrpcMessage(objectFilter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ import info.frostfs.sdk.dto.object.ObjectAttribute;
|
|||
import info.frostfs.sdk.dto.object.ObjectHeader;
|
||||
import info.frostfs.sdk.dto.object.OwnerId;
|
||||
import info.frostfs.sdk.enums.ObjectType;
|
||||
import info.frostfs.sdk.mappers.response.MetaHeaderMapper;
|
||||
import info.frostfs.sdk.exceptions.ProcessFrostFSException;
|
||||
import info.frostfs.sdk.exceptions.ValidationFrostFSException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
@ -56,7 +57,7 @@ public class ObjectHeaderMapperTest {
|
|||
@Test
|
||||
void toGrpcMessage_null() {
|
||||
//When + Then
|
||||
assertThrows(IllegalArgumentException.class, () -> ObjectHeaderMapper.toGrpcMessage(null));
|
||||
assertThrows(ValidationFrostFSException.class, () -> ObjectHeaderMapper.toGrpcMessage(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -70,7 +71,7 @@ public class ObjectHeaderMapperTest {
|
|||
mockStatic.when(() -> Types.ObjectType.forNumber(objectHeader.getObjectType().value))
|
||||
.thenReturn(null);
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> ObjectHeaderMapper.toGrpcMessage(objectHeader));
|
||||
assertThrows(ProcessFrostFSException.class, () -> ObjectHeaderMapper.toGrpcMessage(objectHeader));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +126,7 @@ public class ObjectHeaderMapperTest {
|
|||
mockStatic.when(() -> ObjectType.get(Types.ObjectType.TOMBSTONE.getNumber()))
|
||||
.thenReturn(null);
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> ObjectHeaderMapper.toModel(header));
|
||||
assertThrows(ProcessFrostFSException.class, () -> ObjectHeaderMapper.toModel(header));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package info.frostfs.sdk.mappers.response;
|
|||
import frostfs.session.Types;
|
||||
import info.frostfs.sdk.dto.netmap.Version;
|
||||
import info.frostfs.sdk.dto.response.MetaHeader;
|
||||
import info.frostfs.sdk.exceptions.ValidationFrostFSException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
@ -29,7 +30,7 @@ public class MetaHeaderMapperTest {
|
|||
@Test
|
||||
void toGrpcMessage_null() {
|
||||
//When + Then
|
||||
assertThrows(IllegalArgumentException.class, () -> MetaHeaderMapper.toGrpcMessage(null));
|
||||
assertThrows(ValidationFrostFSException.class, () -> MetaHeaderMapper.toGrpcMessage(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -52,6 +53,6 @@ public class MetaHeaderMapperTest {
|
|||
@Test
|
||||
void toGrpcMessageBuilder_null() {
|
||||
//When + Then
|
||||
assertThrows(IllegalArgumentException.class, () -> MetaHeaderMapper.toGrpcMessageBuilder(null));
|
||||
assertThrows(ValidationFrostFSException.class, () -> MetaHeaderMapper.toGrpcMessageBuilder(null));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package info.frostfs.sdk.mappers.response;
|
|||
|
||||
import frostfs.status.Types;
|
||||
import info.frostfs.sdk.enums.StatusCode;
|
||||
import info.frostfs.sdk.exceptions.ProcessFrostFSException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
@ -48,6 +49,6 @@ public class ResponseStatusMapperTest {
|
|||
.build();
|
||||
|
||||
//When + Then
|
||||
assertThrows(IllegalArgumentException.class, () -> ResponseStatusMapper.toModel(status));
|
||||
assertThrows(ProcessFrostFSException.class, () -> ResponseStatusMapper.toModel(status));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package info.frostfs.sdk.mappers.response;
|
|||
import frostfs.refs.Types;
|
||||
import info.frostfs.sdk.dto.response.Signature;
|
||||
import info.frostfs.sdk.enums.SignatureScheme;
|
||||
import info.frostfs.sdk.exceptions.ProcessFrostFSException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
@ -50,7 +51,7 @@ public class SignatureMapperTest {
|
|||
mockStatic.when(() -> Types.SignatureScheme.forNumber(signature.getScheme().value))
|
||||
.thenReturn(null);
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> SignatureMapper.toGrpcMessage(signature));
|
||||
assertThrows(ProcessFrostFSException.class, () -> SignatureMapper.toGrpcMessage(signature));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package info.frostfs.sdk.mappers.session;
|
|||
|
||||
import com.google.protobuf.ByteString;
|
||||
import frostfs.session.Types;
|
||||
import info.frostfs.sdk.exceptions.ValidationFrostFSException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
@ -27,7 +28,7 @@ public class SessionMapperTest {
|
|||
@Test
|
||||
void serialize_wrong() {
|
||||
//When + Then
|
||||
assertThrows(IllegalArgumentException.class, () -> SessionMapper.serialize(null));
|
||||
assertThrows(ValidationFrostFSException.class, () -> SessionMapper.serialize(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -43,8 +44,8 @@ public class SessionMapperTest {
|
|||
@Test
|
||||
void deserialize_wrong() {
|
||||
//When + Then
|
||||
assertThrows(IllegalArgumentException.class, () -> SessionMapper.deserializeSessionToken(null));
|
||||
assertThrows(IllegalArgumentException.class, () -> SessionMapper.deserializeSessionToken(new byte[]{}));
|
||||
assertThrows(ValidationFrostFSException.class, () -> SessionMapper.deserializeSessionToken(null));
|
||||
assertThrows(ValidationFrostFSException.class, () -> SessionMapper.deserializeSessionToken(new byte[]{}));
|
||||
}
|
||||
|
||||
private Types.SessionToken createSessionToken() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue