diff options
author | Piotr Darosz <piotr.darosz@nokia.com> | 2018-06-18 12:46:35 +0200 |
---|---|---|
committer | Tal Gitelman <tg851x@intl.att.com> | 2018-07-24 14:28:36 +0000 |
commit | 0081451051e155e758a6d0be40f2fb8b18c434c9 (patch) | |
tree | 3138041395c7f933d05a3a5db2d1f21493b169b2 /catalog-dao/src/test | |
parent | d0f8678bfa7f06f06c9f1dd3cad862b1b99c3a03 (diff) |
Refactor tests inside the catalog-dao model
Use Hamcrest matchers to simplify getter/setter tests structure
Change-Id: Icee88395034ffb61e60a9190d2a9e77571e6fac3
Issue-ID: SDC-1434
Signed-off-by: Piotr Darosz <piotr.darosz@nokia.com>
Diffstat (limited to 'catalog-dao/src/test')
4 files changed, 37 insertions, 170 deletions
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/FacetedSearchFacetTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/FacetedSearchFacetTest.java index 79ee69bd8e..8a02bc008a 100644 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/FacetedSearchFacetTest.java +++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/FacetedSearchFacetTest.java @@ -1,55 +1,13 @@ package org.openecomp.sdc.be.dao.model; import org.junit.Test; - +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; public class FacetedSearchFacetTest { - private FacetedSearchFacet createTestSubject() { - return new FacetedSearchFacet("", 0); - } - - - @Test - public void testGetFacetValue() throws Exception { - FacetedSearchFacet testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getFacetValue(); - } - - - @Test - public void testSetFacetValue() throws Exception { - FacetedSearchFacet testSubject; - String facetValue = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setFacetValue(facetValue); - } - - - @Test - public void testGetCount() throws Exception { - FacetedSearchFacet testSubject; - long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCount(); - } - - @Test - public void testSetCount() throws Exception { - FacetedSearchFacet testSubject; - long count = 555; - - // default test - testSubject = createTestSubject(); - testSubject.setCount(count); + public void shouldHaveValidGettersAndSetters(){ + assertThat(FacetedSearchFacet.class, hasValidGettersAndSetters()); } }
\ No newline at end of file diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/FacetedSearchResult.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/FacetedSearchResult.java new file mode 100644 index 0000000000..b262decb43 --- /dev/null +++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/FacetedSearchResult.java @@ -0,0 +1,13 @@ +package org.openecomp.sdc.be.dao.model; + +import org.junit.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; + +public class FacetedSearchResult { + @Test + public void shouldHaveValidGettersAndSetters(){ + assertThat(FacetedSearchResult.class, hasValidGettersAndSetters()); + } +}
\ No newline at end of file diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/FetchContext.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/FetchContext.java new file mode 100644 index 0000000000..c7ed9bc087 --- /dev/null +++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/FetchContext.java @@ -0,0 +1,13 @@ +package org.openecomp.sdc.be.dao.model; + +import org.junit.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; + +public class FetchContext { + @Test + public void shouldHaveValidGettersAndSetters(){ + assertThat(FetchContext.class, hasValidGettersAndSetters()); + } +}
\ No newline at end of file diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/GetMultipleDataResultTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/GetMultipleDataResultTest.java index a3304517f6..843e39899a 100644 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/GetMultipleDataResultTest.java +++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/model/GetMultipleDataResultTest.java @@ -1,137 +1,20 @@ package org.openecomp.sdc.be.dao.model; -import org.apache.tinkerpop.gremlin.structure.T; import org.junit.Test; -public class GetMultipleDataResultTest { - - private GetMultipleDataResult createTestSubject() { - return new GetMultipleDataResult<>(); - } +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; +public class GetMultipleDataResultTest { + @Test public void testCtor() throws Exception { new GetMultipleDataResult<>(new String [1], new Object[1]); new GetMultipleDataResult<>(new String [1], new String [1], 0L, 0L, 1, 1); } - - @Test - public void testGetTypes() throws Exception { - GetMultipleDataResult testSubject; - String[] result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTypes(); - } - - @Test - public void testGetData() throws Exception { - GetMultipleDataResult testSubject; - Object[] result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getData(); - } - - @Test - public void testSetTypes() throws Exception { - GetMultipleDataResult testSubject; - String[] types = new String[] { "" }; - - // default test - testSubject = createTestSubject(); - testSubject.setTypes(types); - } - - @Test - public void testSetData() throws Exception { - GetMultipleDataResult testSubject; - T[] data = new T[] { null }; - - // default test - testSubject = createTestSubject(); - testSubject.setData(data); - } - - @Test - public void testSetQueryDuration() throws Exception { - GetMultipleDataResult testSubject; - long queryDuration = 0L; - - // default test - testSubject = createTestSubject(); - testSubject.setQueryDuration(queryDuration); - } - + @Test - public void testSetTotalResults() throws Exception { - GetMultipleDataResult testSubject; - long totalResults = 0L; - - // default test - testSubject = createTestSubject(); - testSubject.setTotalResults(totalResults); - } - - @Test - public void testSetFrom() throws Exception { - GetMultipleDataResult testSubject; - int from = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setFrom(from); - } - - @Test - public void testSetTo() throws Exception { - GetMultipleDataResult testSubject; - int to = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setTo(to); - } - - @Test - public void testGetQueryDuration() throws Exception { - GetMultipleDataResult testSubject; - long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getQueryDuration(); - } - - @Test - public void testGetTotalResults() throws Exception { - GetMultipleDataResult testSubject; - long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTotalResults(); - } - - @Test - public void testGetFrom() throws Exception { - GetMultipleDataResult testSubject; - int result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getFrom(); - } - - @Test - public void testGetTo() throws Exception { - GetMultipleDataResult testSubject; - int result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTo(); + public void shouldHaveValidGettersAndSetters(){ + assertThat(GetMultipleDataResultTest.class, hasValidGettersAndSetters()); } }
\ No newline at end of file |