Skip to content

Add test cases for new collection factory methods#286

Merged
mercyblitz merged 4 commits into
mainfrom
copilot/add-factory-methods-for-collection-objects
May 30, 2026
Merged

Add test cases for new collection factory methods#286
mercyblitz merged 4 commits into
mainfrom
copilot/add-factory-methods-for-collection-objects

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 30, 2026

Adds comprehensive unit test coverage for newly generated factory methods across all collection utility classes. Tests validate creation, initialization, type correctness, and element handling for thread-safe and specialized collection types.

Test Coverage by Utility Class

SetUtils (5 tests)

  • CopyOnWriteArraySet creation with/without collection argument
  • ConcurrentSkipListSet creation variants with collection and sorted set arguments

ListUtils (2 tests)

  • CopyOnWriteArrayList creation with/without collection argument

QueueUtils (17 tests)

  • PriorityQueue with capacity, comparator, and collection initialization
  • ConcurrentLinkedQueue variants
  • LinkedBlockingQueue with capacity and collection arguments
  • ArrayBlockingQueue with capacity and collection arguments
  • PriorityBlockingQueue initialization
  • DelayQueue, SynchronousQueue, and LinkedTransferQueue creation

MapUtils (8 tests)

  • ConcurrentSkipListMap creation and ordering verification
  • WeakHashMap with capacity and map initialization
  • IdentityHashMap with expected size and map initialization

PropertiesUtils (2 tests)

  • Properties creation with and without default values

Example Test

@Test
void testNewConcurrentSkipListSetWithCollection() {
    Collection<String> source = asList("c", "a", "b");
    ConcurrentSkipListSet<String> set = newConcurrentSkipListSet(source);
    assertEquals(3, set.size());
    // Verifies sorted order maintained by concurrent skip list
    Object[] elements = set.toArray();
    assertEquals("a", elements[0]);
    assertEquals("b", elements[1]);
    assertEquals("c", elements[2]);
}

Total: 34 new test cases ensuring factory method correctness and thread-safety properties.

Move queue implementations to the correct package: import ArrayBlockingQueue, DelayQueue, LinkedBlockingQueue, and LinkedTransferQueue from java.util.concurrent (remove incorrect java.util.ArrayBlockingQueue). Reorder/cleanup imports for consistency and to fix compilation issues referencing the wrong packages.
Correct import statements in QueueUtilsTest: move ArrayBlockingQueue, DelayQueue and LinkedBlockingQueue imports to java.util.concurrent and tidy related imports. This fixes incorrect package references and prevents compilation issues in the test file.
@sonarqubecloud
Copy link
Copy Markdown

@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ Complexity Δ
...main/java/io/microsphere/collection/ListUtils.java 100.00% <100.00%> (ø) 42.00 <2.00> (+2.00)
.../main/java/io/microsphere/collection/MapUtils.java 100.00% <100.00%> (ø) 72.00 <8.00> (+8.00)
...ava/io/microsphere/collection/PropertiesUtils.java 100.00% <100.00%> (ø) 10.00 <2.00> (+2.00)
...ain/java/io/microsphere/collection/QueueUtils.java 100.00% <100.00%> (ø) 34.00 <17.00> (+17.00)
.../main/java/io/microsphere/collection/SetUtils.java 100.00% <100.00%> (ø) 46.00 <5.00> (+5.00)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mercyblitz mercyblitz merged commit e73327b into main May 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants