From 94db219bcb87e2fbba75c0f69cc74fdeea0e79c8 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Mon, 22 Feb 2016 14:17:13 +0100 Subject: [PATCH 01/12] Completed DDI API --- .../hawkbit/controller/ArtifactDownloadTest.java | 2 +- .../hawkbit/controller/CancelActionTest.java | 2 +- .../eclipse/hawkbit/controller/ConfigDataTest.java | 2 +- .../hawkbit/controller/DeploymentBaseTest.java | 2 +- .../hawkbit/controller/RootControllerTest.java | 13 +++++++++---- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ArtifactDownloadTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ArtifactDownloadTest.java index 2db088e64..b49f34b5f 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ArtifactDownloadTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ArtifactDownloadTest.java @@ -60,7 +60,7 @@ import ru.yandex.qatools.allure.annotations.Stories; */ @ActiveProfiles({ "im", "test" }) -@Features("Component Tests - Controller RESTful API") +@Features("Component Tests - Direct Device Integration API") @Stories("Artifact Download Resource") public class ArtifactDownloadTest extends AbstractIntegrationTestWithMongoDB { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/CancelActionTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/CancelActionTest.java index e7b94cb30..d7e0351cf 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/CancelActionTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/CancelActionTest.java @@ -40,7 +40,7 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; @ActiveProfiles({ "im", "test" }) -@Features("Component Tests - Controller RESTful API") +@Features("Component Tests - Direct Device Integration API") @Stories("Cancel Action Resource") public class CancelActionTest extends AbstractIntegrationTest { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ConfigDataTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ConfigDataTest.java index 4b6a135b2..a2b26c218 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ConfigDataTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ConfigDataTest.java @@ -35,7 +35,7 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; @ActiveProfiles({ "im", "test" }) -@Features("Component Tests - Controller RESTful API") +@Features("Component Tests - Direct Device Integration API") @Stories("Config Data Resource") public class ConfigDataTest extends AbstractIntegrationTest { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/DeploymentBaseTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/DeploymentBaseTest.java index 2aabb0cba..2b2b7e597 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/DeploymentBaseTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/DeploymentBaseTest.java @@ -52,7 +52,7 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; @ActiveProfiles({ "im", "test" }) -@Features("Component Tests - Controller RESTful API") +@Features("Component Tests - Direct Device Integration API") @Stories("Deployment Action Resource") public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/RootControllerTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/RootControllerTest.java index 7dce6dc35..45bf5755b 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/RootControllerTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/RootControllerTest.java @@ -45,13 +45,11 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; @ActiveProfiles({ "im", "test" }) -@Features("Component Tests - Controller RESTful API") +@Features("Component Tests - Direct Device Integration API") @Stories("Root Poll Resource") -// TODO: fully document tests -> @Description for long text and reasonable -// method name as short text public class RootControllerTest extends AbstractIntegrationTestWithMongoDB { - @Test() + @Test @Description("Ensures that targets cannot be created e.g. in plug'n play scenarios when tenant does not exists but can be created if the tenant exists.") @WithUser(tenantId = "tenantDoesNotExists", allSpPermissions = true, authorities = "ROLE_CONTROLLER", autoCreateTenant = false) public void targetCannotBeRegisteredIfTenantDoesNotExistsButWhenExists() throws Exception { @@ -73,6 +71,7 @@ public class RootControllerTest extends AbstractIntegrationTestWithMongoDB { } @Test + @Description("Ensures that target poll request does not change audit data on the entity.") @WithUser(principal = "knownPrincipal", authorities = { SpPermission.READ_TARGET, SpPermission.UPDATE_TARGET, SpPermission.CREATE_TARGET }) public void targetPollDoesNotModifyAuditData() throws Exception { @@ -104,11 +103,13 @@ public class RootControllerTest extends AbstractIntegrationTestWithMongoDB { } @Test + @Description("Ensures that server returns a not found response in case of empty controlloer ID.") public void rootRsWithoutId() throws Exception { mvc.perform(get("/controller/v1/")).andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); } @Test + @Description("Ensures that the system creates a new target in plug and play manner, i.e. target is authenticated but does not exist yet.") public void rootRsPlugAndPlay() throws Exception { final long current = System.currentTimeMillis(); @@ -133,6 +134,7 @@ public class RootControllerTest extends AbstractIntegrationTestWithMongoDB { } @Test + @Description("Ensures that etag check results in not modified response if provided etag by client is identical to entity in repository.") public void rootRsNotModified() throws Exception { final String etag = mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) @@ -197,6 +199,8 @@ public class RootControllerTest extends AbstractIntegrationTestWithMongoDB { } @Test + @Description("Ensures that the target state machine of a precomissioned target switches from " + + "UNKNOWN to REGISTERED when the target polls for the first time.") public void rootRsPrecommissioned() throws Exception { final Target target = new Target("4711"); targetManagement.createTarget(target); @@ -219,6 +223,7 @@ public class RootControllerTest extends AbstractIntegrationTestWithMongoDB { } @Test + @Description("Ensures that the source IP address of the polling target is correctly stored in repository") public void rootRsPlugAndPlayIpAddress() throws Exception { // test final String knownControllerId1 = "0815"; From 22fb4bcb136186065bfee22ba6f87140f06980bd Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Mon, 22 Feb 2016 17:21:59 +0100 Subject: [PATCH 02/12] Harmonised test descriptions for mgmt. API --- .../resource/DistributionSetResourceTest.java | 69 ++++++++++++------- .../DistributionSetTypeResourceTest.java | 2 +- .../rest/resource/DownloadResourceTest.java | 2 +- .../rest/resource/RolloutResourceTest.java | 2 +- ...MRessourceMisingMongoDbConnectionTest.java | 12 ++-- .../resource/SoftwareModuleResourceTest.java | 2 +- .../SoftwareModuleTypeResourceTest.java | 5 +- .../rest/resource/SortUtilityTest.java | 2 +- .../SystemManagementResourceTest.java | 2 +- .../rest/resource/TargetResourceTest.java | 13 ++-- .../resource/model/ExceptionInfoTest.java | 9 ++- .../rest/resource/model/PagedListTest.java | 9 +++ 12 files changed, 83 insertions(+), 46 deletions(-) diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java index 7eccf7196..6254da992 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java @@ -47,7 +47,6 @@ import org.eclipse.hawkbit.repository.model.Target; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import org.junit.Ignore; import org.junit.Test; import org.springframework.context.annotation.Description; import org.springframework.http.MediaType; @@ -59,15 +58,8 @@ import com.jayway.jsonpath.JsonPath; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -/** - * - * - * - */ -@Features("Component Tests - Management RESTful API") +@Features("Component Tests - Management API") @Stories("Distribution Set Resource") -// TODO: fully document tests -> @Description for long text and reasonable -// method name as short text public class DistributionSetResourceTest extends AbstractIntegrationTest { @Test @@ -235,6 +227,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that multi target assignment through API is reflected by the repository.") public void assignMultipleTargetsToDistributionSet() throws Exception { // prepare distribution set final Set createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1); @@ -255,9 +248,13 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { .andExpect(status().isOk()).andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(knownTargetIds.length))); + + assertThat(targetManagement.findTargetByAssignedDistributionSet(createdDs.getId(), pageReq).getContent()) + .as("Five targets in repository have DS assigned").hasSize(5); } @Test + @Description("Ensures that assigned targets of DS are returned as reflected by the repository.") public void getAssignedTargetsOfDistributionSet() throws Exception { // prepare distribution set final String knownTargetId = "knownTargetId1"; @@ -273,6 +270,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that assigned targets of DS are returned as persisted in the repository.") public void getAssignedTargetsOfDistributionSetIsEmpty() throws Exception { final Set createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1); final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next(); @@ -283,6 +281,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that installed targets of DS are returned as persisted in the repository.") public void getInstalledTargetsOfDistributionSet() throws Exception { // prepare distribution set final String knownTargetId = "knownTargetId1"; @@ -305,46 +304,50 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that DS in repository are listed with proper paging properties.") public void getDistributionSetsWithoutAddtionalRequestParameters() throws Exception { - final int modules = 5; - createDistributionSetsAlphabetical(modules); + final int sets = 5; + createDistributionSetsAlphabetical(sets); mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(modules))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(modules))) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(modules))); + .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) + .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(sets))) + .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(sets))); } @Test + @Description("Ensures that DS in repository are listed with proper paging results with paging limit parameter.") public void getDistributionSetsWithPagingLimitRequestParameter() throws Exception { - final int modules = 5; + final int sets = 5; final int limitSize = 1; - createDistributionSetsAlphabetical(modules); + createDistributionSetsAlphabetical(sets); mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(modules))) + .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); } @Test + @Description("Ensures that DS in repository are listed with proper paging results with paging limit and offset parameter.") public void getDistributionSetsWithPagingLimitAndOffsetRequestParameter() throws Exception { - final int modules = 5; + final int sets = 5; final int offsetParam = 2; - final int expectedSize = modules - offsetParam; - createDistributionSetsAlphabetical(modules); + final int expectedSize = sets - offsetParam; + createDistributionSetsAlphabetical(sets); mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) .param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) - .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(modules))) + .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(sets))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(modules))) + .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); } @Test @WithUser(principal = "uploadTester", allSpPermissions = true) + @Description("Ensures that multiple DS requested are listed with expected payload.") public void getDistributionSets() throws Exception { // prepare test data assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0); @@ -389,6 +392,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { @Test @WithUser(principal = "uploadTester", allSpPermissions = true) + @Description("Ensures that single DS requested by ID is listed with expected payload.") public void getDistributionSet() throws Exception { final DistributionSet set = createTestDistributionSet(softwareManagement, distributionSetManagement); @@ -420,6 +424,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { @Test @WithUser(principal = "uploadTester", allSpPermissions = true) + @Description("Ensures that multipe DS posted to API are created in the repository.") public void createDistributionSets() throws JSONException, Exception { assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0); @@ -534,7 +539,8 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test - public void testDeleteUnassignedistributionSet() throws Exception { + @Description("Ensures that DS deletion request to API is reflected by the repository.") + public void deleteUnassignedistributionSet() throws Exception { // prepare test data assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0); @@ -553,7 +559,8 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test - public void testDeleteAssignedDistributionSet() throws Exception { + @Description("Ensures that assigned DS deletion request to API is reflected by the repository by means of deleted flag set.") + public void deleteAssignedDistributionSet() throws Exception { // prepare test data assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0); @@ -574,6 +581,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that DS property update request to API is reflected by the repository.") public void updateDistributionSet() throws Exception { // prepare test data @@ -601,6 +609,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that the server reacts properly to invalid requests (URI, Media Type, Methods) with correct reponses.") public void invalidRequestsOnDistributionSetsResource() throws Exception { final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement, distributionSetManagement); @@ -642,6 +651,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that the metadata creation through API is reflected by the repository.") public void createMetadata() throws Exception { final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement, distributionSetManagement); @@ -674,6 +684,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that a metadata update through API is reflected by the repository.") public void updateMetadata() throws Exception { // prepare and create metadata for update final String knownKey = "knownKey"; @@ -700,6 +711,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that a metadata entry deletion through API is reflected by the repository.") public void deleteMetadata() throws Exception { // prepare and create metadata for deletion final String knownKey = "knownKey"; @@ -722,6 +734,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that a metadata entry selection through API reflectes the repository content.") public void getSingleMetadata() throws Exception { // prepare and create metadata final String knownKey = "knownKey"; @@ -737,6 +750,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that a metadata entry paged list selection through API reflectes the repository content.") public void getPagedListofMetadata() throws Exception { final int totalMetadata = 10; @@ -760,6 +774,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that a DS search with query parameters returns the expected result.") public void searchDistributionSetRsql() throws Exception { final String dsSuffix = "test"; final int amount = 10; @@ -776,11 +791,13 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } - @Ignore @Test + @Description("Ensures that a DS search with complete==true parameter returns only DS that are actually completely filled with mandatory modules.") public void filterDistributionSetComplete() throws Exception { final int amount = 10; TestDataUtil.generateDistributionSets(amount, softwareManagement, distributionSetManagement); + distributionSetManagement.createDistributionSet(new DistributionSet("incomplete", "2", "incomplete", + distributionSetManagement.findDistributionSetTypeByKey("ecl_os"), null)); final String rsqlFindLikeDs1OrDs2 = "complete==" + Boolean.TRUE; @@ -790,6 +807,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that a DS assigned target search with controllerId==1 parameter returns only the target with the given ID.") public void searchDistributionSetAssignedTargetsRsql() throws Exception { // prepare distribution set final Set createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1); @@ -815,6 +833,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that a DS metadata filtered query with value==knownValue1 parameter returns only the metadata entries with that value.") public void searchDistributionSetMetadataRsql() throws Exception { final int totalMetadata = 10; final String knownKeyPrefix = "knownKey"; diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java index 266b284ca..3ca25132a 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java @@ -50,7 +50,7 @@ import ru.yandex.qatools.allure.annotations.Stories; * * */ -@Features("Component Tests - Management RESTful API") +@Features("Component Tests - Management API") @Stories("Distribution Set Type Resource") public class DistributionSetTypeResourceTest extends AbstractIntegrationTest { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java index cc8f4f6b7..6c33b0eea 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java @@ -34,7 +34,7 @@ import ru.yandex.qatools.allure.annotations.Stories; * * */ -@Features("Component Tests- Download Restful API") +@Features("Component Tests - Management API") @Stories("Download Resource") public class DownloadResourceTest extends AbstractIntegrationTestWithMongoDB { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java index ff9f0e7db..cb4fc9f4a 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java @@ -47,7 +47,7 @@ import ru.yandex.qatools.allure.annotations.Stories; /** * Tests for covering the {@link RolloutResource}. */ -@Features("Component Tests - Management RESTful API") +@Features("Component Tests - Management API") @Stories("Rollout Resource") public class RolloutResourceTest extends AbstractIntegrationTest { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SMRessourceMisingMongoDbConnectionTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SMRessourceMisingMongoDbConnectionTest.java index f9be088a4..664dc861c 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SMRessourceMisingMongoDbConnectionTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SMRessourceMisingMongoDbConnectionTest.java @@ -23,13 +23,16 @@ import org.junit.Test; import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.web.servlet.MvcResult; +import ru.yandex.qatools.allure.annotations.Description; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + /** * Tests {@link SoftwareModuleResource} in case of missing MongoDB connection. * - * - * - * */ +@Features("Component Tests - Management API") +@Stories("Download Resource") public class SMRessourceMisingMongoDbConnectionTest extends AbstractIntegrationTest { @BeforeClass @@ -40,7 +43,8 @@ public class SMRessourceMisingMongoDbConnectionTest extends AbstractIntegrationT } @Test - public void testMissingMongoDbConnection() throws Exception { + @Description("Ensures that the correct error code is returned in case MongoDB unavailable.") + public void missingMongoDbConnectionResultsInErrorAtUpload() throws Exception { assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); assertThat(artifactRepository.findAll()).hasSize(0); diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java index 8079b5d52..5b6923686 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java @@ -65,7 +65,7 @@ import ru.yandex.qatools.allure.annotations.Stories; * Tests for {@link SoftwareModuleResource} {@link RestController}. * */ -@Features("Component Tests - Management RESTful API") +@Features("Component Tests - Management API") @Stories("Software Module Resource") public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongoDB { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResourceTest.java index c6aedddd4..fefe2a440 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResourceTest.java @@ -43,11 +43,8 @@ import ru.yandex.qatools.allure.annotations.Stories; /** * Test for {@link SoftwareModuleTypeResource}. * - * - * - * */ -@Features("Component Tests - Management RESTful API") +@Features("Component Tests - Management API") @Stories("Software Module Type Resource") public class SoftwareModuleTypeResourceTest extends AbstractIntegrationTest { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java index d915c4e9e..09a90c39c 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java @@ -24,7 +24,7 @@ import ru.yandex.qatools.allure.annotations.Stories; /** * */ -@Features("Component Tests - Management RESTful API") +@Features("Component Tests - Management API") @Stories("Sorting parameter") public class SortUtilityTest { private static final String SORT_PARAM_1 = "NAME:ASC"; diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SystemManagementResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SystemManagementResourceTest.java index 8d8f9a2e4..76cd68d64 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SystemManagementResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SystemManagementResourceTest.java @@ -40,7 +40,7 @@ import ru.yandex.qatools.allure.annotations.Stories; * * */ -@Features("Component Tests - System Management RESTful API") +@Features("Component Tests - Management API") @Stories("System Management Resource") public class SystemManagementResourceTest extends AbstractIntegrationTestWithMongoDB { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java index 9db578fe4..d1dd4d6ed 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java @@ -72,7 +72,7 @@ import ru.yandex.qatools.allure.annotations.Stories; * * */ -@Features("Component Tests - Management RESTful API") +@Features("Component Tests - Management API") @Stories("Target Resource") // TODO: fully document tests -> @Description for long text and reasonable // method name as short text @@ -229,7 +229,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { @Test public void cancelActionOK() throws Exception { // prepare test - Target tA = createTargetAndStartAction(); + final Target tA = createTargetAndStartAction(); // test - cancel the active action mvc.perform(delete(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", @@ -252,7 +252,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { @Test public void cancelAnCancelActionIsNotAllowed() throws Exception { // prepare test - Target tA = createTargetAndStartAction(); + final Target tA = createTargetAndStartAction(); // cancel the active action deploymentManagement.cancelAction(tA.getActions().get(0), tA); @@ -272,7 +272,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { @Description("Force Quit an Action, which is already canceled. Expected Result is an HTTP response code 204.") public void forceQuitAnCanceledActionReturnsOk() throws Exception { - Target tA = createTargetAndStartAction(); + final Target tA = createTargetAndStartAction(); // cancel the active action deploymentManagement.cancelAction(tA.getActions().get(0), tA); @@ -293,7 +293,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { @Description("Force Quit an Action, which is not canceled. Expected Result is an HTTP response code 405.") public void forceQuitAnNotCanceledActionReturnsMethodNotAllowed() throws Exception { - Target tA = createTargetAndStartAction(); + final Target tA = createTargetAndStartAction(); // test - cancel an cancel action returns forbidden mvc.perform(delete(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}?force=true", @@ -1232,7 +1232,8 @@ public class TargetResourceTest extends AbstractIntegrationTest { // prepare test final DistributionSet dsA = TestDataUtil.generateDistributionSet("", softwareManagement, distributionSetManagement); - Target tA = targetManagement.createTarget(TestDataUtil.buildTargetFixture("target-id-A", "first description")); + final Target tA = targetManagement + .createTarget(TestDataUtil.buildTargetFixture("target-id-A", "first description")); // assign a distribution set so we get an active update action deploymentManagement.assignDistributionSet(dsA, Lists.newArrayList(tA)); // verify active action diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java index e9601d693..a1df7f298 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java @@ -15,10 +15,17 @@ import java.util.List; import org.junit.Test; +import ru.yandex.qatools.allure.annotations.Description; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Junit Tests - Management API") +@Stories("Error Handling") public class ExceptionInfoTest { @Test - public void setterAndGetter() { + @Description("Ensures that setters and getters match on teh payload.") + public void setterAndGetterOnExceptionInfo() { final String knownExceptionClass = "hawkbit.test.exception.Class"; final String knownErrorCode = "hawkbit.error.code.Known"; final String knownMessage = "a known message"; diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java index 0c47856dd..9c5a5ac12 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java @@ -15,14 +15,22 @@ import java.util.List; import org.junit.Test; +import ru.yandex.qatools.allure.annotations.Description; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Junit Tests - Management API") +@Stories("Paged List Handling") public class PagedListTest { @Test(expected = NullPointerException.class) + @Description("Ensures that a null payload entitiy throws an exception.") public void createListWithNullContentThrowsException() { new PagedList<>(null, 0); } @Test + @Description("Create list with payload and verify content.") public void createListWithContent() { final long knownTotal = 2; final List knownContentList = new ArrayList<>(); @@ -36,6 +44,7 @@ public class PagedListTest { } @Test + @Description("Create list with payload and verify size values.") public void createListWithSmallerTotalThanContentSizeIsOk() { final long knownTotal = 0; final List knownContentList = new ArrayList<>(); From a9f91e90da42202bba9bba79a42e80e9597a6c50 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Mon, 22 Feb 2016 20:13:45 +0100 Subject: [PATCH 03/12] Removed old issue numbers. Further documentation --- .../repository/DeploymentManagement.java | 2 +- .../repository/DistributionSetManagement.java | 3 +-- .../hawkbit/repository/SystemManagement.java | 2 +- .../hawkbit/repository/ActionTest.java | 8 ++++++- .../ArtifactManagementNoMongoDbTest.java | 3 --- .../repository/DeploymentManagementTest.java | 1 - .../hawkbit/controller/RootController.java | 2 -- .../DistributionSetTypeResourceTest.java | 3 --- .../rest/resource/DownloadResourceTest.java | 4 ---- .../rest/resource/RolloutResourceTest.java | 2 +- .../resource/SoftwareModuleResourceTest.java | 8 ------- .../rest/resource/TargetResourceTest.java | 22 +++++++++++++------ ...yTokenAuthenticationConfigurationItem.java | 3 +-- 13 files changed, 27 insertions(+), 36 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index 560549e7e..c0319a069 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -365,7 +365,7 @@ public class DeploymentManagement { }).collect(Collectors.toList())).stream() .collect(Collectors.toMap(a -> a.getTarget().getControllerId(), Function.identity())); - // MECS-720 create initial action status when action is created so we + // create initial action status when action is created so we // remember the initial // running status because we will change the status of the action itself // and with this action diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java index d22a77f75..8b07c9bf8 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java @@ -294,8 +294,7 @@ public class DistributionSetManagement { // hard delete the rest if exixts if (!toHardDelete.isEmpty()) { // don't give the delete statement an empty list, JPA/Oracle cannot - // handle the empty list, - // see MECS-403 + // handle the empty list distributionSetRepository.deleteByIdIn(toHardDelete); } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java index 09b6025d3..aac5db7f5 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java @@ -280,7 +280,7 @@ public class SystemManagement implements EnvironmentAware { * @return {@code true} in case the tenant exits or {@code false} if not */ @Cacheable(value = "currentTenant", keyGenerator = "currentTenantKeyGenerator") - // MECS-903 set transaction to not supported, due we call this in + // set transaction to not supported, due we call this in // BaseEntity#prePersist methods // and it seems that JPA committing the transaction when executing this // transactional method, diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java index 0ce7dd677..9bd532b5e 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java @@ -14,10 +14,16 @@ import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.junit.Test; +import ru.yandex.qatools.allure.annotations.Description; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Unit Tests - Repository") +@Stories("Deployment Management") public class ActionTest { - // issue MECS-670 timeforced update and eTAG calculation @Test + @Description("Ensures that timeforced moded switch from soft to forces after defined timeframe.") public void timeforcedHitNewHasCodeIsGenerated() throws InterruptedException { final boolean active = true; diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementNoMongoDbTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementNoMongoDbTest.java index e509a3b0c..dd1e171ca 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementNoMongoDbTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementNoMongoDbTest.java @@ -25,9 +25,6 @@ import ru.yandex.qatools.allure.annotations.Stories; /** * Addition tests next to {@link ArtifactManagementTest} with no running MongoDB * - * - * - * */ @Features("Component Tests - Repository") @Stories("Artifact Management") diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java index 693a67082..0db3325aa 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java @@ -140,7 +140,6 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { @Test @Description("Test verifies that an assignment with automatic cancelation works correctly even if the update is split into multiple partitions on the database.") - @Issue("MECS-674") public void multiAssigmentHistoryOverMultiplePagesResultsInTwoActiveAction() { final DistributionSet cancelDs = TestDataUtil.generateDistributionSet("Canceled DS", "1.0", softwareManagement, diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java index 8246dd430..2b0ac810e 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java @@ -435,8 +435,6 @@ public class RootController implements EnvironmentAware { LOG.debug("Controller reported intermediate status (actionid: {}, targetid: {}) as we got {} report.", actionid, targetid, feedback.getStatus().getExecution()); actionStatus.setStatus(Status.RUNNING); - // MECS-400: we should not use the unstructed message list for - // the server comment on the status. actionStatus.addMessage("Controller reported: " + feedback.getStatus().getExecution()); } diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java index 3ca25132a..78f4f741e 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java @@ -46,9 +46,6 @@ import ru.yandex.qatools.allure.annotations.Stories; /** * Test for {@link DistributionSetTypeResource}. * - * - * - * */ @Features("Component Tests - Management API") @Stories("Distribution Set Type Resource") diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java index 6c33b0eea..ee0fa52fe 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java @@ -30,10 +30,6 @@ import org.springframework.context.annotation.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -/** - * - * - */ @Features("Component Tests - Management API") @Stories("Download Resource") public class DownloadResourceTest extends AbstractIntegrationTestWithMongoDB { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java index cb4fc9f4a..afa12b7af 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java @@ -99,7 +99,7 @@ public class RolloutResourceTest extends AbstractIntegrationTest { .andReturn(); } - @Description("TODO") + @Description("Ensures that the repository refuses to create rollout without a defined target filter set.") public void missingTargetFilterQueryInRollout() throws Exception { final String targetFilterQuery = null; diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java index 5b6923686..0587a305c 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java @@ -112,14 +112,6 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } - /** - * Test method for - * {@link org.eclipse.hawkbit.rest.resource.SoftwareModuleResource#uploadArtifact(java.lang.Long, org.springframework.web.multipart.MultipartFile)} - * . - * - * @throws Exception - * if test fails - */ @Test @Description("Tests the uppload of an artifact binary. The upload is executed and the content checked in the repository for completenes.") public void uploadArtifact() throws Exception { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java index d1dd4d6ed..3ae423448 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java @@ -74,8 +74,6 @@ import ru.yandex.qatools.allure.annotations.Stories; */ @Features("Component Tests - Management API") @Stories("Target Resource") -// TODO: fully document tests -> @Description for long text and reasonable -// method name as short text public class TargetResourceTest extends AbstractIntegrationTest { private static final String TARGET_DESCRIPTION_TEST = "created in test"; @@ -103,10 +101,8 @@ public class TargetResourceTest extends AbstractIntegrationTest { private static final String JSON_PATH_CONTROLLERID = JSON_PATH_ROOT + JSON_PATH_FIELD_CONTROLLERID; private static final String JSON_PATH_DESCRIPTION = JSON_PATH_ROOT + JSON_PATH_FIELD_DESCRIPTION; - // TODO kzimmerm: test *modified after entity change - @Test - // MECS-1064 + @Description("Ensures that actions list is in exptected order.") public void getActionStatusReturnsCorrectType() throws Exception { final int limitSize = 2; final String knownTargetId = "targetId"; @@ -141,6 +137,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that security token is not returned if user does not have READ_TARGET_SEC_TOKEN permission.") @WithUser(allSpPermissions = false, authorities = { SpPermission.READ_TARGET, SpPermission.CREATE_TARGET }) public void securityTokenIsNotInResponseIfMissingPermission() throws Exception { @@ -152,6 +149,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that security token is returned if user does have READ_TARGET_SEC_TOKEN permission.") @WithUser(allSpPermissions = false, authorities = { SpPermission.READ_TARGET, SpPermission.CREATE_TARGET, SpPermission.READ_TARGET_SEC_TOKEN }) public void securityTokenIsInResponseWithCorrectPermission() throws Exception { @@ -164,6 +162,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that that IP address is in result as stored in the repository.") public void addressAndIpAddressInTargetResult() throws Exception { // prepare targets with IP final String knownControllerId1 = "0815"; @@ -195,6 +194,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that actions history is returned as defined by filter status==pending,status==finished.") public void searchActionsRsql() throws Exception { // prepare test @@ -227,6 +227,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that a deletion of an active action results in cancelation triggered.") public void cancelActionOK() throws Exception { // prepare test final Target tA = createTargetAndStartAction(); @@ -250,7 +251,8 @@ public class TargetResourceTest extends AbstractIntegrationTest { } @Test - public void cancelAnCancelActionIsNotAllowed() throws Exception { + @Description("Ensures that method not allowed is returned if cancelation is triggered on already canceled action.") + public void cancelAndCancelActionIsNotAllowed() throws Exception { // prepare test final Target tA = createTargetAndStartAction(); @@ -302,6 +304,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that deletion is executed if permitted.") public void deleteTargetReturnsOK() throws Exception { final String knownControllerId = "knownControllerIdDelete"; targetManagement.createTarget(new Target(knownControllerId)); @@ -314,6 +317,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that deletion is refused with not found if target does not exist.") public void deleteTargetWhichDoesNotExistsLeadsToEntityNotFound() throws Exception { final String knownControllerId = "knownControllerIdDelete"; @@ -322,6 +326,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that update is refused with not found if target does not exist.") public void updateTargetWhichDoesNotExistsLeadsToEntityNotFound() throws Exception { final String knownControllerId = "knownControllerIdUpdate"; mvc.perform(put(RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content("{}") @@ -330,6 +335,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that target update request is reflected by repository.") public void updateTargetDescription() throws Exception { final String knownControllerId = "123"; final String knownNewDescription = "a new desc updated over rest"; @@ -354,6 +360,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that target query returns list of targets in defined format.") public void getTargetWithoutAddtionalRequestParameters() throws Exception { final int knownTargetAmount = 3; final String idA = "a"; @@ -393,6 +400,7 @@ public class TargetResourceTest extends AbstractIntegrationTest { } @Test + @Description("Ensures that target query returns list of targets in defined format in size reduced by given limit parameter.") public void getTargetWithPagingLimitRequestParameter() throws Exception { final int knownTargetAmount = 3; final int limitSize = 1; @@ -413,10 +421,10 @@ public class TargetResourceTest extends AbstractIntegrationTest { .andExpect(jsonPath("$content.[?(@.name==" + idA + ")][0].controllerId", equalTo(idA))) .andExpect(jsonPath("$content.[?(@.name==" + idA + ")][0].createdBy", equalTo("bumlux"))) .andExpect(jsonPath("$content.[?(@.name==" + idA + ")][0].updateStatus", equalTo("unknown"))); - } @Test + @Description("Ensures that target query returns list of targets in defined format in size reduced by given limit and offset parameter.") public void getTargetWithPagingLimitAndOffsetRequestParameter() throws Exception { final int knownTargetAmount = 5; final int offsetParam = 2; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java index 6ae002263..790f219d8 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java @@ -84,8 +84,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac gatewayTokenNameTextField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null, "", true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH); gatewayTokenNameTextField.setImmediate(true); - // hide text field until we support multiple gateway tokens for a tenant - // MECS-830 + // hide text field until we support multiple gateway tokens for a tenan gatewayTokenNameTextField.setVisible(false); gatewayTokenNameTextField.addTextChangeListener(event -> keyNameChanged()); From 7f2a9d1ed2913af56b28f143771b2dfa3bd8b3bd Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Tue, 23 Feb 2016 09:57:18 +0100 Subject: [PATCH 04/12] Features harmonised, more test descriptions --- .../repository/ArtifactStoreTest.java | 5 + .../cache/eventbus/EventDistributorTest.java | 5 + .../cache/redis/RedisPropertiesTest.java | 5 + .../EventBusSubscriberProcessorTest.java | 5 + .../AmqpControllerAuthentficationTest.java | 4 +- .../AmqpMessageDispatcherServiceTest.java | 4 +- .../amqp/AmqpMessageHandlerServiceTest.java | 4 +- ...SourceTrustAuthenticationProviderTest.java | 5 + .../eclipse/hawkbit/cache/CacheKeysTest.java | 5 + .../hawkbit/cache/CacheWriteNotifyTest.java | 5 + .../CacheFieldEntityListenerTest.java | 5 + .../hawkbit/repository/TagManagementTest.java | 94 ++++++++----------- .../TargetManagementSearchTest.java | 6 +- .../repository/rsql/RSQLActionFieldsTest.java | 2 +- .../rsql/RSQLDistributionSetFieldTest.java | 2 +- ...RSQLDistributionSetMetadataFieldsTest.java | 2 +- .../rsql/RSQLRolloutGroupFields.java | 2 +- .../rsql/RSQLSoftwareModuleFieldTest.java | 2 +- .../RSQLSoftwareModuleMetadataFieldsTest.java | 2 +- .../RSQLSoftwareModuleTypeFieldsTest.java | 2 +- .../repository/rsql/RSQLTagFieldsTest.java | 2 +- .../repository/rsql/RSQLTargetFieldTest.java | 2 +- .../repository/rsql/RSQLUtilityTest.java | 2 +- .../tenancy/MultiTenancyEntityTest.java | 68 ++++---------- .../rest/resource/RolloutResourceTest.java | 2 - .../rest/resource/TargetResourceTest.java | 3 - .../security/SecurityTokenGeneratorTest.java | 5 + .../org/eclipse/hawkbit/util/IpUtilTest.java | 4 +- 28 files changed, 124 insertions(+), 130 deletions(-) diff --git a/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreTest.java b/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreTest.java index 2a8441ee6..c53447a6c 100644 --- a/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreTest.java +++ b/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreTest.java @@ -34,6 +34,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.google.common.io.BaseEncoding; import com.mongodb.gridfs.GridFSDBFile; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Component Tests - Repository") +@Stories("Artifact Store MongoDB") @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = { ArtifactStoreAutoConfiguration.class, TestConfiguration.class }) public class ArtifactStoreTest { diff --git a/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/eventbus/EventDistributorTest.java b/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/eventbus/EventDistributorTest.java index e44889f60..fb657638e 100644 --- a/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/eventbus/EventDistributorTest.java +++ b/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/eventbus/EventDistributorTest.java @@ -29,6 +29,11 @@ import org.springframework.hateoas.Identifiable; import com.google.common.eventbus.EventBus; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Unit Tests - Cluster Cache") +@Stories("EventDistributor Test") @RunWith(MockitoJUnitRunner.class) public class EventDistributorTest { diff --git a/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/redis/RedisPropertiesTest.java b/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/redis/RedisPropertiesTest.java index 6aac1b03f..ab57dd541 100644 --- a/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/redis/RedisPropertiesTest.java +++ b/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/redis/RedisPropertiesTest.java @@ -13,6 +13,11 @@ import static org.fest.assertions.api.Assertions.assertThat; import org.eclipse.hawkbit.cache.RedisProperties; import org.junit.Test; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Unit Tests - Cluster Cache") +@Stories("Redis Properties Test") public class RedisPropertiesTest { @Test diff --git a/hawkbit-core/src/test/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessorTest.java b/hawkbit-core/src/test/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessorTest.java index ac02aaad1..2925ba878 100644 --- a/hawkbit-core/src/test/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessorTest.java +++ b/hawkbit-core/src/test/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessorTest.java @@ -21,6 +21,11 @@ import org.mockito.runners.MockitoJUnitRunner; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Unit Tests - Cluster Event Bus") +@Stories("EventBus Subscriber Processor Test") @RunWith(MockitoJUnitRunner.class) public class EventBusSubscriberProcessorTest { diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java index 1d962907b..d44bee337 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java @@ -47,8 +47,8 @@ import ru.yandex.qatools.allure.annotations.Stories; * * Test Amqp controller authentfication. */ -@Features("AMQP Authenfication Test") -@Stories("Tests the authenfication") +@Features("Component Tests - Device Management Federation API") +@Stories("AmqpController Authentfication Test") public class AmqpControllerAuthentficationTest { private static final String TENANT = "DEFAULT"; diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java index 348e8dea4..6584d9349 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java @@ -53,8 +53,8 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; @ActiveProfiles({ "test" }) -@Features("AMQP Dispatcher Test") -@Stories("Tests send messages") +@Features("Component Tests - Device Management Federation API") +@Stories("AmqpMessage Dispatcher Service Test") public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWithMongoDB { private AmqpMessageDispatcherService amqpMessageDispatcherService; diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java index bea75e9d6..4a05e96ff 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java @@ -68,8 +68,8 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; @RunWith(MockitoJUnitRunner.class) -@Features("AMQP Controller Test") -@Stories("Tests the servcies for message handler and dispatcher") +@Features("Component Tests - Device Management Federation API") +@Stories("AmqpMessage Handler Service Test") public class AmqpMessageHandlerServiceTest { private static final String TENANT = "DEFAULT"; diff --git a/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java b/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java index f2ffe5c4c..a5b02ffb1 100644 --- a/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java +++ b/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java @@ -20,6 +20,11 @@ import org.springframework.security.authentication.InsufficientAuthenticationExc import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Unit Tests - Security") +@Stories("PreAuthToken Source TrustAuthentication Provider Test") @RunWith(MockitoJUnitRunner.class) public class PreAuthTokenSourceTrustAuthenticationProviderTest { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheKeysTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheKeysTest.java index 6c9314d07..b0da78abd 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheKeysTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheKeysTest.java @@ -12,6 +12,11 @@ import static org.fest.assertions.api.Assertions.assertThat; import org.junit.Test; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Unit Tests - Repository") +@Stories("CacheKeys") public class CacheKeysTest { @Test diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheWriteNotifyTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheWriteNotifyTest.java index 3b69b4fed..c88a3e717 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheWriteNotifyTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheWriteNotifyTest.java @@ -26,6 +26,11 @@ import org.springframework.cache.CacheManager; import com.google.common.eventbus.EventBus; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Unit Tests - Repository") +@Stories("CacheWriteNotify") @RunWith(MockitoJUnitRunner.class) public class CacheWriteNotifyTest { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/eventbus/CacheFieldEntityListenerTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/eventbus/CacheFieldEntityListenerTest.java index e80c49b2d..4943ea88a 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/eventbus/CacheFieldEntityListenerTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/eventbus/CacheFieldEntityListenerTest.java @@ -27,6 +27,11 @@ import org.springframework.cache.CacheManager; import org.springframework.cache.support.SimpleValueWrapper; import org.springframework.hateoas.Identifiable; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Unit Tests - Repository") +@Stories("EventBus") @RunWith(MockitoJUnitRunner.class) public class CacheFieldEntityListenerTest { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java index 9c1a9b66e..b8a4db598 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java @@ -34,13 +34,9 @@ import ru.yandex.qatools.allure.annotations.Stories; /** * Test class for {@link TagManagement}. * - * - * */ @Features("Component Tests - Repository") @Stories("Tag Management") -// TODO: fully document tests -> @Description for long text and reasonable -// method name as short text public class TagManagementTest extends AbstractIntegrationTest { public TagManagementTest() { LOG = LoggerFactory.getLogger(TagManagementTest.class); @@ -155,13 +151,9 @@ public class TagManagementTest extends AbstractIntegrationTest { return new DistributionSetFilterBuilder(); } - /** - * Test method for - * {@link org.eclipse.hawkbit.repository.TagManagement#findTargetTag(java.lang.String)} - * . - */ @Test - public void testFindTargetTag() { + @Description("Ensures that all tags are retrieved through repository.") + public void findAllTargetTags() { assertThat(targetTagRepository.findAll()).isEmpty(); final List tags = createTargetsWithTags(); @@ -170,13 +162,9 @@ public class TagManagementTest extends AbstractIntegrationTest { .hasSize(20); } - /** - * Test method for - * {@link org.eclipse.hawkbit.repository.TagManagement#createTargetTag(org.eclipse.hawkbit.repository.model.TargetTag)} - * . - */ @Test - public void testCreateTargetTag() { + @Description("Ensures that a created tag is persisted in the repository as defined.") + public void createTargetTag() { assertThat(targetTagRepository.findAll()).isEmpty(); final Tag tag = tagManagement.createTargetTag(new TargetTag("kai1", "kai2", "colour")); @@ -186,13 +174,9 @@ public class TagManagementTest extends AbstractIntegrationTest { assertThat(tagManagement.findTargetTagById(tag.getId()).getColour()).isEqualTo("colour"); } - /** - * Test method for - * {@link org.eclipse.hawkbit.repository.TagManagement#deleteTargetTag(java.lang.String[])} - * . - */ @Test - public void testDeleteTargetTagsStringArray() { + @Description("Ensures that a deleted tag is removed from the repository as defined.") + public void deleteTargetTas() { assertThat(targetTagRepository.findAll()).isEmpty(); // create test data @@ -217,7 +201,7 @@ public class TagManagementTest extends AbstractIntegrationTest { } @Test - @Description("Tests the creation of a target tag.") + @Description("Tests the name update of a target tag.") public void updateTargetTag() { assertThat(targetTagRepository.findAll()).isEmpty(); @@ -237,13 +221,9 @@ public class TagManagementTest extends AbstractIntegrationTest { assertThat(targetTagRepository.findOne(savedAssigned.getId()).getOptLockRevision()).isEqualTo(2); } - /** - * Test method for - * {@link org.eclipse.hawkbit.repository.TagManagement#createDistributionSetTag(org.eclipse.hawkbit.repository.model.DistributionSetTag)} - * . - */ @Test - public void testCreateDistributionSetTag() { + @Description("Ensures that a created tag is persisted in the repository as defined.") + public void createDistributionSetTag() { assertThat(distributionSetTagRepository.findAll()).isEmpty(); final Tag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("kai1", "kai2", "colour")); @@ -253,13 +233,9 @@ public class TagManagementTest extends AbstractIntegrationTest { assertThat(tagManagement.findDistributionSetTagById(tag.getId()).getColour()).isEqualTo("colour"); } - /** - * Test method for - * {@link org.eclipse.hawkbit.repository.TagManagement#createDistributionSetTags(java.lang.Iterable)} - * . - */ @Test - public void testCreateDistributionSetTags() { + @Description("Ensures that a created tags are persisted in the repository as defined.") + public void createDistributionSetTags() { assertThat(distributionSetTagRepository.findAll()).isEmpty(); final List tags = createDsSetsWithTags(); @@ -267,13 +243,9 @@ public class TagManagementTest extends AbstractIntegrationTest { assertThat(distributionSetTagRepository.findAll()).hasSize(tags.size()); } - /** - * Test method for - * {@link org.eclipse.hawkbit.repository.TagManagement#deleteDistributionSetTag(java.lang.String[])} - * . - */ @Test - public void testDeleteDistributionSetTag() { + @Description("Ensures that a deleted tag is removed from the repository as defined.") + public void deleteDistributionSetTag() { assertThat(distributionSetTagRepository.findAll()).isEmpty(); // create test data @@ -298,24 +270,40 @@ public class TagManagementTest extends AbstractIntegrationTest { } @Test(expected = EntityAlreadyExistsException.class) - public void testFailedDuplicateTargetTagNameException() { + @Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).") + public void failedDuplicateTargetTagNameException() { tagManagement.createTargetTag(new TargetTag("A")); tagManagement.createTargetTag(new TargetTag("A")); } @Test(expected = EntityAlreadyExistsException.class) - public void testFailedDuplicateDsTagNameException() { + @Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).") + public void failedDuplicateTargetTagNameExceptionAfterUpdate() { + tagManagement.createTargetTag(new TargetTag("A")); + final TargetTag tag = tagManagement.createTargetTag(new TargetTag("B")); + tag.setName("A"); + tagManagement.updateTargetTag(tag); + } + + @Test(expected = EntityAlreadyExistsException.class) + @Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).") + public void failedDuplicateDsTagNameException() { tagManagement.createDistributionSetTag(new DistributionSetTag("A")); tagManagement.createDistributionSetTag(new DistributionSetTag("A")); } - /** - * Test method for - * {@link org.eclipse.hawkbit.repository.TagManagement#updateDistributionSetTag(org.eclipse.hawkbit.repository.model.DistributionSetTag)} - * . - */ + @Test(expected = EntityAlreadyExistsException.class) + @Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).") + public void failedDuplicateDsTagNameExceptionAfterUpdate() { + tagManagement.createDistributionSetTag(new DistributionSetTag("A")); + final DistributionSetTag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("B")); + tag.setName("A"); + tagManagement.updateDistributionSetTag(tag); + } + @Test - public void testUpdateDistributionSetTag() { + @Description("Tests the name update of a target tag.") + public void updateDistributionSetTag() { assertThat(distributionSetTagRepository.findAll()).isEmpty(); // create test data @@ -333,13 +321,9 @@ public class TagManagementTest extends AbstractIntegrationTest { assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).isEqualTo("test123"); } - /** - * Test method for - * {@link org.eclipse.hawkbit.repository.TagManagement#findAllDistributionSetTags()} - * . - */ @Test - public void testFindDistributionSetTagsAll() { + @Description("Ensures that all tags are retrieved through repository.") + public void findDistributionSetTagsAll() { assertThat(distributionSetTagRepository.findAll()).isEmpty(); final List tags = createDsSetsWithTags(); diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementSearchTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementSearchTest.java index bd9884e89..34aa223c3 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementSearchTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementSearchTest.java @@ -47,7 +47,7 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest { final TargetTag targTagC = tagManagement.createTargetTag(new TargetTag("TargTag-C")); final TargetTag targTagD = tagManagement.createTargetTag(new TargetTag("TargTag-D")); - // TODO kzimmerm: test also installedDS (not only assignedDS) + // TODO kaizimmerm: test also installedDS (not only assignedDS) final DistributionSet setA = TestDataUtil.generateDistributionSet("", softwareManagement, distributionSetManagement); @@ -90,7 +90,7 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest { final PageRequest pageReq = new PageRequest(0, 500); // try to find several targets with different filter settings - // TODO kzimmerm: comment and check also the content itself, not only + // TODO kaizimmerm: comment and check also the content itself, not only // the numbers // (containsOnly) assertThat(targetManagement.countTargetsAll()).isEqualTo(400); @@ -185,7 +185,7 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest { } - // TODO kzimmerm: add filter tests + // TODO kaizimmerm: add filter tests @Test @Description("Tests the correct order of targets based on selected distribution set. The system expects to have an order based on installed, assigned DS.") public void targetSearchWithVariousFilterCombinationsAndOrderByDistributionSet() { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLActionFieldsTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLActionFieldsTest.java index 71cf511ae..0c4a3aadd 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLActionFieldsTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLActionFieldsTest.java @@ -26,7 +26,7 @@ import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -@Features("Component Tests - RSQL filtering") +@Features("Component Tests - Repository") @Stories("RSQL filter actions") public class RSQLActionFieldsTest extends AbstractIntegrationTest { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetFieldTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetFieldTest.java index 6bfdb89aa..0c316f918 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetFieldTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetFieldTest.java @@ -28,7 +28,7 @@ import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -@Features("Component Tests - RSQL filtering") +@Features("Component Tests - Repository") @Stories("RSQL filter distribution set") public class RSQLDistributionSetFieldTest extends AbstractIntegrationTest { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetMetadataFieldsTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetMetadataFieldsTest.java index 2d113a0a3..1d1e8b7f3 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetMetadataFieldsTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetMetadataFieldsTest.java @@ -24,7 +24,7 @@ import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -@Features("Component Tests - RSQL filtering") +@Features("Component Tests - Repository") @Stories("RSQL filter distribution set metadata") public class RSQLDistributionSetMetadataFieldsTest extends AbstractIntegrationTest { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLRolloutGroupFields.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLRolloutGroupFields.java index 05e26293c..78d333826 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLRolloutGroupFields.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLRolloutGroupFields.java @@ -27,7 +27,7 @@ import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -@Features("Component Tests - RSQL filtering") +@Features("Component Tests - Repository") @Stories("RSQL filter rollout group") public class RSQLRolloutGroupFields extends AbstractIntegrationTest { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleFieldTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleFieldTest.java index 55e4386cd..88f0817f7 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleFieldTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleFieldTest.java @@ -23,7 +23,7 @@ import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -@Features("Component Tests - RSQL filtering") +@Features("Component Tests - Repository") @Stories("RSQL filter software module") public class RSQLSoftwareModuleFieldTest extends AbstractIntegrationTest { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleMetadataFieldsTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleMetadataFieldsTest.java index f75893b43..c863c1460 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleMetadataFieldsTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleMetadataFieldsTest.java @@ -24,7 +24,7 @@ import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -@Features("Component Tests - RSQL filtering") +@Features("Component Tests - Repository") @Stories("RSQL filter software module metadata") public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractIntegrationTest { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleTypeFieldsTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleTypeFieldsTest.java index 008de9199..12f4005ac 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleTypeFieldsTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLSoftwareModuleTypeFieldsTest.java @@ -21,7 +21,7 @@ import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -@Features("Component Tests - RSQL filtering") +@Features("Component Tests - Repository") @Stories("RSQL filter software module test type") public class RSQLSoftwareModuleTypeFieldsTest extends AbstractIntegrationTest { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLTagFieldsTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLTagFieldsTest.java index e3ab8fc2c..b35ed13d1 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLTagFieldsTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLTagFieldsTest.java @@ -23,7 +23,7 @@ import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -@Features("Component Tests - RSQL filtering") +@Features("Component Tests - Repository") @Stories("RSQL filter target and distribution set tags") public class RSQLTagFieldsTest extends AbstractIntegrationTest { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLTargetFieldTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLTargetFieldTest.java index 2f77346f2..54efab860 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLTargetFieldTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLTargetFieldTest.java @@ -30,7 +30,7 @@ import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -@Features("Component Tests - RSQL filtering") +@Features("Component Tests - Repository") @Stories("RSQL filter target") public class RSQLTargetFieldTest extends AbstractIntegrationTest { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLUtilityTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLUtilityTest.java index 3b923d167..1e58b2f8c 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLUtilityTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLUtilityTest.java @@ -40,7 +40,7 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; @RunWith(MockitoJUnitRunner.class) -@Features("Component Tests - RSQL filtering") +@Features("Component Tests - Repository") @Stories("RSQL search utility") // TODO: fully document tests -> @Description for long text and reasonable // method name as short text diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java index 51e49ef04..1dd4c9823 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java @@ -10,8 +10,6 @@ package org.eclipse.hawkbit.tenancy; import static org.fest.assertions.api.Assertions.assertThat; -import java.util.concurrent.Callable; - import org.eclipse.hawkbit.AbstractIntegrationTest; import org.eclipse.hawkbit.WithSpringAuthorityRule; import org.eclipse.hawkbit.WithUser; @@ -31,9 +29,6 @@ import ru.yandex.qatools.allure.annotations.Stories; * CRUD-Operations are tenant aware and cannot access or delete entities not * belonging to the current tenant. * - * - * - * */ @Features("Component Tests - Repository") @Stories("Multi Tenancy") @@ -97,13 +92,9 @@ public class MultiTenancyEntityTest extends AbstractIntegrationTest { // check that the cache is not getting in the way, i.e. "bumlux" results // in bumlux and not // mytenant - assertThat( - securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", "bumlux"), new Callable() { - @Override - public String call() throws Exception { - return systemManagement.getTenantMetadata().getTenant().toUpperCase(); - } - })).isEqualTo("bumlux".toUpperCase()); + assertThat(securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", "bumlux"), + () -> systemManagement.getTenantMetadata().getTenant().toUpperCase())) + .isEqualTo("bumlux".toUpperCase()); } @Test @@ -154,59 +145,38 @@ public class MultiTenancyEntityTest extends AbstractIntegrationTest { } private Target createTargetForTenant(final String controllerId, final String tenant) throws Exception { - return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant), new Callable() { - @Override - public Target call() throws Exception { - return targetManagement.createTarget(new Target(controllerId)); - } - }); + return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant), + () -> targetManagement.createTarget(new Target(controllerId))); } private Slice findTargetsForTenant(final String tenant) throws Exception { return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant), - new Callable>() { - @Override - public Slice call() throws Exception { - return targetManagement.findTargetsAll(pageReq); - } - }); + () -> targetManagement.findTargetsAll(pageReq)); } private void deleteTargetsForTenant(final String tenant, final Long... targetIds) throws Exception { - securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant), new Callable() { - @Override - public Void call() throws Exception { - targetManagement.deleteTargets(targetIds); - return null; - } + securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant), () -> { + targetManagement.deleteTargets(targetIds); + return null; }); } private DistributionSet createDistributionSetForTenant(final String name, final String version, final String tenant) throws Exception { - return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant), - new Callable() { - @Override - public DistributionSet call() throws Exception { - final DistributionSet ds = new DistributionSet(); - ds.setName(name); - ds.setTenant(tenant); - ds.setVersion(version); - ds.setType(distributionSetManagement - .createDistributionSetType(new DistributionSetType("typetest", "test", "foobar"))); - return distributionSetManagement.createDistributionSet(ds); - } - }); + return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant), () -> { + final DistributionSet ds = new DistributionSet(); + ds.setName(name); + ds.setTenant(tenant); + ds.setVersion(version); + ds.setType(distributionSetManagement + .createDistributionSetType(new DistributionSetType("typetest", "test", "foobar"))); + return distributionSetManagement.createDistributionSet(ds); + }); } private Page findDistributionSetForTenant(final String tenant) throws Exception { return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant), - new Callable>() { - @Override - public Page call() throws Exception { - return distributionSetManagement.findDistributionSetsAll(pageReq, false, false); - } - }); + () -> distributionSetManagement.findDistributionSetsAll(pageReq, false, false)); } } diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java index afa12b7af..29cb4ede0 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RolloutResourceTest.java @@ -435,7 +435,6 @@ public class RolloutResourceTest extends AbstractIntegrationTest { .andExpect(jsonPath("$content", hasSize(5))).andExpect(jsonPath("$total", equalTo(5))); } - // TODO @Test @Description("Start the rollout in async mode") public void startingRolloutSwitchesIntoRunningStateAsync() throws Exception { @@ -528,7 +527,6 @@ public class RolloutResourceTest extends AbstractIntegrationTest { } - // TODO copied code from sp-bic-test protected T doWithTimeout(final Callable callable, final SuccessCondition successCondition, final long timeout, final long pollInterval) throws Exception // NOPMD { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java index 3ae423448..e9b0bd60a 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java @@ -66,11 +66,8 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; /** - * * Spring MVC Tests against the TargetResource. * - * - * */ @Features("Component Tests - Management API") @Stories("Target Resource") diff --git a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/security/SecurityTokenGeneratorTest.java b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/security/SecurityTokenGeneratorTest.java index 405d6d010..9228e700c 100644 --- a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/security/SecurityTokenGeneratorTest.java +++ b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/security/SecurityTokenGeneratorTest.java @@ -13,6 +13,11 @@ import java.security.NoSuchAlgorithmException; import org.junit.Test; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Unit Tests - Security") +@Stories("SecurityToken Generator Test") public class SecurityTokenGeneratorTest { @Test diff --git a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java index e1e809ab8..25e1c974b 100644 --- a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java +++ b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java @@ -33,8 +33,8 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; @RunWith(MockitoJUnitRunner.class) -@Features("IpUtil Test") -@Stories("Tests the created uris") +@Features("Unit Tests - Security") +@Stories("IP Util Test") public class IpUtilTest { @Mock From ac9547e04c5c766d1e923a9ea82c5d5d6d549fd5 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Tue, 23 Feb 2016 20:01:50 +0100 Subject: [PATCH 05/12] Completed test docs on artefact repo --- .../hawkbit/artifact/repository/ArtifactStoreTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreTest.java b/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreTest.java index c53447a6c..c5aca8e1a 100644 --- a/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreTest.java +++ b/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreTest.java @@ -34,6 +34,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.google.common.io.BaseEncoding; import com.mongodb.gridfs.GridFSDBFile; +import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; @@ -53,6 +54,7 @@ public class ArtifactStoreTest { private GridFsOperations gridFs; @Test + @Description("Ensures that storage in MongoDB is correctly executed.s") public void storeArtifactInMongoDB() { final int filelengthBytes = 128; final String filename = "testfile.json"; @@ -65,6 +67,7 @@ public class ArtifactStoreTest { } @Test + @Description("Ensures that search by SHA1 hash (which is used by hawkBit as artifact ID) finds the expected results.") public void findArtifactBySHA1Hash() throws NoSuchAlgorithmException { final int filelengthBytes = 128; final String filename = "testfile.json"; @@ -77,6 +80,7 @@ public class ArtifactStoreTest { } @Test + @Description("Ensures that search by MD5 hash finds the expected results.") public void findArtifactByMD5Hash() throws NoSuchAlgorithmException { final int filelengthBytes = 128; final String filename = "testfile.json"; @@ -89,6 +93,7 @@ public class ArtifactStoreTest { } @Test + @Description("Ensures that artifact content can be read through InputStream.") public void getInputStreamFromArtifact() throws IOException { final int filelengthBytes = 128; final String filename = "testfile.json"; @@ -108,7 +113,8 @@ public class ArtifactStoreTest { } @Test - public void deleteArtifactWithOnlyOneTenantLast() throws NoSuchAlgorithmException { + @Description("Ensures that artifact delete actually results in deletion from database.") + public void deleteArtifact() throws NoSuchAlgorithmException { final int filelengthBytes = 128; final String filename = "testfile.json"; final String contentType = "application/json"; From 204fe1fd18920fd5c8dda2fcc1acb3355077acde Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Tue, 23 Feb 2016 20:53:21 +0100 Subject: [PATCH 06/12] Created TODOs for missing descriptions --- .../hawkbit/cache/eventbus/EventDistributorTest.java | 1 + .../hawkbit/eventbus/EventBusSubscriberProcessorTest.java | 1 + .../PreAuthTokenSourceTrustAuthenticationProviderTest.java | 1 + .../hawkbit/security/SecurityTokenGeneratorTest.java | 1 + .../push/SpringSecurityAtmosphereInterceptorTest.java | 6 ++++++ .../eclipse/hawkbit/ui/utils/NamingThreadFactoryTest.java | 2 +- .../hawkbit/ui/utils/SPUIComponentProviderTest.java | 7 +++++-- 7 files changed, 16 insertions(+), 3 deletions(-) diff --git a/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/eventbus/EventDistributorTest.java b/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/eventbus/EventDistributorTest.java index fb657638e..c1ff54961 100644 --- a/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/eventbus/EventDistributorTest.java +++ b/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/eventbus/EventDistributorTest.java @@ -35,6 +35,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @Features("Unit Tests - Cluster Cache") @Stories("EventDistributor Test") @RunWith(MockitoJUnitRunner.class) +// TODO: create description annotations public class EventDistributorTest { @Mock diff --git a/hawkbit-core/src/test/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessorTest.java b/hawkbit-core/src/test/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessorTest.java index 2925ba878..548bf7e7e 100644 --- a/hawkbit-core/src/test/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessorTest.java +++ b/hawkbit-core/src/test/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessorTest.java @@ -27,6 +27,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @Features("Unit Tests - Cluster Event Bus") @Stories("EventBus Subscriber Processor Test") @RunWith(MockitoJUnitRunner.class) +// TODO: create description annotations public class EventBusSubscriberProcessorTest { @Mock diff --git a/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java b/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java index a5b02ffb1..fb961f9b2 100644 --- a/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java +++ b/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java @@ -26,6 +26,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @Features("Unit Tests - Security") @Stories("PreAuthToken Source TrustAuthentication Provider Test") @RunWith(MockitoJUnitRunner.class) +// TODO: create description annotations public class PreAuthTokenSourceTrustAuthenticationProviderTest { private static final String REQUEST_SOURCE_IP = "127.0.0.1"; diff --git a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/security/SecurityTokenGeneratorTest.java b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/security/SecurityTokenGeneratorTest.java index 9228e700c..b83b81df7 100644 --- a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/security/SecurityTokenGeneratorTest.java +++ b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/security/SecurityTokenGeneratorTest.java @@ -20,6 +20,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @Stories("SecurityToken Generator Test") public class SecurityTokenGeneratorTest { + // FIXME: figure what is this all about?? @Test public void test() throws NoSuchAlgorithmException, UnsupportedEncodingException { final SecurityTokenGenerator securityTokenGenerator = new SecurityTokenGenerator(); diff --git a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/push/SpringSecurityAtmosphereInterceptorTest.java b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/push/SpringSecurityAtmosphereInterceptorTest.java index 84b48a004..bcf0dcf72 100644 --- a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/push/SpringSecurityAtmosphereInterceptorTest.java +++ b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/push/SpringSecurityAtmosphereInterceptorTest.java @@ -25,7 +25,13 @@ import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.context.HttpSessionSecurityContextRepository; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Unit Tests - Management UI") +@Stories("Push Security") @RunWith(MockitoJUnitRunner.class) +// TODO: create description annotations public class SpringSecurityAtmosphereInterceptorTest { @Mock diff --git a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactoryTest.java b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactoryTest.java index 1ff1b3d33..d91d4cba2 100644 --- a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactoryTest.java +++ b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactoryTest.java @@ -24,7 +24,7 @@ import org.springframework.context.annotation.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -@Features("Component Tests - UI") +@Features("Unit Tests - Management UI") @Stories("Threads with NamingThreadFactory") @RunWith(MockitoJUnitRunner.class) public class NamingThreadFactoryTest { diff --git a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/SPUIComponentProviderTest.java b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/SPUIComponentProviderTest.java index 1f4798ad5..f818bc15d 100644 --- a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/SPUIComponentProviderTest.java +++ b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/SPUIComponentProviderTest.java @@ -19,12 +19,15 @@ import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Button; import com.vaadin.ui.Label; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + /** * Unit Test block for UI Component provider. Dynamic Factory Testing. * - * - * */ +@Features("Unit Tests - Management UI") +@Stories("UI components") public class SPUIComponentProviderTest { /** * Test case for check button factory. From ecdf38b4f980372a80a89d9d6fe178aceea40adb Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Tue, 23 Feb 2016 22:12:29 +0100 Subject: [PATCH 07/12] Fixed typo --- ...ationTest.java => AmqpControllerAuthenticationTest.java} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/{AmqpControllerAuthentficationTest.java => AmqpControllerAuthenticationTest.java} (98%) diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java similarity index 98% rename from hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java rename to hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java index d44bee337..d6c63b83b 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java @@ -45,11 +45,11 @@ import ru.yandex.qatools.allure.annotations.Stories; /** * - * Test Amqp controller authentfication. + * Test Amqp controller authentication. */ @Features("Component Tests - Device Management Federation API") -@Stories("AmqpController Authentfication Test") -public class AmqpControllerAuthentficationTest { +@Stories("AmqpController Authentication Test") +public class AmqpControllerAuthenticationTest { private static final String TENANT = "DEFAULT"; private static String CONTROLLLER_ID = "123"; From 623c980b7b3217cf5580248c2ba3384be5f4ed40 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 24 Feb 2016 08:31:05 +0100 Subject: [PATCH 08/12] Completed feature stories annotations --- .../hawkbit/rest/resource/model/ExceptionInfoTest.java | 2 +- .../hawkbit/ExcludePathAwareShallowETagFilterTest.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java index a1df7f298..a74d89179 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java @@ -19,7 +19,7 @@ import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -@Features("Junit Tests - Management API") +@Features("Unit Tests - Management API") @Stories("Error Handling") public class ExceptionInfoTest { diff --git a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilterTest.java b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilterTest.java index ce663fbfb..c5830f016 100644 --- a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilterTest.java +++ b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilterTest.java @@ -28,6 +28,11 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Unit Tests - Security") +@Stories("Exclude path aware shallow ETag filter") @RunWith(MockitoJUnitRunner.class) public class ExcludePathAwareShallowETagFilterTest { From c99ad7c59625bd0051cc8ffe4e8015ad4496c56b Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 24 Feb 2016 08:31:20 +0100 Subject: [PATCH 09/12] Upgrade Allure --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index aa188e76a..0613e30f0 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ 1.4 2.0M10 1.8 - 1.4.15 + 1.4.22 2.6.0 1.5.4 1.0.2 From e1a48c9b7d9b3e7054c9eca76aba197ea72fe42a Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 24 Feb 2016 10:20:33 +0100 Subject: [PATCH 10/12] Documented usage of annotations --- CONTRUBUTING.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/CONTRUBUTING.md b/CONTRUBUTING.md index bc04d2abd..516c63a68 100644 --- a/CONTRUBUTING.md +++ b/CONTRUBUTING.md @@ -4,7 +4,9 @@ Please read this if you intend to contribute to the project. -## Code Conventions +## Conventions + +### Code Style * Java files: * we follow the standard eclipse IDE (built in) code formatter with the following changes: @@ -19,6 +21,32 @@ Please read this if you intend to contribute to the project. * Sonarqube: * Our rule set is defined [here](http://sonar.eu-gb.mybluemix.net) +### Test documentation + +Please documented the test cases that you contribute by means of [Allure](http://allure.qatools.ru) annotations and proper test method naming. + +All test classes are documented with [Allure's](https://github.com/allure-framework/allure-core/wiki/Features-and-Stories) **@Features** and **@Stories** annotations in the following format: +``` +@Features("TEST_TYPE - HAWKBIT_COMPONENT") +@Stories("Test class description") +``` + +Test types are: +* Unit Tests - for single units tests with a mocked environment +* Component Tests - for complete components including lower layers, e.g. Spring MVC test on rest API including repository and database. +* Integration Tests - including clients, e.g. Selenium UI tests with various browsers. +* System Tests - on target environments, e.g. Cloud Foundry. + +Examples for hawkBit components: +* Management API +* Direct Device Integration API +* Device Management Federation API +* Management UI +* Repository +* Security + +In addition all test method's name describes in **camel case** what the test is all about and has a long description aith Allures **@Description** annotation. + ## Legal considerations for your contribution The following steps are necessary to comply with the Eclipse Foundation's IP policy. From 5248e70db9c652f5813460ecf5cf35f4231dfe45 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 24 Feb 2016 10:21:35 +0100 Subject: [PATCH 11/12] Added example --- CONTRUBUTING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CONTRUBUTING.md b/CONTRUBUTING.md index 516c63a68..626e7f0f1 100644 --- a/CONTRUBUTING.md +++ b/CONTRUBUTING.md @@ -45,6 +45,11 @@ Examples for hawkBit components: * Repository * Security +``` +@Features("Component Tests - Management API") +@Stories("Distribution Set Type Resource") +``` + In addition all test method's name describes in **camel case** what the test is all about and has a long description aith Allures **@Description** annotation. ## Legal considerations for your contribution From f17f58f78a907979f467ac8a2973a639fb60af83 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Thu, 3 Mar 2016 21:24:39 +0100 Subject: [PATCH 12/12] Fixed typo. --- .../org/eclipse/hawkbit/rest/resource/model/PagedListTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java index b4a11412c..49e13c0b4 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java @@ -19,7 +19,7 @@ import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -@Features("Junit Tests - Management API") +@Features("Unit Tests - Management API") @Stories("Paged List Handling") public class PagedListTest {