-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a9d16c
commit 4d470e2
Showing
3 changed files
with
75 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
opengrok-indexer/src/test/java/org/opengrok/indexer/util/ErrorMessageCollectorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* CDDL HEADER START | ||
* | ||
* The contents of this file are subject to the terms of the | ||
* Common Development and Distribution License (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* | ||
* See LICENSE.txt included in this distribution for the specific | ||
* language governing permissions and limitations under the License. | ||
* | ||
* When distributing Covered Code, include this CDDL HEADER in each | ||
* file and include the License file at LICENSE.txt. | ||
* If applicable, add the following below this CDDL HEADER, with the | ||
* fields enclosed by brackets "[]" replaced with your own identifying | ||
* information: Portions Copyright [yyyy] [name of copyright owner] | ||
* | ||
* CDDL HEADER END | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2023, Oracle and/or its affiliates. | ||
* Portions Copyright (c) 2023, Gino Augustine <[email protected]>. | ||
*/ | ||
package org.opengrok.indexer.util; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Set; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* Represents a container for tests of {@link ErrorMessageCollector}. | ||
*/ | ||
class ErrorMessageCollectorTest { | ||
@Test | ||
void noEmptyStringEmptyCollectionReturnOptionalEmpty() { | ||
var collector = new ErrorMessageCollector("TestPrefix"); | ||
var returnValue = Stream.<String>empty().collect(collector); | ||
Assertions.assertTrue(returnValue.isEmpty()); | ||
} | ||
@Test | ||
void emptyStringWithEmptyCollectionReturnOptionalEmpty() { | ||
var collector = new ErrorMessageCollector("TestPrefix", "TestEmptyString"); | ||
var returnValue = Stream.<String>empty().collect(collector); | ||
Assertions.assertEquals("TestEmptyString", returnValue.orElse("")); | ||
} | ||
@Test | ||
void noEmptyStringWithMultiElementCollectionReturnJoinedString() { | ||
var collector = new ErrorMessageCollector("TestPrefix "); | ||
var returnValue = Set.of("a", "b").stream().collect(collector); | ||
Assertions.assertTrue(returnValue.orElse("").startsWith("TestPrefix ")); | ||
} | ||
@Test | ||
void emptyStringWithMultiElementCollectionReturnJoinedStringWithoutEmptyString() { | ||
var collector = new ErrorMessageCollector("TestPrefix ", "TestEmptyString"); | ||
var returnValue = Set.of("a", "b").stream().collect(collector); | ||
Assertions.assertTrue(returnValue.orElse("").startsWith("TestPrefix ")); | ||
} | ||
|
||
} |