[
https://issues.apache.org/jira/browse/HDDS-12604?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Attila Doroszlai resolved HDDS-12604.
-------------------------------------
Fix Version/s: 2.1.0
Resolution: Implemented
> Reduce duplication in TestContainerStateMachine
> -----------------------------------------------
>
> Key: HDDS-12604
> URL: https://issues.apache.org/jira/browse/HDDS-12604
> Project: Apache Ozone
> Issue Type: Sub-task
> Components: test
> Reporter: Attila Doroszlai
> Assignee: Chia-Chuan Yu
> Priority: Major
> Labels: pull-request-available
> Fix For: 2.1.0
>
>
> Reduce code duplication in TestContainerStateMachine. Examples:
> {code}
>
> when(context.getRequestProto()).thenReturn(ContainerProtos.ContainerCommandRequestProto.newBuilder()
> .setCmdType(ContainerProtos.Type.WriteChunk).setWriteChunk(
>
> ContainerProtos.WriteChunkRequestProto.newBuilder().setData(ByteString.copyFromUtf8("Test
> Data"))
> .setBlockID(
>
> ContainerProtos.DatanodeBlockID.newBuilder().setContainerID(1).setLocalID(1).build()).build())
> .setContainerID(1)
> .setDatanodeUuid(UUID.randomUUID().toString()).build());
> {code}
> {code}
> AtomicReference<Throwable> throwable = new AtomicReference<>(null);
> Function<Throwable, ? extends Message> throwableSetter = t -> {
> throwable.set(t);
> return null;
> };
> {code}
> {code}
> if (failWithException) {
> when(dispatcher.dispatch(any(), any())).thenThrow(new
> RuntimeException());
> } else {
> when(dispatcher.dispatch(any(),
> any())).thenReturn(ContainerProtos.ContainerCommandResponseProto
> .newBuilder().setCmdType(ContainerProtos.Type.WriteChunk)
> .setResult(ContainerProtos.Result.CONTAINER_INTERNAL_ERROR)
> .build());
> }
> {code}
> CC [~swamirishi], [~sumitagrawl]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]