Skip to content

Commit

Permalink
fix : add synchronized review
Browse files Browse the repository at this point in the history
Signed-off-by: Samir Romdhani <samir.romdhani@rte-france.com>
  • Loading branch information
samirromdhani committed Sep 23, 2024
1 parent acdc404 commit 4002cab
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.concurrent.*;
import java.util.stream.Stream;

import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.*;
import static org.lfenergy.compas.sct.commons.util.Utils.copySclElement;

Expand Down Expand Up @@ -490,21 +491,20 @@ void copySclElement_should_succeed_when_syncRead() throws ExecutionException, In
tln.setLnType("T1");
tln.getLnClass().add(TLLN0Enum.LLN_0.value());
ExecutorService service = Executors.newFixedThreadPool(2);
Callable<TLN> copySclElementTlnCallable = new Callable<TLN>() {
@Override
public TLN call() {
return copySclElement(tln, TLN.class);
}
};
Callable<TLN> copySclElementTlnCallable = () -> copySclElement(tln, TLN.class);
// When
List<Future<TLN>> result = service.invokeAll(Arrays.asList(copySclElementTlnCallable, copySclElementTlnCallable));
List<Future<TLN>> result = service.invokeAll(List.of(copySclElementTlnCallable, copySclElementTlnCallable));
service.shutdown();
TLN[] tlns = new TLN[]{result.getFirst().get(), result.getLast().get()};
// Then
assertThat(tlns).hasSize(2);
assertThat(tlns[0]).isNotSameAs(tlns[1]).isNotSameAs(tln);
assertThat(tlns[0]).usingRecursiveComparison().isEqualTo(tln);
assertThat(tlns[1]).usingRecursiveComparison().isEqualTo(tln);
assertThat(tlns[0])
.isNotSameAs(tlns[1])
.isNotSameAs(tln);
assertThat(tlns[0])
.usingRecursiveComparison()
.isEqualTo(tlns[1])
.isEqualTo(tln);
}

@Test
Expand Down

0 comments on commit 4002cab

Please sign in to comment.