Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#28536 Add more unit tests for IndexReviseEngine #28834

Merged
merged 4 commits into from
Mar 28, 2024

Conversation

JessikaFujimura
Copy link
Contributor

@JessikaFujimura JessikaFujimura commented Oct 21, 2023

Fixes #28536.

Changes proposed in this pull request:

  • Add Unit Test for class IndexReviseEngine.java

Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.
  • I have made corresponding changes to the documentation. (N/A)
  • I have added corresponding unit tests for my changes. (N/A)

@Test
void assertReviseIsPresentIsFalse() {
when(metaDataReviseEntry.getIndexReviser(any(), anyString())).thenReturn(Optional.empty());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks :)


Collection<IndexMetaData> indexMetaDataCollection = Collections.singletonList(new IndexMetaData("index"));
Collection<IndexMetaData> actual = indexReviseEngine.revise("tableName", indexMetaDataCollection);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks :)

@Test
void assertReviseIsPresentIsTrue() {
IndexReviser<T> reviser = mock(IndexReviser.class);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks :)

IndexReviser<T> reviser = mock(IndexReviser.class);

IndexMetaData indexMetaData = new IndexMetaData("index");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks :)

when(reviser.revise(anyString(), any(), any())).thenReturn(Optional.of(indexMetaData));

Collection<IndexMetaData> indexMetaDataCollection = Arrays.asList(new IndexMetaData("index1"), new IndexMetaData("index2"));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks :)

Collection<IndexMetaData> indexMetaDataCollection = Arrays.asList(new IndexMetaData("index1"), new IndexMetaData("index2"));

Collection<IndexMetaData> actual = indexReviseEngine.revise("tableName", indexMetaDataCollection);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks :)

import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;

public class IndexReviseEngineTest<T extends ShardingSphereRule> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove public

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks :)

@tuichenchuxin tuichenchuxin merged commit 355c8fa into apache:master Mar 28, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add more unit tests for IndexReviseEngine
3 participants