-
Notifications
You must be signed in to change notification settings - Fork 83
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
9e430c9
commit affe9d2
Showing
3 changed files
with
102 additions
and
59 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
56 changes: 56 additions & 0 deletions
56
okapi-core/src/test/java/org/folio/okapi/util/TenantProductSeqTest.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,56 @@ | ||
package org.folio.okapi.util; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
class TenantProductSeqTest { | ||
|
||
static Stream<Arguments> tenantProductSeq() { | ||
return Stream.of( | ||
Arguments.of(null, "mod-foo", 9, "mod-foo_9"), | ||
Arguments.of(null, "mod-foo-bar", 999, "mod-foo-bar_999"), | ||
Arguments.of("tenant", "mod-foo", 0, "tenant_mod-foo_0"), | ||
Arguments.of("test_tenant", "mod-foo-bar", 123, "test_tenant_mod-foo-bar_123") | ||
); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource | ||
void tenantProductSeq(String tenantId, String product, int seq, String tenantProductSeq) { | ||
var actual = new TenantProductSeq(tenantId, product, seq).toString(); | ||
assertThat(actual, is(tenantProductSeq)); | ||
|
||
var actual2 = new TenantProductSeq(tenantProductSeq); | ||
assertThat(actual2.getTenantId(), is(tenantId)); | ||
assertThat(actual2.getProduct(), is(product)); | ||
assertThat(actual2.getSeq(), is(seq)); | ||
|
||
var actual3 = new TenantProductSeq("diku", tenantProductSeq); | ||
assertThat(actual3.getTenantId(), is("diku")); | ||
assertThat(actual3.getProduct(), is(product)); | ||
assertThat(actual3.getSeq(), is(seq)); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = { | ||
"", | ||
"_", | ||
"-", | ||
"mod-foo", | ||
"mod-foo_", | ||
"tenant_mod-foo", | ||
"tenant_mod-foo_", | ||
}) | ||
void tenantProductSeqFail(String tenantProductSeq) { | ||
assertThrows(NumberFormatException.class, () -> new TenantProductSeq(tenantProductSeq)); | ||
} | ||
} |