Skip to content

Commit

Permalink
Add more test cases on PrimaryKeyIngestPosition's impl classes (#33354)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Oct 22, 2024
1 parent 1a494de commit f323f7b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,13 @@

package org.apache.shardingsphere.data.pipeline.core.ingest.position.type.pk.type;

import org.apache.shardingsphere.data.pipeline.core.ingest.position.type.pk.PrimaryKeyIngestPositionFactory;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

class IntegerPrimaryKeyIngestPositionTest {

@Test
void assertInit() {
IntegerPrimaryKeyIngestPosition position = (IntegerPrimaryKeyIngestPosition) PrimaryKeyIngestPositionFactory.newInstance("i,1,100");
assertThat(position.getBeginValue(), is(1L));
assertThat(position.getEndValue(), is(100L));
}

@Test
void assertToString() {
assertThat(new IntegerPrimaryKeyIngestPosition(1L, 100L).toString(), is("i,1,100"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,20 @@

package org.apache.shardingsphere.data.pipeline.core.ingest.position.type.pk.type;

import org.apache.shardingsphere.data.pipeline.core.ingest.position.type.pk.PrimaryKeyIngestPositionFactory;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNull;

class StringPrimaryKeyIngestPositionTest {

@Test
void assertInit() {
StringPrimaryKeyIngestPosition position = (StringPrimaryKeyIngestPosition) PrimaryKeyIngestPositionFactory.newInstance("s,hi,jk");
assertThat(position.getBeginValue(), is("hi"));
assertThat(position.getEndValue(), is("jk"));
}

@Test
void assertToString() {
assertThat(new StringPrimaryKeyIngestPosition("hi", "jk").toString(), is("s,hi,jk"));
}

@Test
void assertEmptyToNull() {
StringPrimaryKeyIngestPosition actual = (StringPrimaryKeyIngestPosition) PrimaryKeyIngestPositionFactory.newInstance("s,,");
assertNull(actual.getBeginValue());
assertNull(actual.getEndValue());
void assertToStringWithNullValue() {
assertThat(new StringPrimaryKeyIngestPosition(null, null).toString(), is("s,,"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,13 @@

package org.apache.shardingsphere.data.pipeline.core.ingest.position.type.pk.type;

import org.apache.shardingsphere.data.pipeline.core.ingest.position.type.pk.PrimaryKeyIngestPositionFactory;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNull;

class UnsupportedKeyIngestPositionTest {

@Test
void assertInit() {
UnsupportedKeyIngestPosition position = (UnsupportedKeyIngestPosition) PrimaryKeyIngestPositionFactory.newInstance("u,,");
assertNull(position.getBeginValue());
assertNull(position.getEndValue());
}

@Test
void assertToString() {
assertThat(new UnsupportedKeyIngestPosition().toString(), is("u,,"));
Expand Down

0 comments on commit f323f7b

Please sign in to comment.