From 421c96380923d5c2be7dcfe31b609717bcadd386 Mon Sep 17 00:00:00 2001 From: John Blum Date: Tue, 16 Feb 2021 12:57:53 -0800 Subject: [PATCH] Move the OqlKeywordUnitTests class to the 'org.springframework.data.gemfire.repository.query.support' package. --- .../support}/OqlKeywordUnitTests.java | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) rename spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/{ => query/support}/OqlKeywordUnitTests.java (71%) diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/OqlKeywordUnitTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/query/support/OqlKeywordUnitTests.java similarity index 71% rename from spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/OqlKeywordUnitTests.java rename to spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/query/support/OqlKeywordUnitTests.java index 9bdc4571..1d32a550 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/OqlKeywordUnitTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/query/support/OqlKeywordUnitTests.java @@ -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());