diff --git a/CONTRUBUTING.md b/CONTRUBUTING.md index bc04d2abd..626e7f0f1 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,37 @@ 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 + +``` +@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 The following steps are necessary to comply with the Eclipse Foundation's IP policy. 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..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,12 @@ 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; + +@Features("Component Tests - Repository") +@Stories("Artifact Store MongoDB") @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = { ArtifactStoreAutoConfiguration.class, TestConfiguration.class }) public class ArtifactStoreTest { @@ -48,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"; @@ -60,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"; @@ -72,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"; @@ -84,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"; @@ -103,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"; 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..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 @@ -29,7 +29,13 @@ 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) +// TODO: create description annotations public class EventDistributorTest { @Mock 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..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 @@ -21,7 +21,13 @@ 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) +// TODO: create description annotations public class EventBusSubscriberProcessorTest { @Mock 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 571760684..501fddf81 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 @@ -46,11 +46,11 @@ import ru.yandex.qatools.allure.annotations.Stories; /** * - * Test Amqp controller authentfication. + * Test Amqp controller authentication. */ -@Features("AMQP Authenfication Test") -@Stories("Tests the authenfication") -public class AmqpControllerAuthentficationTest { +@Features("Component Tests - Device Management Federation API") +@Stories("AmqpController Authentication Test") +public class AmqpControllerAuthenticationTest { private static final String TENANT = "DEFAULT"; private static String CONTROLLLER_ID = "123"; 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 f8ac2a027..46ddd35cc 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 06e9f19fb..79a39a40a 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..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 @@ -20,7 +20,13 @@ 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) +// TODO: create description annotations public class PreAuthTokenSourceTrustAuthenticationProviderTest { private static final String REQUEST_SOURCE_IP = "127.0.0.1"; 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 ac989e277..e1976c9a6 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/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/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 a3071d756..6427ca8a2 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 @@ -145,7 +145,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-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 139b0a88d..8b20af27d 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 f72c3a968..40d757d15 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 bcfade8d5..356464bc2 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/main/java/org/eclipse/hawkbit/controller/RootController.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java index a8d17e1b3..6928ee7b5 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 @@ -427,8 +427,6 @@ public class RootController { 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/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"; 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..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,11 +46,8 @@ import ru.yandex.qatools.allure.annotations.Stories; /** * Test for {@link DistributionSetTypeResource}. * - * - * - * */ -@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..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,11 +30,7 @@ import org.springframework.context.annotation.Description; import ru.yandex.qatools.allure.annotations.Features; 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..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 @@ -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 { @@ -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; @@ -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/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 3a0cc3e94..cf93fcba7 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 @@ -67,7 +67,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 { @@ -117,14 +117,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/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 1ec4d5d16..a8ebfdd9d 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 @@ -68,16 +68,11 @@ import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; /** - * * Spring MVC Tests against the TargetResource. * - * - * */ -@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 public class TargetResourceTest extends AbstractIntegrationTest { private static final String TARGET_DESCRIPTION_TEST = "created in test"; @@ -105,10 +100,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"; @@ -140,6 +133,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 { @@ -151,6 +145,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 { @@ -163,6 +158,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"; @@ -194,6 +190,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 @@ -226,6 +223,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(); @@ -249,7 +247,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(); @@ -301,6 +300,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)); @@ -313,6 +313,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"; @@ -321,6 +322,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("{}") @@ -329,6 +331,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"; @@ -353,6 +356,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"; @@ -392,6 +396,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; @@ -412,10 +417,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-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 ab5012d73..d240a814b 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("Unit 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 4a88bf43e..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 @@ -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("Unit 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<>(); @@ -39,6 +47,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<>(); 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 d3dc066f1..0b2c0b116 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 { 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..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 @@ -13,8 +13,14 @@ 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 { + // FIXME: figure what is this all about?? @Test public void test() throws NoSuchAlgorithmException, UnsupportedEncodingException { final SecurityTokenGenerator securityTokenGenerator = new SecurityTokenGenerator(); 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 73995259d..9eb83d2a9 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 diff --git a/hawkbit-test-report/pom.xml b/hawkbit-test-report/pom.xml index 6e58cb61a..3e9182f0a 100644 --- a/hawkbit-test-report/pom.xml +++ b/hawkbit-test-report/pom.xml @@ -18,7 +18,7 @@ 0.2.0-SNAPSHOT hawkbit-test-report - Hawkbit :: Test Report + hawkBit :: Test Report pom @@ -75,8 +75,7 @@ - - + \ No newline at end of file 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()); 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. diff --git a/pom.xml b/pom.xml index bf38d3b14..3d70d980c 100644 --- a/pom.xml +++ b/pom.xml @@ -86,7 +86,7 @@ 1.4 2.0M10 - 1.4.15 + 1.4.22 2.6.2 1.5.4 1.0.2