Move the OqlKeywordUnitTests class to the 'org.springframework.data.gemfire.repository.query.support' package.

This commit is contained in:
John Blum
2021-02-16 12:57:53 -08:00
parent da819378b5
commit 421c963809

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,24 +12,16 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.springframework.data.gemfire.repository;
package org.springframework.data.gemfire.repository.query.support;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.assertj.core.api.Assertions.fail;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.data.gemfire.repository.query.support.OqlKeyword;
/**
* Test suite of test cases testing the contract and functionality
* of the {@link OqlKeyword} enumerated type.
* Unit Tests for {@link OqlKeyword}.
*
* @author John Blum
* @see org.junit.Test
@@ -38,18 +30,17 @@ import org.springframework.data.gemfire.repository.query.support.OqlKeyword;
*/
public class OqlKeywordUnitTests {
@Rule
public ExpectedException exception = ExpectedException.none();
@Test
public void valueOfIgnoreCaseWithEnumeratedValuesIsSuccessful() {
for (OqlKeyword oqlKeyword : OqlKeyword.values()) {
assertThat(OqlKeyword.valueOfIgnoreCase(oqlKeyword.getKeyword())).isEqualTo(oqlKeyword);
}
}
@Test
public void valueOfIgnoreCaseWithUnconventionalValuesIsSuccessful() {
public void valueOfIgnoreCaseWithUnconventionalEnumeratedValuesIsSuccessful() {
assertThat(OqlKeyword.valueOfIgnoreCase("and")).isEqualTo(OqlKeyword.AND);
assertThat(OqlKeyword.valueOfIgnoreCase("As")).isEqualTo(OqlKeyword.AS);
assertThat(OqlKeyword.valueOfIgnoreCase("CoUnT")).isEqualTo(OqlKeyword.COUNT);
@@ -58,7 +49,8 @@ public class OqlKeywordUnitTests {
}
@Test
public void valueOfIgnoreCaseWithIllegalValuesThrowsIllegalArgumentException() {
public void valueOfIgnoreCaseWithIllegalEnumeratedValuesThrowsIllegalArgumentException() {
assertIllegalOqlKeyword("AN");
assertIllegalOqlKeyword("ASS");
assertIllegalOqlKeyword("CNT");
@@ -81,16 +73,21 @@ public class OqlKeywordUnitTests {
assertIllegalOqlKeyword("WHEN");
}
protected void assertIllegalOqlKeyword(String keyword) {
exception.expect(IllegalArgumentException.class);
exception.expectCause(is(nullValue(Throwable.class)));
exception.expectMessage(String.format("[%s] is not a valid GemFire OQL Keyword", keyword));
private void assertIllegalOqlKeyword(String keyword) {
OqlKeyword.valueOfIgnoreCase(keyword);
try {
OqlKeyword.valueOfIgnoreCase(keyword);
fail("Keyword [%s] is not valid", keyword);
}
catch (IllegalArgumentException expected) {
assertThat(expected).hasMessage("[%s] is not a valid GemFire OQL Keyword", keyword);
assertThat(expected).hasNoCause();
}
}
@Test
public void getKeywordEqualsNameExceptForOrderBy() {
for (OqlKeyword oqlKeyword : OqlKeyword.values()) {
if (!OqlKeyword.ORDER_BY.equals(oqlKeyword)) {
assertThat(oqlKeyword.getKeyword()).isEqualTo(oqlKeyword.name());