File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -326,11 +326,10 @@ class FindByStatus {
326326 @Test
327327 @DisplayName (" returns matching orders when status exists" )
328328 void shouldReturnOrders_whenStatusExists () {
329- // arrange
330329 when(repository. findByStatus(Status . PENDING )). thenReturn(List . of(order));
331- // act
330+
332331 var result = service. findByStatus(Status . PENDING );
333- // assert
332+
334333 assertThat(result). hasSize(1 ). containsExactly(order);
335334 }
336335}
@@ -341,8 +340,7 @@ class FindByStatus {
341340- Profile before optimizing; use JFR (Java Flight Recorder) and async-profiler
342341- Choose the right garbage collector: G1GC (default), ZGC (low latency), Shenandoah (low latency)
343342- Use ` StringBuilder ` for string concatenation in loops; single-expression concatenation is optimized by the compiler
344- - Preallocate collections with expected capacity: ` new ArrayList<>(expectedSize) ` , ` HashMap.newHashMap(expectedSize) ` (Java 19+)
345- - Use primitive-specialized collections from Eclipse Collections or Koloboke for hot paths with large datasets
343+ - Preallocate collections with expected capacity: ` new ArrayList<>(expectedSize) ` , ` new HashMap<>((int) (expectedSize / 0.75f) + 1) ` when sizing for the default load factor
346344- Use connection pooling (HikariCP) for database connections
347345- Use ` HttpClient ` (java.net.http, Java 11+) instead of legacy ` HttpURLConnection `
348346- Avoid boxing in hot loops; use ` int ` not ` Integer ` where possible
You can’t perform that action at this time.
0 commit comments