Merge branch 'master' into
feature_MECS-86_tenant_specific_polling_configuration Conflicts: hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/TenantConfigurationKey.java hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentfication.java hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java hawkbit-repository/src/test/resources/application-test.properties Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -17,8 +17,8 @@ import org.eclipse.hawkbit.cache.TenantAwareCacheManager;
|
||||
import org.eclipse.hawkbit.repository.model.helper.EventBusHolder;
|
||||
import org.eclipse.hawkbit.repository.utils.RepositoryDataGenerator;
|
||||
import org.eclipse.hawkbit.repository.utils.RepositoryDataGenerator.DatabaseCleanupUtil;
|
||||
import org.eclipse.hawkbit.security.DdiSecurityProperties;
|
||||
import org.eclipse.hawkbit.security.SecurityContextTenantAware;
|
||||
import org.eclipse.hawkbit.security.SecurityProperties;
|
||||
import org.eclipse.hawkbit.security.SpringSecurityAuditorAware;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||
@@ -47,7 +47,7 @@ import com.mongodb.MongoClientOptions;
|
||||
*/
|
||||
@Configuration
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true, mode = AdviceMode.ASPECTJ, proxyTargetClass = true, securedEnabled = true)
|
||||
@EnableConfigurationProperties({ SecurityProperties.class, ControllerPollProperties.class })
|
||||
@EnableConfigurationProperties({ DdiSecurityProperties.class, ControllerPollProperties.class })
|
||||
@Profile("test")
|
||||
public class TestConfiguration implements AsyncConfigurer {
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -70,8 +70,8 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
assertThat(actionStatusRepository.findAll(pageReq).getNumberOfElements()).isEqualTo(3);
|
||||
assertThat(deploymentManagement.findActionStatusMessagesByActionInDescOrder(pageReq, savedAction, false)
|
||||
.getNumberOfElements()).isEqualTo(3);
|
||||
assertThat(deploymentManagement.findActionStatusByAction(pageReq, savedAction, false).getNumberOfElements())
|
||||
.isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -50,7 +50,6 @@ import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Issue;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
/**
|
||||
@@ -145,7 +144,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,
|
||||
@@ -766,12 +764,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).getOptLockRevision());
|
||||
|
||||
// verifying that the assignment is correct
|
||||
assertEquals(1, deploymentManagement.findActiveActionsByTarget(targ).size());
|
||||
assertEquals(1, deploymentManagement.findActionsByTarget(targ).size());
|
||||
assertEquals(TargetUpdateStatus.PENDING, targ.getTargetInfo().getUpdateStatus());
|
||||
assertEquals(dsA, targ.getAssignedDistributionSet());
|
||||
assertEquals(dsA, deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet());
|
||||
assertNull(targ.getTargetInfo().getInstalledDistributionSet());
|
||||
assertEquals("Active target actions are wrong", 1, deploymentManagement.findActiveActionsByTarget(targ).size());
|
||||
assertEquals("Target actions are wrong", 1, deploymentManagement.findActionsByTarget(targ).size());
|
||||
assertEquals("Target status is wrong", TargetUpdateStatus.PENDING, targ.getTargetInfo().getUpdateStatus());
|
||||
assertEquals("Assigned ds is wrong", dsA, targ.getAssignedDistributionSet());
|
||||
assertEquals("Active ds is wrong", dsA,
|
||||
deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet());
|
||||
assertNull("Installed ds should be null", targ.getTargetInfo().getInstalledDistributionSet());
|
||||
|
||||
final Page<Action> updAct = actionRepository.findByDistributionSet(pageReq, dsA);
|
||||
final Action action = updAct.getContent().get(0);
|
||||
@@ -781,29 +780,28 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
targ = targetManagement.findTargetByControllerID(targ.getControllerId());
|
||||
|
||||
assertEquals(0, deploymentManagement.findActiveActionsByTarget(targ).size());
|
||||
// try {
|
||||
assertEquals(1, deploymentManagement.findInActiveActionsByTarget(targ).size());
|
||||
// }
|
||||
// catch( final LazyInitializationException ex ) {
|
||||
//
|
||||
// }
|
||||
assertEquals(TargetUpdateStatus.IN_SYNC, targ.getTargetInfo().getUpdateStatus());
|
||||
assertEquals(dsA, targ.getAssignedDistributionSet());
|
||||
assertEquals(dsA, targ.getTargetInfo().getInstalledDistributionSet());
|
||||
assertEquals("active target actions are wrong", 0, deploymentManagement.findActiveActionsByTarget(targ).size());
|
||||
assertEquals("active actions are wrong", 1, deploymentManagement.findInActiveActionsByTarget(targ).size());
|
||||
|
||||
assertEquals("tagret update status is not correct", TargetUpdateStatus.IN_SYNC,
|
||||
targ.getTargetInfo().getUpdateStatus());
|
||||
assertEquals("wrong assigned ds", dsA, targ.getAssignedDistributionSet());
|
||||
assertEquals("wrong installed ds", dsA, targ.getTargetInfo().getInstalledDistributionSet());
|
||||
|
||||
targs = deploymentManagement.assignDistributionSet(dsB.getId(), new String[] { "target-id-A" })
|
||||
.getAssignedTargets();
|
||||
|
||||
targ = targs.iterator().next();
|
||||
|
||||
assertEquals(1, deploymentManagement.findActiveActionsByTarget(targ).size());
|
||||
assertEquals(TargetUpdateStatus.PENDING,
|
||||
assertEquals("active actions are wrong", 1, deploymentManagement.findActiveActionsByTarget(targ).size());
|
||||
assertEquals("target status is wrong", TargetUpdateStatus.PENDING,
|
||||
targetManagement.findTargetByControllerID(targ.getControllerId()).getTargetInfo().getUpdateStatus());
|
||||
assertEquals(dsB, targ.getAssignedDistributionSet());
|
||||
assertEquals(dsA.getId(), targetManagement.findTargetByControllerIDWithDetails(targ.getControllerId())
|
||||
.getTargetInfo().getInstalledDistributionSet().getId());
|
||||
assertEquals(dsB, deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet());
|
||||
assertEquals("wrong assigned ds", dsB, targ.getAssignedDistributionSet());
|
||||
assertEquals("Installed ds is wrong", dsA.getId(),
|
||||
targetManagement.findTargetByControllerIDWithDetails(targ.getControllerId()).getTargetInfo()
|
||||
.getInstalledDistributionSet().getId());
|
||||
assertEquals("Active ds is wrong", dsB,
|
||||
deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,6 +23,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -34,18 +36,19 @@ 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);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
assertThat(targetTagRepository.findAll()).as("Not tags should be available").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Full DS tag lifecycle tested. Create tags, assign them to sets and delete the tags.")
|
||||
public void createAndAssignAndDeleteDistributionSetTags() {
|
||||
@@ -92,7 +95,7 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
||||
// search for not deleted
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Lists.newArrayList(tagA.getName()));
|
||||
assertEquals(
|
||||
assertEquals("filter works not correct",
|
||||
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||
@@ -100,7 +103,7 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Lists.newArrayList(tagB.getName()));
|
||||
assertEquals(
|
||||
assertEquals("filter works not correct",
|
||||
dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||
@@ -108,7 +111,7 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Lists.newArrayList(tagC.getName()));
|
||||
assertEquals(
|
||||
assertEquals("filter works not correct",
|
||||
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||
@@ -116,22 +119,22 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Lists.newArrayList(tagX.getName()));
|
||||
assertEquals(0, distributionSetManagement
|
||||
assertEquals("filter works not correct", 0, distributionSetManagement
|
||||
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
|
||||
assertEquals(5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
assertEquals("wrong tag size", 5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
|
||||
tagManagement.deleteDistributionSetTag(tagY.getName());
|
||||
assertEquals(4, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
assertEquals("wrong tag size", 4, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
tagManagement.deleteDistributionSetTag(tagX.getName());
|
||||
assertEquals(3, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
assertEquals("wrong tag size", 3, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
|
||||
tagManagement.deleteDistributionSetTag(tagB.getName());
|
||||
assertEquals(2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
assertEquals("wrong tag size", 2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setTagNames(Lists.newArrayList(tagA.getName()));
|
||||
assertEquals(
|
||||
assertEquals("filter works not correct",
|
||||
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||
@@ -139,12 +142,12 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setTagNames(Lists.newArrayList(tagB.getName()));
|
||||
assertEquals(0, distributionSetManagement
|
||||
assertEquals("filter works not correct", 0, distributionSetManagement
|
||||
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setTagNames(Lists.newArrayList(tagC.getName()));
|
||||
assertEquals(
|
||||
assertEquals("filter works not correct",
|
||||
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||
@@ -155,45 +158,28 @@ 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() {
|
||||
assertThat(targetTagRepository.findAll()).isEmpty();
|
||||
|
||||
@Description("Ensures that all tags are retrieved through repository.")
|
||||
public void findAllTargetTags() {
|
||||
final List<TargetTag> tags = createTargetsWithTags();
|
||||
|
||||
assertThat(targetTagRepository.findAll()).isEqualTo(tagManagement.findAllTargetTags()).isEqualTo(tags)
|
||||
.hasSize(20);
|
||||
.as("Wrong tag size").hasSize(20);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.eclipse.hawkbit.repository.TagManagement#createTargetTag(org.eclipse.hawkbit.repository.model.TargetTag)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testCreateTargetTag() {
|
||||
assertThat(targetTagRepository.findAll()).isEmpty();
|
||||
|
||||
@Description("Ensures that a created tag is persisted in the repository as defined.")
|
||||
public void createTargetTag() {
|
||||
final Tag tag = tagManagement.createTargetTag(new TargetTag("kai1", "kai2", "colour"));
|
||||
|
||||
assertThat(targetTagRepository.findByNameEquals("kai1").getDescription()).isEqualTo("kai2");
|
||||
assertThat(tagManagement.findTargetTag("kai1").getColour()).isEqualTo("colour");
|
||||
assertThat(tagManagement.findTargetTagById(tag.getId()).getColour()).isEqualTo("colour");
|
||||
assertThat(targetTagRepository.findByNameEquals("kai1").getDescription()).as("wrong tag ed").isEqualTo("kai2");
|
||||
assertThat(tagManagement.findTargetTag("kai1").getColour()).as("wrong tag found").isEqualTo("colour");
|
||||
assertThat(tagManagement.findTargetTagById(tag.getId()).getColour()).as("wrong tag found").isEqualTo("colour");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.eclipse.hawkbit.repository.TagManagement#deleteTargetTag(java.lang.String[])}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testDeleteTargetTagsStringArray() {
|
||||
assertThat(targetTagRepository.findAll()).isEmpty();
|
||||
@Description("Ensures that a deleted tag is removed from the repository as defined.")
|
||||
public void deleteTargetTas() {
|
||||
|
||||
// create test data
|
||||
final Iterable<TargetTag> tags = createTargetsWithTags();
|
||||
@@ -212,16 +198,13 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
||||
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getTags())
|
||||
.doesNotContain(toDelete);
|
||||
}
|
||||
assertThat(targetTagRepository.findOne(toDelete.getId())).isNull();
|
||||
assertThat(tagManagement.findAllTargetTags()).hasSize(19);
|
||||
assertThat(targetTagRepository.findOne(toDelete.getId())).as("No tag should be found").isNull();
|
||||
assertThat(tagManagement.findAllTargetTags()).as("Wrong target tag size").hasSize(19);
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
// create test data
|
||||
final List<TargetTag> tags = createTargetsWithTags();
|
||||
|
||||
// change data
|
||||
@@ -232,91 +215,104 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
||||
tagManagement.updateTargetTag(savedAssigned);
|
||||
|
||||
// check data
|
||||
assertThat(tagManagement.findAllTargetTags()).hasSize(tags.size());
|
||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getName()).isEqualTo("test123");
|
||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getOptLockRevision()).isEqualTo(2);
|
||||
assertThat(tagManagement.findAllTargetTags()).as("Wrong target tag size").hasSize(tags.size());
|
||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getName()).as("wrong target tag is saved")
|
||||
.isEqualTo("test123");
|
||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getOptLockRevision())
|
||||
.as("wrong target tag is saved").isEqualTo(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.eclipse.hawkbit.repository.TagManagement#createDistributionSetTag(org.eclipse.hawkbit.repository.model.DistributionSetTag)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testCreateDistributionSetTag() {
|
||||
assertThat(distributionSetTagRepository.findAll()).isEmpty();
|
||||
|
||||
@Description("Ensures that a created tag is persisted in the repository as defined.")
|
||||
public void createDistributionSetTag() {
|
||||
final Tag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("kai1", "kai2", "colour"));
|
||||
|
||||
assertThat(distributionSetTagRepository.findByNameEquals("kai1").getDescription()).isEqualTo("kai2");
|
||||
assertThat(tagManagement.findDistributionSetTag("kai1").getColour()).isEqualTo("colour");
|
||||
assertThat(tagManagement.findDistributionSetTagById(tag.getId()).getColour()).isEqualTo("colour");
|
||||
assertThat(distributionSetTagRepository.findByNameEquals("kai1").getDescription()).as("wrong tag found")
|
||||
.isEqualTo("kai2");
|
||||
assertThat(tagManagement.findDistributionSetTag("kai1").getColour()).as("wrong tag found").isEqualTo("colour");
|
||||
assertThat(tagManagement.findDistributionSetTagById(tag.getId()).getColour()).as("wrong tag found")
|
||||
.isEqualTo("colour");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.eclipse.hawkbit.repository.TagManagement#createDistributionSetTags(java.lang.Iterable)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testCreateDistributionSetTags() {
|
||||
assertThat(distributionSetTagRepository.findAll()).isEmpty();
|
||||
|
||||
@Description("Ensures that a created tags are persisted in the repository as defined.")
|
||||
public void createDistributionSetTags() {
|
||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
|
||||
assertThat(distributionSetTagRepository.findAll()).hasSize(tags.size());
|
||||
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags created").hasSize(tags.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.eclipse.hawkbit.repository.TagManagement#deleteDistributionSetTag(java.lang.String[])}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testDeleteDistributionSetTag() {
|
||||
assertThat(distributionSetTagRepository.findAll()).isEmpty();
|
||||
|
||||
@Description("Ensures that a deleted tag is removed from the repository as defined.")
|
||||
public void deleteDistributionSetTag() {
|
||||
// create test data
|
||||
final Iterable<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
final DistributionSetTag toDelete = tags.iterator().next();
|
||||
|
||||
for (final DistributionSet set : distributionSetRepository.findAll()) {
|
||||
assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags())
|
||||
.contains(toDelete);
|
||||
.as("Wrong tag found").contains(toDelete);
|
||||
}
|
||||
|
||||
// delete
|
||||
tagManagement.deleteDistributionSetTag(tags.iterator().next().getName());
|
||||
|
||||
// check
|
||||
assertThat(distributionSetTagRepository.findOne(toDelete.getId())).isNull();
|
||||
assertThat(tagManagement.findAllDistributionSetTags()).hasSize(19);
|
||||
assertThat(distributionSetTagRepository.findOne(toDelete.getId())).as("Deleted tag should be null").isNull();
|
||||
assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of tags after deletion").hasSize(19);
|
||||
for (final DistributionSet set : distributionSetRepository.findAll()) {
|
||||
assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags())
|
||||
.doesNotContain(toDelete);
|
||||
.as("Wrong found tags").doesNotContain(toDelete);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = EntityAlreadyExistsException.class)
|
||||
public void testFailedDuplicateTargetTagNameException() {
|
||||
tagManagement.createTargetTag(new TargetTag("A"));
|
||||
@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"));
|
||||
try {
|
||||
tagManagement.createTargetTag(new TargetTag("A"));
|
||||
fail("Expected EntityAlreadyExistsException");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = EntityAlreadyExistsException.class)
|
||||
public void testFailedDuplicateDsTagNameException() {
|
||||
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
|
||||
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
|
||||
@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");
|
||||
try {
|
||||
tagManagement.updateTargetTag(tag);
|
||||
fail("Expected EntityAlreadyExistsException");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@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"));
|
||||
try {
|
||||
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
|
||||
fail("Expected EntityAlreadyExistsException");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@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");
|
||||
try {
|
||||
tagManagement.updateDistributionSetTag(tag);
|
||||
fail("Expected EntityAlreadyExistsException");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.eclipse.hawkbit.repository.TagManagement#updateDistributionSetTag(org.eclipse.hawkbit.repository.model.DistributionSetTag)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testUpdateDistributionSetTag() {
|
||||
assertThat(distributionSetTagRepository.findAll()).isEmpty();
|
||||
@Description("Tests the name update of a target tag.")
|
||||
public void updateDistributionSetTag() {
|
||||
|
||||
// create test data
|
||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
@@ -329,24 +325,19 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
||||
tagManagement.updateDistributionSetTag(savedAssigned);
|
||||
|
||||
// check data
|
||||
assertThat(tagManagement.findAllDistributionSetTags()).hasSize(tags.size());
|
||||
assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).isEqualTo("test123");
|
||||
assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of ds tags").hasSize(tags.size());
|
||||
assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).as("Wrong ds tag found")
|
||||
.isEqualTo("test123");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.eclipse.hawkbit.repository.TagManagement#findAllDistributionSetTags()}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testFindDistributionSetTagsAll() {
|
||||
assertThat(distributionSetTagRepository.findAll()).isEmpty();
|
||||
|
||||
@Description("Ensures that all tags are retrieved through repository.")
|
||||
public void findDistributionSetTagsAll() {
|
||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
|
||||
// test
|
||||
assertThat(tagManagement.findAllDistributionSetTags()).hasSize(tags.size());
|
||||
assertThat(distributionSetTagRepository.findAll()).hasSize(20);
|
||||
assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of tags").hasSize(tags.size());
|
||||
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags").hasSize(20);
|
||||
}
|
||||
|
||||
private List<TargetTag> createTargetsWithTags() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -96,24 +96,26 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
final TargetTag targetTag = tagManagement.createTargetTag(new TargetTag("Tag1"));
|
||||
|
||||
final List<Target> assignedTargets = targetManagement.assignTag(assignTarget, targetTag);
|
||||
assertThat(assignedTargets.size()).isEqualTo(4);
|
||||
assertThat(assignedTargets.size()).as("Assigned targets are wrong").isEqualTo(4);
|
||||
assignedTargets.forEach(target -> assertThat(target.getTags().size()).isEqualTo(1));
|
||||
|
||||
TargetTag findTargetTag = tagManagement.findTargetTag("Tag1");
|
||||
assertThat(assignedTargets.size()).isEqualTo(findTargetTag.getAssignedToTargets().size());
|
||||
assertThat(assignedTargets.size()).as("Assigned targets are wrong")
|
||||
.isEqualTo(findTargetTag.getAssignedToTargets().size());
|
||||
|
||||
assertThat(targetManagement.unAssignTag("NotExist", findTargetTag)).isNull();
|
||||
assertThat(targetManagement.unAssignTag("NotExist", findTargetTag)).as("Unassign target does not work")
|
||||
.isNull();
|
||||
|
||||
final Target unAssignTarget = targetManagement.unAssignTag("targetId123", findTargetTag);
|
||||
assertThat(unAssignTarget.getControllerId()).isEqualTo("targetId123");
|
||||
assertThat(unAssignTarget.getTags().size()).isEqualTo(0);
|
||||
assertThat(unAssignTarget.getControllerId()).as("Controller id is wrong").isEqualTo("targetId123");
|
||||
assertThat(unAssignTarget.getTags()).as("Tag size is wrong").isEmpty();
|
||||
findTargetTag = tagManagement.findTargetTag("Tag1");
|
||||
assertThat(findTargetTag.getAssignedToTargets().size()).isEqualTo(3);
|
||||
assertThat(findTargetTag.getAssignedToTargets()).as("Assigned targets are wrong").hasSize(3);
|
||||
|
||||
final List<Target> unAssignTargets = targetManagement.unAssignAllTargetsByTag(findTargetTag);
|
||||
findTargetTag = tagManagement.findTargetTag("Tag1");
|
||||
assertThat(findTargetTag.getAssignedToTargets().size()).isEqualTo(0);
|
||||
assertThat(unAssignTargets.size()).isEqualTo(3);
|
||||
assertThat(findTargetTag.getAssignedToTargets()).as("Unassigned targets are wrong").isEmpty();
|
||||
assertThat(unAssignTargets).as("Unassigned targets are wrong").hasSize(3);
|
||||
unAssignTargets.forEach(target -> assertThat(target.getTags().size()).isEqualTo(0));
|
||||
}
|
||||
|
||||
@@ -121,14 +123,14 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
@Description("Ensures that targets can deleted e.g. test all cascades")
|
||||
public void deleteAndCreateTargets() {
|
||||
Target target = targetManagement.createTarget(new Target("targetId123"));
|
||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(1);
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(1);
|
||||
targetManagement.deleteTargets(target.getId());
|
||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
|
||||
|
||||
target = createTargetWithAttributes("4711");
|
||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(1);
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(1);
|
||||
targetManagement.deleteTargets(target.getId());
|
||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
|
||||
|
||||
final List<Long> targets = new ArrayList<Long>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@@ -136,9 +138,9 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
targets.add(target.getId());
|
||||
targets.add(createTargetWithAttributes("" + (i * i + 1000)).getId());
|
||||
}
|
||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(10);
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(10);
|
||||
targetManagement.deleteTargets(targets.toArray(new Long[targets.size()]));
|
||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
|
||||
}
|
||||
|
||||
private Target createTargetWithAttributes(final String controllerId) {
|
||||
@@ -150,7 +152,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
target = controllerManagament.updateControllerAttributes(controllerId, testData);
|
||||
|
||||
target = targetManagement.findTargetByControllerIDWithDetails(controllerId);
|
||||
assertThat(target.getTargetInfo().getControllerAttributes()).isEqualTo(testData);
|
||||
assertThat(target.getTargetInfo().getControllerAttributes()).as("Controller Attributes are wrong")
|
||||
.isEqualTo(testData);
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -162,10 +165,14 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
final DistributionSet set2 = TestDataUtil.generateDistributionSet("test2", softwareManagement,
|
||||
distributionSetManagement);
|
||||
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set.getId())).isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set.getId())).isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set2.getId())).isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set2.getId())).isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
|
||||
Target target = createTargetWithAttributes("4711");
|
||||
|
||||
@@ -183,13 +190,19 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
target = targetManagement.findTargetByControllerIDWithDetails("4711");
|
||||
// read data
|
||||
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set.getId())).isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set.getId())).isEqualTo(1);
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set2.getId())).isEqualTo(1);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set2.getId())).isEqualTo(0);
|
||||
assertThat(target.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
||||
assertThat(target.getAssignedDistributionSet()).isEqualTo(set2);
|
||||
assertThat(target.getTargetInfo().getInstalledDistributionSet().getId()).isEqualTo(set.getId());
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set.getId())).as("Target count is wrong")
|
||||
.isEqualTo(1);
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
.isEqualTo(1);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(target.getTargetInfo().getLastTargetQuery()).as("Target query is not work")
|
||||
.isGreaterThanOrEqualTo(current);
|
||||
assertThat(target.getAssignedDistributionSet()).as("Assigned ds size is wrong").isEqualTo(set2);
|
||||
assertThat(target.getTargetInfo().getInstalledDistributionSet().getId()).as("Installed ds is wrong")
|
||||
.isEqualTo(set.getId());
|
||||
|
||||
}
|
||||
|
||||
@@ -373,8 +386,7 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
assertThat(firstSaved.spliterator().getExactSizeIfKnown() - nr2Del).as("Size of splited list")
|
||||
.isEqualTo(allFound.spliterator().getExactSizeIfKnown());
|
||||
|
||||
// verify that all undeleted are still found
|
||||
assertThat(allFound).doesNotContain(deletedTargets);
|
||||
assertThat(allFound).as("Not all undeleted found").doesNotContain(deletedTargets);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -404,7 +416,7 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
targetInfo = targetInfoRepository.save(targetInfo);
|
||||
}
|
||||
final Query qry = entityManager.createNativeQuery("select * from sp_target_attributes ta");
|
||||
final List result = qry.getResultList();
|
||||
final List<?> result = qry.getResultList();
|
||||
|
||||
assertThat(attribs.size() * ts.spliterator().getExactSizeIfKnown()).as("Amount of all target attributes")
|
||||
.isEqualTo(result.size());
|
||||
@@ -467,7 +479,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
final Target tNoAttrib = targetManagement.findTargetByControllerID(tNoAttribl.getControllerId());
|
||||
|
||||
if (tNoAttrib.getControllerId().equals(target.getControllerId())) {
|
||||
assertThat(target.getTargetInfo().getControllerAttributes()).isEmpty();
|
||||
assertThat(target.getTargetInfo().getControllerAttributes())
|
||||
.as("Controller attributes should be empty").isEmpty();
|
||||
continue restTarget_;
|
||||
}
|
||||
}
|
||||
@@ -479,7 +492,7 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
if (tNoAttrib.getControllerId().equals(target.getControllerId())) {
|
||||
assertThat(target.getTargetInfo().getControllerAttributes().keySet().toArray())
|
||||
.doesNotContain(attribs2Del.toArray());
|
||||
.as("Controller attributes are wrong").doesNotContain(attribs2Del.toArray());
|
||||
continue restTarget_;
|
||||
}
|
||||
}
|
||||
@@ -504,12 +517,14 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
t2 = targetManagement.createTarget(t2);
|
||||
|
||||
t1 = targetManagement.findTargetByControllerID(t1.getControllerId());
|
||||
assertThat(t1.getTags()).hasSize(noT1Tags).containsAll(t1Tags);
|
||||
assertThat(t1.getTags()).hasSize(noT1Tags).doesNotContain(Iterables.toArray(t2Tags, TargetTag.class));
|
||||
assertThat(t1.getTags()).as("Tag size is wrong").hasSize(noT1Tags).containsAll(t1Tags);
|
||||
assertThat(t1.getTags()).as("Tag size is wrong").hasSize(noT1Tags)
|
||||
.doesNotContain(Iterables.toArray(t2Tags, TargetTag.class));
|
||||
|
||||
t2 = targetManagement.findTargetByControllerID(t2.getControllerId());
|
||||
assertThat(t2.getTags()).hasSize(noT2Tags).containsAll(t2Tags);
|
||||
assertThat(t2.getTags()).hasSize(noT2Tags).doesNotContain(Iterables.toArray(t1Tags, TargetTag.class));
|
||||
assertThat(t2.getTags()).as("Tag size is wrong").hasSize(noT2Tags).containsAll(t2Tags);
|
||||
assertThat(t2.getTags()).as("Tag size is wrong").hasSize(noT2Tags)
|
||||
.doesNotContain(Iterables.toArray(t1Tags, TargetTag.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -531,7 +546,7 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
final TargetTag tagA = tagManagement.createTargetTag(new TargetTag("A"));
|
||||
final TargetTag tagB = tagManagement.createTargetTag(new TargetTag("B"));
|
||||
final TargetTag tagC = tagManagement.createTargetTag(new TargetTag("C"));
|
||||
final TargetTag tagX = tagManagement.createTargetTag(new TargetTag("X"));
|
||||
tagManagement.createTargetTag(new TargetTag("X"));
|
||||
|
||||
// doing different assignments
|
||||
targetManagement.toggleTagAssignment(tagATargets, tagA);
|
||||
@@ -545,7 +560,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
targetManagement.toggleTagAssignment(tagABCTargets, tagB);
|
||||
targetManagement.toggleTagAssignment(tagABCTargets, tagC);
|
||||
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "X")).isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "X"))
|
||||
.as("Target count is wrong").isEqualTo(0);
|
||||
|
||||
// search for targets with tag tagA
|
||||
final List<Target> targetWithTagA = new ArrayList<Target>();
|
||||
@@ -575,11 +591,11 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
|
||||
// check again target lists refreshed from DB
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "A"))
|
||||
.isEqualTo(targetWithTagA.size());
|
||||
.as("Target count is wrong").isEqualTo(targetWithTagA.size());
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "B"))
|
||||
.isEqualTo(targetWithTagB.size());
|
||||
.as("Target count is wrong").isEqualTo(targetWithTagB.size());
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "C"))
|
||||
.isEqualTo(targetWithTagC.size());
|
||||
.as("Target count is wrong").isEqualTo(targetWithTagC.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -656,14 +672,15 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
targetManagement.toggleTagAssignment(targAs, targTagA);
|
||||
|
||||
assertThat(targetManagement.findTargetsByControllerIDsWithTags(
|
||||
targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList()))).hasSize(25);
|
||||
targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList())))
|
||||
.as("Target count is wrong").hasSize(25);
|
||||
|
||||
// no lazy loading exception and tag correctly assigned
|
||||
assertThat(targetManagement
|
||||
.findTargetsByControllerIDsWithTags(
|
||||
targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList()))
|
||||
.stream().map(target -> target.getTags().contains(targTagA)).collect(Collectors.toList()))
|
||||
.containsOnly(true);
|
||||
.as("Tags not correctly assigned").containsOnly(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -678,7 +695,7 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
||||
final List<String> findAllTargetIds = findAllTargetIdNames.stream().map(TargetIdName::getControllerId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
assertThat(findAllTargetIds).containsOnly(createdTargetIds);
|
||||
assertThat(findAllTargetIds).as("Target list has wrong content").containsOnly(createdTargetIds);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -98,7 +98,7 @@ public class RSQLDistributionSetFieldTest extends AbstractIntegrationTest {
|
||||
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "==true", 4);
|
||||
try {
|
||||
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "==noExist*", 0);
|
||||
fail();
|
||||
fail("Expected RSQLParameterSyntaxException");
|
||||
} catch (final RSQLParameterSyntaxException e) {
|
||||
}
|
||||
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "=in=(true)", 4);
|
||||
@@ -140,7 +140,7 @@ public class RSQLDistributionSetFieldTest extends AbstractIntegrationTest {
|
||||
final Page<DistributionSet> find = distributionSetManagement.findDistributionSetsAll(
|
||||
RSQLUtility.parse(rsqlParam, DistributionSetFields.class), new PageRequest(0, 100), false);
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).isNotNull();
|
||||
assertThat(countAll).isEqualTo(excpectedEntity);
|
||||
assertThat(find).as("Founded entity is should not be null").isNotNull();
|
||||
assertThat(countAll).as("Founded entity size is wrong").isEqualTo(excpectedEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<String>() {
|
||||
@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<Target>() {
|
||||
@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<Target> findTargetsForTenant(final String tenant) throws Exception {
|
||||
return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant),
|
||||
new Callable<Slice<Target>>() {
|
||||
@Override
|
||||
public Slice<Target> 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<Void>() {
|
||||
@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<DistributionSet>() {
|
||||
@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<DistributionSet> findDistributionSetForTenant(final String tenant) throws Exception {
|
||||
return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant),
|
||||
new Callable<Page<DistributionSet>>() {
|
||||
@Override
|
||||
public Page<DistributionSet> call() throws Exception {
|
||||
return distributionSetManagement.findDistributionSetsAll(pageReq, false, false);
|
||||
}
|
||||
});
|
||||
() -> distributionSetManagement.findDistributionSetsAll(pageReq, false, false));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
spring.data.mongodb.uri=mongodb://localhost/spArtifactRepository${random.value}
|
||||
spring.data.mongodb.port=28017
|
||||
|
||||
hawkbit.server.controller.security.authentication.header.enabled=true
|
||||
hawkbit.server.controller.security.authentication.gatewaytoken.name=TestToken
|
||||
hawkbit.server.ddi.security.authentication.header.enabled=true
|
||||
hawkbit.server.ddi.security.authentication.gatewaytoken.name=TestToken
|
||||
|
||||
hawkbit.server.artifact.repo.upload.maxFileSize=5MB
|
||||
|
||||
@@ -30,11 +30,6 @@ flyway.initOnMigrate=true
|
||||
flyway.sqlMigrationSuffix=${spring.jpa.database}.sql
|
||||
#spring.jpa.show-sql=true
|
||||
|
||||
# SP Controller configuration
|
||||
# DDI configuration
|
||||
hawkbit.controller.pollingTime=00:01:00
|
||||
hawkbit.controller.pollingOverdueTime=00:01:00
|
||||
|
||||
## Configuration for RabbitMQ integration
|
||||
hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter
|
||||
hawkbit.dmf.rabbitmq.deadLetterExchange=dmf.connector.deadletter
|
||||
hawkbit.dmf.rabbitmq.receiverQueue=dmf_receiver
|
||||
hawkbit.controller.pollingOverdueTime=00:01:00
|
||||
Reference in New Issue
Block a user