Make entities immutable and create proper update methods that state by signature what can be updated. (#342)
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -22,7 +22,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -30,8 +31,11 @@ import java.util.Set;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.model.*;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.test.util.TestdataFactory;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||
@@ -46,6 +50,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
@@ -72,8 +77,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
// create DisSet
|
||||
final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Eris", "560a");
|
||||
final List<Long> smIDs = new ArrayList<>();
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "Dysnomia ", "15,772", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
smIDs.add(sm.getId());
|
||||
final JSONArray smList = new JSONArray();
|
||||
for (final Long smID : smIDs) {
|
||||
@@ -88,10 +92,10 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String[] knownTargetIds = new String[] { "1", "2" };
|
||||
final JSONArray list = new JSONArray();
|
||||
for (final String targetId : knownTargetIds) {
|
||||
targetManagement.createTarget(entityFactory.generateTarget(targetId));
|
||||
testdataFactory.createTarget(targetId);
|
||||
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
|
||||
}
|
||||
deploymentManagement.assignDistributionSet(disSet.getId(), knownTargetIds[0]);
|
||||
assignDistributionSet(disSet.getId(), knownTargetIds[0]);
|
||||
mvc.perform(
|
||||
post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets")
|
||||
.contentType(MediaType.APPLICATION_JSON).content(list.toString()))
|
||||
@@ -104,8 +108,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
// to the target.
|
||||
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM/"
|
||||
+ smIDs.get(0)).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isLocked())
|
||||
.andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.entitiylocked")));
|
||||
.andExpect(status().isForbidden())
|
||||
.andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.entityreadonly")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -115,8 +119,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
// create DisSet
|
||||
final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Mars", "686,980");
|
||||
final List<Long> smIDs = new ArrayList<>();
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "Phobos", "0,3189", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
smIDs.add(sm.getId());
|
||||
final JSONArray smList = new JSONArray();
|
||||
for (final Long smID : smIDs) {
|
||||
@@ -131,11 +134,11 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String[] knownTargetIds = new String[] { "1", "2" };
|
||||
final JSONArray list = new JSONArray();
|
||||
for (final String targetId : knownTargetIds) {
|
||||
targetManagement.createTarget(entityFactory.generateTarget(targetId));
|
||||
testdataFactory.createTarget(targetId);
|
||||
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
|
||||
}
|
||||
// assign DisSet to target and test assignment
|
||||
deploymentManagement.assignDistributionSet(disSet.getId(), knownTargetIds[0]);
|
||||
assignDistributionSet(disSet.getId(), knownTargetIds[0]);
|
||||
mvc.perform(
|
||||
post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets")
|
||||
.contentType(MediaType.APPLICATION_JSON).content(list.toString()))
|
||||
@@ -145,19 +148,14 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.andExpect(jsonPath("$.total", equalTo(knownTargetIds.length)));
|
||||
|
||||
// Create another SM and post assignment
|
||||
final List<Long> smID2s = new ArrayList<>();
|
||||
SoftwareModule sm2 = entityFactory.generateSoftwareModule(appType, "Deimos", "1,262", null, null);
|
||||
sm2 = softwareManagement.createSoftwareModule(sm2);
|
||||
smID2s.add(sm2.getId());
|
||||
final SoftwareModule sm2 = testdataFactory.createSoftwareModuleApp();
|
||||
final JSONArray smList2 = new JSONArray();
|
||||
for (final Long smID : smID2s) {
|
||||
smList2.put(new JSONObject().put("id", Long.valueOf(smID)));
|
||||
}
|
||||
smList2.put(new JSONObject().put("id", sm2.getId()));
|
||||
|
||||
mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")
|
||||
.contentType(MediaType.APPLICATION_JSON).content(smList2.toString()))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isLocked())
|
||||
.andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.entitiylocked")));
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden())
|
||||
.andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.entityreadonly")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -171,16 +169,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.size", equalTo(disSet.getModules().size())));
|
||||
// create Software Modules
|
||||
final List<Long> smIDs = new ArrayList<>();
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "Europa", "3,551", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
smIDs.add(sm.getId());
|
||||
SoftwareModule sm2 = entityFactory.generateSoftwareModule(appType, "Ganymed", "7,155", null, null);
|
||||
sm2 = softwareManagement.createSoftwareModule(sm2);
|
||||
smIDs.add(sm2.getId());
|
||||
SoftwareModule sm3 = entityFactory.generateSoftwareModule(runtimeType, "Kallisto", "16,689", null, null);
|
||||
sm3 = softwareManagement.createSoftwareModule(sm3);
|
||||
smIDs.add(sm3.getId());
|
||||
final List<Long> smIDs = Lists.newArrayList(testdataFactory.createSoftwareModuleOs().getId(),
|
||||
testdataFactory.createSoftwareModuleApp().getId());
|
||||
final JSONArray list = new JSONArray();
|
||||
for (final Long smID : smIDs) {
|
||||
list.put(new JSONObject().put("id", Long.valueOf(smID)));
|
||||
@@ -227,11 +217,11 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String[] knownTargetIds = new String[] { "1", "2", "3", "4", "5" };
|
||||
final JSONArray list = new JSONArray();
|
||||
for (final String targetId : knownTargetIds) {
|
||||
targetManagement.createTarget(entityFactory.generateTarget(targetId));
|
||||
testdataFactory.createTarget(targetId);
|
||||
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
|
||||
}
|
||||
// assign already one target to DS
|
||||
deploymentManagement.assignDistributionSet(createdDs.getId(), knownTargetIds[0]);
|
||||
assignDistributionSet(createdDs.getId(), knownTargetIds[0]);
|
||||
|
||||
mvc.perform(post(
|
||||
MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")
|
||||
@@ -251,8 +241,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownTargetId = "knownTargetId1";
|
||||
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
|
||||
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
|
||||
targetManagement.createTarget(entityFactory.generateTarget(knownTargetId));
|
||||
deploymentManagement.assignDistributionSet(createdDs.getId(), knownTargetId);
|
||||
testdataFactory.createTarget(knownTargetId);
|
||||
assignDistributionSet(createdDs.getId(), knownTargetId);
|
||||
|
||||
mvc.perform(get(
|
||||
MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets"))
|
||||
@@ -278,15 +268,15 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownTargetId = "knownTargetId1";
|
||||
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
|
||||
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
|
||||
final Target createTarget = targetManagement.createTarget(entityFactory.generateTarget(knownTargetId));
|
||||
final Target createTarget = testdataFactory.createTarget(knownTargetId);
|
||||
// create some dummy targets which are not assigned or installed
|
||||
targetManagement.createTarget(entityFactory.generateTarget("dummy1"));
|
||||
targetManagement.createTarget(entityFactory.generateTarget("dummy2"));
|
||||
testdataFactory.createTarget("dummy1");
|
||||
testdataFactory.createTarget("dummy2");
|
||||
// assign knownTargetId to distribution set
|
||||
deploymentManagement.assignDistributionSet(createdDs.getId(), knownTargetId);
|
||||
assignDistributionSet(createdDs.getId(), knownTargetId);
|
||||
// make it in install state
|
||||
testdataFactory.sendUpdateActionStatusToTargets(Lists.newArrayList(createTarget), Status.FINISHED,
|
||||
"some message");
|
||||
Collections.singletonList("some message"));
|
||||
|
||||
mvc.perform(get(
|
||||
MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/installedTargets"))
|
||||
@@ -302,11 +292,16 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
|
||||
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
|
||||
|
||||
targetFilterQueryManagement
|
||||
.createTargetFilterQuery(entityFactory.generateTargetFilterQuery(knownFilterName, "x==y", createdDs));
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
entityFactory.targetFilterQuery().create().name(knownFilterName).query("x==y")).getId(),
|
||||
createdDs.getId());
|
||||
|
||||
// create some dummy target filter queries
|
||||
targetFilterQueryManagement.createTargetFilterQuery(entityFactory.generateTargetFilterQuery("b", "x==y"));
|
||||
targetFilterQueryManagement.createTargetFilterQuery(entityFactory.generateTargetFilterQuery("c", "x==y"));
|
||||
targetFilterQueryManagement
|
||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("b").query("x==y"));
|
||||
targetFilterQueryManagement
|
||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("c").query("x==y"));
|
||||
|
||||
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId()
|
||||
+ "/autoAssignTargetFilters")).andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(1)))
|
||||
@@ -334,14 +329,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
|
||||
final String query = "name==" + filterNamePrefix + "*";
|
||||
|
||||
// create target filter queries that should be found
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
entityFactory.generateTargetFilterQuery(filterNamePrefix + "1", "x==y", createdDs));
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
entityFactory.generateTargetFilterQuery(filterNamePrefix + "2", "x==z", createdDs));
|
||||
// create some dummy target filter queries
|
||||
targetFilterQueryManagement.createTargetFilterQuery(entityFactory.generateTargetFilterQuery("b", "x==y"));
|
||||
targetFilterQueryManagement.createTargetFilterQuery(entityFactory.generateTargetFilterQuery("c", "x==y"));
|
||||
prepareTestFilters(filterNamePrefix, createdDs);
|
||||
|
||||
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId()
|
||||
+ "/autoAssignTargetFilters").param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, query))
|
||||
@@ -358,20 +346,32 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
|
||||
final String query = "name==doesNotExist";
|
||||
|
||||
// create target filter queries that should be found
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
entityFactory.generateTargetFilterQuery(filterNamePrefix + "1", "x==y", createdDs));
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
entityFactory.generateTargetFilterQuery(filterNamePrefix + "2", "x==z", createdDs));
|
||||
// create some dummy target filter queries
|
||||
targetFilterQueryManagement.createTargetFilterQuery(entityFactory.generateTargetFilterQuery("b", "x==y"));
|
||||
targetFilterQueryManagement.createTargetFilterQuery(entityFactory.generateTargetFilterQuery("c", "x==y"));
|
||||
prepareTestFilters(filterNamePrefix, createdDs);
|
||||
|
||||
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId()
|
||||
+ "/autoAssignTargetFilters").param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, query))
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(0)));
|
||||
}
|
||||
|
||||
private void prepareTestFilters(final String filterNamePrefix, final DistributionSet createdDs) {
|
||||
// create target filter queries that should be found
|
||||
targetFilterQueryManagement
|
||||
.updateTargetFilterQueryAutoAssignDS(targetFilterQueryManagement
|
||||
.createTargetFilterQuery(
|
||||
entityFactory.targetFilterQuery().create().name(filterNamePrefix + "1").query("x==y"))
|
||||
.getId(), createdDs.getId());
|
||||
targetFilterQueryManagement
|
||||
.updateTargetFilterQueryAutoAssignDS(targetFilterQueryManagement
|
||||
.createTargetFilterQuery(
|
||||
entityFactory.targetFilterQuery().create().name(filterNamePrefix + "2").query("x==y"))
|
||||
.getId(), createdDs.getId());
|
||||
// create some dummy target filter queries
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
entityFactory.targetFilterQuery().create().name(filterNamePrefix + "b").query("x==y"));
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
entityFactory.targetFilterQuery().create().name(filterNamePrefix + "c").query("x==y"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that DS in repository are listed with proper paging properties.")
|
||||
public void getDistributionSetsWithoutAddtionalRequestParameters() throws Exception {
|
||||
@@ -423,11 +423,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.hasSize(0);
|
||||
|
||||
DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
set.setRequiredMigrationStep(set.isRequiredMigrationStep());
|
||||
set = distributionSetManagement.updateDistributionSet(set);
|
||||
|
||||
set.setVersion("anotherVersion");
|
||||
set = distributionSetManagement.updateDistributionSet(set);
|
||||
set = distributionSetManagement.updateDistributionSet(entityFactory.distributionSet().update(set.getId())
|
||||
.version("anotherVersion").requiredMigrationStep(true));
|
||||
|
||||
// load also lazy stuff
|
||||
set = distributionSetManagement.findDistributionSetByIdWithDetails(set.getId());
|
||||
@@ -443,7 +440,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
equalTo("http://localhost/rest/v1/distributionsets/" + set.getId())))
|
||||
.andExpect(jsonPath("$.content.[0].id", equalTo(set.getId().intValue())))
|
||||
.andExpect(jsonPath("$.content.[0].name", equalTo(set.getName())))
|
||||
.andExpect(jsonPath("$.content.[0].requiredMigrationStep", equalTo(set.isRequiredMigrationStep())))
|
||||
.andExpect(jsonPath("$.content.[0].requiredMigrationStep", equalTo(Boolean.TRUE)))
|
||||
.andExpect(jsonPath("$.content.[0].description", equalTo(set.getDescription())))
|
||||
.andExpect(jsonPath("$.content.[0].type", equalTo(set.getType().getKey())))
|
||||
.andExpect(jsonPath("$.content.[0].createdBy", equalTo(set.getCreatedBy())))
|
||||
@@ -457,7 +454,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.andExpect(jsonPath("$.content.[0].modules.[?(@.type==" + appType.getKey() + ")].id",
|
||||
contains(set.findFirstModuleByType(appType).getId().intValue())))
|
||||
.andExpect(jsonPath("$.content.[0].modules.[?(@.type==" + osType.getKey() + ")].id",
|
||||
contains(set.findFirstModuleByType(osType).getId().intValue())));
|
||||
contains(getOsModule(set).intValue())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -488,7 +485,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.andExpect(jsonPath("$.modules.[?(@.type==" + appType.getKey() + ")].id",
|
||||
contains(set.findFirstModuleByType(appType).getId().intValue())))
|
||||
.andExpect(jsonPath("$.modules.[?(@.type==" + osType.getKey() + ")].id",
|
||||
contains(set.findFirstModuleByType(osType).getId().intValue())));
|
||||
contains(getOsModule(set).intValue())));
|
||||
|
||||
}
|
||||
|
||||
@@ -508,13 +505,9 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
DistributionSet two = testdataFactory.generateDistributionSet("two", "two", standardDsType,
|
||||
Lists.newArrayList(os, jvm, ah));
|
||||
DistributionSet three = testdataFactory.generateDistributionSet("three", "three", standardDsType,
|
||||
Lists.newArrayList(os, jvm, ah));
|
||||
three.setRequiredMigrationStep(true);
|
||||
Lists.newArrayList(os, jvm, ah), true);
|
||||
|
||||
final List<DistributionSet> sets = new ArrayList<>();
|
||||
sets.add(one);
|
||||
sets.add(two);
|
||||
sets.add(three);
|
||||
final List<DistributionSet> sets = Lists.newArrayList(one, two, three);
|
||||
|
||||
final long current = System.currentTimeMillis();
|
||||
|
||||
@@ -640,8 +633,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.hasSize(0);
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
targetManagement.createTarget(entityFactory.generateTarget("test"));
|
||||
deploymentManagement.assignDistributionSet(set.getId(), "test");
|
||||
testdataFactory.createTarget("test");
|
||||
assignDistributionSet(set.getId(), "test");
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(1);
|
||||
@@ -670,12 +663,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(1);
|
||||
|
||||
final DistributionSet update = entityFactory.generateDistributionSet();
|
||||
update.setVersion("anotherVersion");
|
||||
update.setName(null);
|
||||
update.setType(standardDsType);
|
||||
|
||||
mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId()).content(JsonBuilder.distributionSet(update))
|
||||
mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId()).content("{\"version\":\"anotherVersion\"}")
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
|
||||
@@ -709,8 +697,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
final DistributionSet missingName = testdataFactory.generateDistributionSet("missingName");
|
||||
missingName.setName(null);
|
||||
final DistributionSet missingName = entityFactory.distributionSet().create().build();
|
||||
mvc.perform(
|
||||
post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(Lists.newArrayList(missingName)))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
@@ -762,8 +749,10 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.andExpect(jsonPath("[1]key", equalTo(knownKey2)))
|
||||
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
|
||||
|
||||
final DistributionSetMetadata metaKey1 = distributionSetManagement.findOne(testDS, knownKey1);
|
||||
final DistributionSetMetadata metaKey2 = distributionSetManagement.findOne(testDS, knownKey2);
|
||||
final DistributionSetMetadata metaKey1 = distributionSetManagement.findDistributionSetMetadata(testDS.getId(),
|
||||
knownKey1);
|
||||
final DistributionSetMetadata metaKey2 = distributionSetManagement.findDistributionSetMetadata(testDS.getId(),
|
||||
knownKey2);
|
||||
|
||||
assertThat(metaKey1.getValue()).isEqualTo(knownValue1);
|
||||
assertThat(metaKey2.getValue()).isEqualTo(knownValue2);
|
||||
@@ -778,8 +767,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String updateValue = "valueForUpdate";
|
||||
|
||||
final DistributionSet testDS = testdataFactory.createDistributionSet("one");
|
||||
distributionSetManagement.createDistributionSetMetadata(
|
||||
entityFactory.generateDistributionSetMetadata(testDS, knownKey, knownValue));
|
||||
createDistributionSetMetadata(testDS.getId(), entityFactory.generateMetadata(knownKey, knownValue));
|
||||
|
||||
final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue);
|
||||
|
||||
@@ -789,7 +777,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
|
||||
|
||||
final DistributionSetMetadata assertDS = distributionSetManagement.findOne(testDS, knownKey);
|
||||
final DistributionSetMetadata assertDS = distributionSetManagement.findDistributionSetMetadata(testDS.getId(),
|
||||
knownKey);
|
||||
assertThat(assertDS.getValue()).isEqualTo(updateValue);
|
||||
|
||||
}
|
||||
@@ -802,14 +791,13 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownValue = "knownValue";
|
||||
|
||||
final DistributionSet testDS = testdataFactory.createDistributionSet("one");
|
||||
distributionSetManagement.createDistributionSetMetadata(
|
||||
entityFactory.generateDistributionSetMetadata(testDS, knownKey, knownValue));
|
||||
createDistributionSetMetadata(testDS.getId(), entityFactory.generateMetadata(knownKey, knownValue));
|
||||
|
||||
mvc.perform(delete("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
|
||||
try {
|
||||
distributionSetManagement.findOne(testDS, knownKey);
|
||||
distributionSetManagement.findDistributionSetMetadata(testDS.getId(), knownKey);
|
||||
fail("expected EntityNotFoundException but didn't throw");
|
||||
} catch (final EntityNotFoundException e) {
|
||||
// ok as expected
|
||||
@@ -823,8 +811,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownKey = "knownKey";
|
||||
final String knownValue = "knownValue";
|
||||
final DistributionSet testDS = testdataFactory.createDistributionSet("one");
|
||||
distributionSetManagement.createDistributionSetMetadata(
|
||||
entityFactory.generateDistributionSetMetadata(testDS, knownKey, knownValue));
|
||||
createDistributionSetMetadata(testDS.getId(), entityFactory.generateMetadata(knownKey, knownValue));
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -842,9 +829,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownValuePrefix = "knownValue";
|
||||
final DistributionSet testDS = testdataFactory.createDistributionSet("one");
|
||||
for (int index = 0; index < totalMetadata; index++) {
|
||||
distributionSetManagement.createDistributionSetMetadata(entityFactory.generateDistributionSetMetadata(
|
||||
distributionSetManagement.findDistributionSetById(testDS.getId()), knownKeyPrefix + index,
|
||||
knownValuePrefix + index));
|
||||
createDistributionSetMetadata(testDS.getId(),
|
||||
entityFactory.generateMetadata(knownKeyPrefix + index, knownValuePrefix + index));
|
||||
}
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsets/{dsId}/metadata?offset=" + offsetParam + "&limit=" + limitParam,
|
||||
@@ -878,8 +864,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
public void filterDistributionSetComplete() throws Exception {
|
||||
final int amount = 10;
|
||||
testdataFactory.createDistributionSets(amount);
|
||||
distributionSetManagement.createDistributionSet(entityFactory.generateDistributionSet("incomplete", "2",
|
||||
"incomplete", distributionSetManagement.findDistributionSetTypeByKey("os"), null));
|
||||
distributionSetManagement.createDistributionSet(
|
||||
entityFactory.distributionSet().create().name("incomplete").version("2").type("os"));
|
||||
|
||||
final String rsqlFindLikeDs1OrDs2 = "complete==" + Boolean.TRUE;
|
||||
|
||||
@@ -895,21 +881,18 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
|
||||
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
|
||||
// prepare targets
|
||||
final String[] knownTargetIds = new String[] { "1", "2", "3", "4", "5" };
|
||||
final JSONArray list = new JSONArray();
|
||||
for (final String targetId : knownTargetIds) {
|
||||
targetManagement.createTarget(entityFactory.generateTarget(targetId));
|
||||
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
|
||||
}
|
||||
final Collection<String> knownTargetIds = Lists.newArrayList("1", "2", "3", "4", "5");
|
||||
|
||||
knownTargetIds.forEach(controllerId -> targetManagement
|
||||
.createTarget(entityFactory.target().create().controllerId(controllerId)));
|
||||
|
||||
// assign already one target to DS
|
||||
deploymentManagement.assignDistributionSet(createdDs.getId(), knownTargetIds[0]);
|
||||
assignDistributionSet(createdDs.getId(), knownTargetIds.iterator().next());
|
||||
|
||||
final String rsqlFindTargetId1 = "controllerId==1";
|
||||
|
||||
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId()
|
||||
+ "/assignedTargets?q=" + rsqlFindTargetId1).contentType(MediaType.APPLICATION_JSON)
|
||||
.content(list.toString()))
|
||||
+ "/assignedTargets?q=" + rsqlFindTargetId1).contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1)))
|
||||
.andExpect(jsonPath("size", equalTo(1))).andExpect(jsonPath("content[0].controllerId", equalTo("1")));
|
||||
}
|
||||
@@ -922,9 +905,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownValuePrefix = "knownValue";
|
||||
final DistributionSet testDS = testdataFactory.createDistributionSet("one");
|
||||
for (int index = 0; index < totalMetadata; index++) {
|
||||
distributionSetManagement.createDistributionSetMetadata(entityFactory.generateDistributionSetMetadata(
|
||||
distributionSetManagement.findDistributionSetById(testDS.getId()), knownKeyPrefix + index,
|
||||
knownValuePrefix + index));
|
||||
createDistributionSetMetadata(testDS.getId(),
|
||||
entityFactory.generateMetadata(knownKeyPrefix + index, knownValuePrefix + index));
|
||||
}
|
||||
|
||||
final String rsqlSearchValue1 = "value==knownValue1";
|
||||
@@ -937,7 +919,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
|
||||
private Set<DistributionSet> createDistributionSetsAlphabetical(final int amount) {
|
||||
char character = 'a';
|
||||
final Set<DistributionSet> created = new HashSet<>();
|
||||
final Set<DistributionSet> created = Sets.newHashSetWithExpectedSize(amount);
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String str = String.valueOf(character);
|
||||
created.add(testdataFactory.createDistributionSet(str));
|
||||
|
||||
@@ -21,13 +21,13 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||
@@ -44,6 +44,7 @@ import com.jayway.jsonpath.JsonPath;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Step;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
/**
|
||||
@@ -59,10 +60,11 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests.")
|
||||
public void getDistributionSetTypes() throws Exception {
|
||||
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = distributionSetManagement.updateDistributionSetType(testType);
|
||||
DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
||||
.name("TestName123").description("Desc123").colour("col12"));
|
||||
testType = distributionSetManagement.updateDistributionSetType(
|
||||
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
|
||||
|
||||
// 4 types overall (2 hawkbit tenant default, 1 test default and 1
|
||||
// generated in this test)
|
||||
@@ -99,10 +101,11 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests with sorting by KEY.")
|
||||
public void getDistributionSetTypesSortedByKey() throws Exception {
|
||||
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("zzzzz", "TestName123", "Desc123"));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = distributionSetManagement.updateDistributionSetType(testType);
|
||||
DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("zzzzz").name("TestName123")
|
||||
.description("Desc123").colour("col12"));
|
||||
testType = distributionSetManagement.updateDistributionSetType(
|
||||
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
|
||||
|
||||
// descending
|
||||
mvc.perform(get("/rest/v1/distributionsettypes").accept(MediaType.APPLICATION_JSON)
|
||||
@@ -138,35 +141,18 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes POST requests.")
|
||||
public void createDistributionSetTypes() throws JSONException, Exception {
|
||||
|
||||
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES);
|
||||
final List<DistributionSetType> types = createTestDistributionSetTestTypes();
|
||||
|
||||
final List<DistributionSetType> types = new ArrayList<>();
|
||||
types.add(entityFactory.generateDistributionSetType("test1", "TestName1", "Desc1")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(runtimeType));
|
||||
types.add(entityFactory.generateDistributionSetType("test2", "TestName2", "Desc2").addOptionalModuleType(osType)
|
||||
.addOptionalModuleType(runtimeType).addOptionalModuleType(appType));
|
||||
types.add(entityFactory.generateDistributionSetType("test3", "TestName3", "Desc3")
|
||||
.addMandatoryModuleType(osType).addMandatoryModuleType(runtimeType));
|
||||
final MvcResult mvcResult = runPostDistributionSetType(types);
|
||||
|
||||
final MvcResult mvcResult = mvc
|
||||
.perform(post("/rest/v1/distributionsettypes/").content(JsonBuilder.distributionSetTypes(types))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("[0].name", equalTo("TestName1"))).andExpect(jsonPath("[0].key", equalTo("test1")))
|
||||
.andExpect(jsonPath("[0].description", equalTo("Desc1")))
|
||||
.andExpect(jsonPath("[0].createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("[1].name", equalTo("TestName2"))).andExpect(jsonPath("[1].key", equalTo("test2")))
|
||||
.andExpect(jsonPath("[1].description", equalTo("Desc2")))
|
||||
.andExpect(jsonPath("[1].createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("[2].name", equalTo("TestName3"))).andExpect(jsonPath("[2].key", equalTo("test3")))
|
||||
.andExpect(jsonPath("[2].description", equalTo("Desc3")))
|
||||
.andExpect(jsonPath("[2].createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("[2].createdAt", not(equalTo(0)))).andReturn();
|
||||
verifyCreatedDistributionSetTypes(mvcResult);
|
||||
}
|
||||
|
||||
final DistributionSetType created1 = distributionSetManagement.findDistributionSetTypeByKey("test1");
|
||||
final DistributionSetType created2 = distributionSetManagement.findDistributionSetTypeByKey("test2");
|
||||
final DistributionSetType created3 = distributionSetManagement.findDistributionSetTypeByKey("test3");
|
||||
@Step
|
||||
private void verifyCreatedDistributionSetTypes(final MvcResult mvcResult) throws UnsupportedEncodingException {
|
||||
final DistributionSetType created1 = distributionSetManagement.findDistributionSetTypeByKey("testKey1");
|
||||
final DistributionSetType created2 = distributionSetManagement.findDistributionSetTypeByKey("testKey2");
|
||||
final DistributionSetType created3 = distributionSetManagement.findDistributionSetTypeByKey("testKey3");
|
||||
|
||||
assertThat(created1.getMandatoryModuleTypes()).containsOnly(osType);
|
||||
assertThat(created1.getOptionalModuleTypes()).containsOnly(runtimeType);
|
||||
@@ -206,12 +192,50 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(6);
|
||||
}
|
||||
|
||||
@Step
|
||||
private MvcResult runPostDistributionSetType(final List<DistributionSetType> types) throws Exception {
|
||||
return mvc
|
||||
.perform(post("/rest/v1/distributionsettypes/").content(JsonBuilder.distributionSetTypes(types))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("[0].name", equalTo("TestName1")))
|
||||
.andExpect(jsonPath("[0].key", equalTo("testKey1")))
|
||||
.andExpect(jsonPath("[0].description", equalTo("Desc1")))
|
||||
.andExpect(jsonPath("[0].createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("[1].name", equalTo("TestName2")))
|
||||
.andExpect(jsonPath("[1].key", equalTo("testKey2")))
|
||||
.andExpect(jsonPath("[1].description", equalTo("Desc2")))
|
||||
.andExpect(jsonPath("[1].createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("[2].name", equalTo("TestName3")))
|
||||
.andExpect(jsonPath("[2].key", equalTo("testKey3")))
|
||||
.andExpect(jsonPath("[2].description", equalTo("Desc3")))
|
||||
.andExpect(jsonPath("[2].createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("[2].createdAt", not(equalTo(0)))).andReturn();
|
||||
}
|
||||
|
||||
@Step
|
||||
private List<DistributionSetType> createTestDistributionSetTestTypes() {
|
||||
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES);
|
||||
|
||||
return Lists.newArrayList(
|
||||
entityFactory.distributionSetType().create().key("testKey1").name("TestName1").description("Desc1")
|
||||
.colour("col").mandatory(Lists.newArrayList(osType.getId()))
|
||||
.optional(Lists.newArrayList(runtimeType.getId())).build(),
|
||||
entityFactory.distributionSetType().create().key("testKey2").name("TestName2").description("Desc2")
|
||||
.colour("col")
|
||||
.optional(Lists.newArrayList(runtimeType.getId(), osType.getId(), appType.getId())).build(),
|
||||
entityFactory.distributionSetType().create().key("testKey3").name("TestName3").description("Desc3")
|
||||
.colour("col").mandatory(Lists.newArrayList(runtimeType.getId(), osType.getId())).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes POST requests.")
|
||||
public void addMandatoryModuleToDistributionSetType() throws JSONException, Exception {
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
||||
.name("TestName123").description("Desc123").colour("col12"));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
|
||||
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType.getId())
|
||||
@@ -229,8 +253,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes POST requests.")
|
||||
public void addOptionalModuleToDistributionSetType() throws JSONException, Exception {
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
||||
.name("TestName123").description("Desc123").colour("col12"));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
|
||||
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId())
|
||||
@@ -249,12 +274,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes GET requests.")
|
||||
public void getMandatoryModulesOfDistributionSetType() throws JSONException, Exception {
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
|
||||
final DistributionSetType testType = generateTestType();
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType.getId())
|
||||
.accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -268,12 +288,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes GET requests.")
|
||||
public void getOptionalModulesOfDistributionSetType() throws JSONException, Exception {
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
|
||||
final DistributionSetType testType = generateTestType();
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId())
|
||||
.accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -288,12 +303,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes/{ID} GET requests.")
|
||||
public void getMandatoryModuleOfDistributionSetType() throws JSONException, Exception {
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
|
||||
final DistributionSetType testType = generateTestType();
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes/{smtId}", testType.getId(),
|
||||
osType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
@@ -306,16 +316,21 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
.andExpect(jsonPath("$.lastModifiedAt", equalTo(osType.getLastModifiedAt())));
|
||||
}
|
||||
|
||||
private DistributionSetType generateTestType() {
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(entityFactory
|
||||
.distributionSetType().create().key("test123").name("TestName123").description("Desc123").colour("col")
|
||||
.mandatory(Lists.newArrayList(osType.getId())).optional(Lists.newArrayList(appType.getId())));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
|
||||
return testType;
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes/{ID} GET requests.")
|
||||
public void getOptionalModuleOfDistributionSetType() throws JSONException, Exception {
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
|
||||
final DistributionSetType testType = generateTestType();
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes/{smtId}", testType.getId(),
|
||||
appType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
@@ -332,12 +347,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes/{ID} DELETE requests.")
|
||||
public void removeMandatoryModuleToDistributionSetType() throws JSONException, Exception {
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
|
||||
DistributionSetType testType = generateTestType();
|
||||
|
||||
mvc.perform(delete("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes/{smtId}", testType.getId(),
|
||||
osType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
@@ -354,12 +364,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes/{ID} DELETE requests.")
|
||||
public void removeOptionalModuleToDistributionSetType() throws JSONException, Exception {
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
|
||||
DistributionSetType testType = generateTestType();
|
||||
|
||||
mvc.perform(delete("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes/{smtId}", testType.getId(),
|
||||
appType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
@@ -377,10 +382,11 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID} GET requests.")
|
||||
public void getDistributionSetType() throws Exception {
|
||||
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = distributionSetManagement.updateDistributionSetType(testType);
|
||||
DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
||||
.name("TestName123").description("Desc123").colour("col12"));
|
||||
testType = distributionSetManagement.updateDistributionSetType(
|
||||
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId()).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -396,8 +402,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (hard delete scenario).")
|
||||
public void deleteDistributionSetTypeUnused() throws Exception {
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
final DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
||||
.name("TestName123").description("Desc123").colour("col12"));
|
||||
|
||||
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES + 1);
|
||||
|
||||
@@ -411,10 +418,12 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (soft delete scenario).")
|
||||
public void deleteDistributionSetTypeUsed() throws Exception {
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
distributionSetManagement.createDistributionSet(
|
||||
entityFactory.generateDistributionSet("sdfsd", "dsfsdf", "sdfsdf", testType, null));
|
||||
final DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
||||
.name("TestName123").description("Desc123").colour("col12"));
|
||||
|
||||
distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create().name("sdfsd")
|
||||
.description("dsfsdf").version("1").type(testType));
|
||||
|
||||
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES + 1);
|
||||
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
|
||||
@@ -429,8 +438,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Test
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID} PUT requests.")
|
||||
public void updateDistributionSetTypeOnlyDescriptionAndNameUntouched() throws Exception {
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
final DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
||||
.name("TestName123").description("Desc123").colour("col"));
|
||||
|
||||
final String body = new JSONObject().put("id", testType.getId()).put("description", "foobardesc")
|
||||
.put("name", "nameShouldNotBeChanged").toString();
|
||||
@@ -488,11 +498,12 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Test
|
||||
@Description("Ensures that the server is behaving as expected on invalid requests (wrong media type, wrong ID etc.).")
|
||||
public void invalidRequestsOnDistributionSetTypesResource() throws Exception {
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
// final DistributionSetType testDsType = distributionSetManagement
|
||||
// .createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
||||
// .name("TestName123").description("Desc123").colour("col"));
|
||||
|
||||
final SoftwareModuleType testSmType = softwareManagement.createSoftwareModuleType(
|
||||
entityFactory.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
entityFactory.softwareModuleType().create().key("test123").name("TestName123"));
|
||||
|
||||
// DST does not exist
|
||||
mvc.perform(get("/rest/v1/distributionsettypes/12345678")).andDo(MockMvcResultPrinter.print())
|
||||
@@ -532,10 +543,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
|
||||
// Modules types at creation time invalid
|
||||
|
||||
final DistributionSetType testNewType = entityFactory.generateDistributionSetType("test123", "TestName123",
|
||||
"Desc123");
|
||||
testNewType.addMandatoryModuleType(
|
||||
entityFactory.generateSoftwareModuleType("foo", "bar", "test", Integer.MAX_VALUE));
|
||||
final DistributionSetType testNewType = entityFactory.distributionSetType().create().key("test123")
|
||||
.name("TestName123").description("Desc123").colour("col").mandatory(Lists.newArrayList(osType.getId()))
|
||||
.optional(Collections.emptyList()).build();
|
||||
|
||||
mvc.perform(post("/rest/v1/distributionsettypes")
|
||||
.content(JsonBuilder.distributionSetTypes(Lists.newArrayList(testNewType)))
|
||||
@@ -556,8 +566,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
final DistributionSetType toLongName = entityFactory.generateDistributionSetType("test123",
|
||||
RandomStringUtils.randomAscii(80), "Desc123");
|
||||
final DistributionSetType toLongName = entityFactory.distributionSetType().create().key("test123")
|
||||
.name(RandomStringUtils.randomAscii(80)).build();
|
||||
mvc.perform(post("/rest/v1/distributionsettypes")
|
||||
.content(JsonBuilder.distributionSetTypes(Lists.newArrayList(toLongName)))
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
@@ -580,10 +590,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Test
|
||||
@Description("Search erquest of software module types.")
|
||||
public void searchDistributionSetTypeRsql() throws Exception {
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
final DistributionSetType testType2 = distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.generateDistributionSetType("test1234", "TestName1234", "Desc123"));
|
||||
distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("test123").name("TestName123"));
|
||||
distributionSetManagement.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("test1234").name("TestName1234"));
|
||||
|
||||
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
|
||||
|
||||
@@ -597,9 +607,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
char character = 'a';
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String str = String.valueOf(character);
|
||||
final SoftwareModule softwareModule = entityFactory.generateSoftwareModule(osType, str, str, str, str);
|
||||
|
||||
softwareManagement.createSoftwareModule(softwareModule);
|
||||
softwareManagement.createSoftwareModule(
|
||||
entityFactory.softwareModule().create().name(str).description(str).vendor(str).version(str));
|
||||
character++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@@ -45,6 +44,8 @@ import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
@@ -119,7 +120,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
@Description("Testing that rollout can be created")
|
||||
public void createRollout() throws Exception {
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(20, "target", "rollout"));
|
||||
testdataFactory.createTargets(20, "target", "rollout");
|
||||
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
postRollout("rollout1", 10, dsA.getId(), "id==target*");
|
||||
@@ -131,25 +132,18 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("ro");
|
||||
|
||||
final int amountTargets = 10;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "ro-target", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "ro-target", "rollout");
|
||||
|
||||
List<RolloutGroup> rolloutGroups = new ArrayList<>(2);
|
||||
final int percentTargetsInGroup1 = 20;
|
||||
final int percentTargetsInGroup2 = 100;
|
||||
final float percentTargetsInGroup1 = 20;
|
||||
final float percentTargetsInGroup2 = 100;
|
||||
|
||||
RolloutGroup group1 = entityFactory.generateRolloutGroup();
|
||||
group1.setName("Group1");
|
||||
group1.setDescription("Group1desc");
|
||||
group1.setTargetPercentage(percentTargetsInGroup1);
|
||||
rolloutGroups.add(group1);
|
||||
final List<RolloutGroup> rolloutGroups = Lists.newArrayList(
|
||||
entityFactory.rolloutGroup().create().name("Group1").description("Group1desc")
|
||||
.targetPercentage(percentTargetsInGroup1).build(),
|
||||
entityFactory.rolloutGroup().create().name("Group2").description("Group2desc")
|
||||
.targetPercentage(percentTargetsInGroup2).build());
|
||||
|
||||
RolloutGroup group2 = entityFactory.generateRolloutGroup();
|
||||
group2.setName("Group2");
|
||||
group2.setDescription("Group2desc");
|
||||
group2.setTargetPercentage(percentTargetsInGroup2);
|
||||
rolloutGroups.add(group2);
|
||||
|
||||
RolloutGroupConditions rolloutGroupConditions = new RolloutGroupConditionBuilder().build();
|
||||
final RolloutGroupConditions rolloutGroupConditions = new RolloutGroupConditionBuilder().withDefaults().build();
|
||||
|
||||
mvc.perform(post("/rest/v1/rollouts")
|
||||
.content(JsonBuilder.rollout("rollout2", "desc", null, dsA.getId(), "id==ro-target*",
|
||||
@@ -161,41 +155,50 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Testing that no rollout with groups that have illegal percentages can be created")
|
||||
public void createRolloutWithIllegalPercentages() throws Exception {
|
||||
public void createRolloutWithToLowlPercentage() throws Exception {
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("ro2");
|
||||
|
||||
final int amountTargets = 10;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "ro-target", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "ro-target", "rollout");
|
||||
|
||||
List<RolloutGroup> rolloutGroups = new ArrayList<>(2);
|
||||
final List<RolloutGroup> rolloutGroups = Lists.newArrayList(
|
||||
entityFactory.rolloutGroup().create().name("Group1").description("Group1desc").targetPercentage(0F)
|
||||
.build(),
|
||||
entityFactory.rolloutGroup().create().name("Group2").description("Group2desc").targetPercentage(100F)
|
||||
.build());
|
||||
|
||||
RolloutGroup group1 = entityFactory.generateRolloutGroup();
|
||||
group1.setName("Group1");
|
||||
group1.setDescription("Group1desc");
|
||||
group1.setTargetPercentage(0);
|
||||
rolloutGroups.add(group1);
|
||||
|
||||
RolloutGroup group2 = entityFactory.generateRolloutGroup();
|
||||
group2.setName("Group2");
|
||||
group2.setDescription("Group2desc");
|
||||
group2.setTargetPercentage(100);
|
||||
rolloutGroups.add(group2);
|
||||
|
||||
RolloutGroupConditions rolloutGroupConditions = new RolloutGroupConditionBuilder().build();
|
||||
final RolloutGroupConditions rolloutGroupConditions = new RolloutGroupConditionBuilder().withDefaults().build();
|
||||
|
||||
mvc.perform(post("/rest/v1/rollouts")
|
||||
.content(JsonBuilder.rollout("rollout4", "desc", null, dsA.getId(), "id==ro-target*",
|
||||
rolloutGroupConditions, rolloutGroups))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isInternalServerError())
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest())
|
||||
.andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.repo.constraintViolation")));
|
||||
|
||||
group1.setTargetPercentage(101);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Testing that no rollout with groups that have illegal percentages can be created")
|
||||
public void createRolloutWithToHighPercentage() throws Exception {
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("ro2");
|
||||
|
||||
final int amountTargets = 10;
|
||||
testdataFactory.createTargets(amountTargets, "ro-target", "rollout");
|
||||
|
||||
final List<RolloutGroup> rolloutGroups = Lists.newArrayList(
|
||||
entityFactory.rolloutGroup().create().name("Group1").description("Group1desc").targetPercentage(1F)
|
||||
.build(),
|
||||
entityFactory.rolloutGroup().create().name("Group2").description("Group2desc").targetPercentage(101F)
|
||||
.build());
|
||||
|
||||
final RolloutGroupConditions rolloutGroupConditions = new RolloutGroupConditionBuilder().withDefaults().build();
|
||||
|
||||
mvc.perform(post("/rest/v1/rollouts")
|
||||
.content(JsonBuilder.rollout("rollout4", "desc", null, dsA.getId(), "id==ro-target*",
|
||||
rolloutGroupConditions, rolloutGroups))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isInternalServerError())
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest())
|
||||
.andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.repo.constraintViolation")));
|
||||
|
||||
}
|
||||
@@ -213,7 +216,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void rolloutPagedListContainsAllRollouts() throws Exception {
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(20, "target", "rollout"));
|
||||
testdataFactory.createTargets(20, "target", "rollout");
|
||||
|
||||
// setup - create 2 rollouts
|
||||
postRollout("rollout1", 10, dsA.getId(), "id==target*");
|
||||
@@ -240,7 +243,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void rolloutPagedListIsLimitedToQueryParam() throws Exception {
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(20, "target", "rollout"));
|
||||
testdataFactory.createTargets(20, "target", "rollout");
|
||||
|
||||
// setup - create 2 rollouts
|
||||
postRollout("rollout1", 10, dsA.getId(), "id==target*");
|
||||
@@ -259,7 +262,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void retrieveRolloutGroupsForSpecificRollout() throws Exception {
|
||||
// setup
|
||||
final int amountTargets = 20;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "rollout", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
@@ -281,7 +284,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void startingRolloutSwitchesIntoRunningState() throws Exception {
|
||||
// setup
|
||||
final int amountTargets = 20;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "rollout", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
@@ -312,7 +315,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void pausingRolloutSwitchesIntoPausedState() throws Exception {
|
||||
// setup
|
||||
final int amountTargets = 20;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "rollout", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
@@ -341,7 +344,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void resumingRolloutSwitchesIntoRunningState() throws Exception {
|
||||
// setup
|
||||
final int amountTargets = 20;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "rollout", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
@@ -374,7 +377,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void startingAlreadyStartedRolloutReturnsBadRequest() throws Exception {
|
||||
// setup
|
||||
final int amountTargets = 20;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "rollout", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
@@ -398,7 +401,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void resumingNotStartedRolloutReturnsBadRequest() throws Exception {
|
||||
// setup
|
||||
final int amountTargets = 20;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "rollout", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
@@ -415,7 +418,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void startingRolloutFirstRolloutGroupIsInRunningState() throws Exception {
|
||||
// setup
|
||||
final int amountTargets = 10;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "rollout", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
@@ -443,7 +446,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void retrieveSingleRolloutGroup() throws Exception {
|
||||
// setup
|
||||
final int amountTargets = 10;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "rollout", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
@@ -466,7 +469,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void retrieveTargetsFromRolloutGroup() throws Exception {
|
||||
// setup
|
||||
final int amountTargets = 10;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "rollout", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
@@ -488,8 +491,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void retrieveTargetsFromRolloutGroupWithQuery() throws Exception {
|
||||
// setup
|
||||
final int amountTargets = 10;
|
||||
final List<Target> targets = targetManagement
|
||||
.createTargets(testdataFactory.generateTargets(amountTargets, "rollout", "rollout"));
|
||||
final List<Target> targets = testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
@@ -513,7 +515,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void retrieveTargetsFromRolloutGroupAfterRolloutIsStarted() throws Exception {
|
||||
// setup
|
||||
final int amountTargets = 10;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "rollout", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
@@ -540,7 +542,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void startingRolloutSwitchesIntoRunningStateAsync() throws Exception {
|
||||
|
||||
final int amountTargets = 1000;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "rollout", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
@@ -554,8 +556,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
rolloutManagement.checkStartingRollouts(0);
|
||||
|
||||
// check if running
|
||||
assertThat(doWithTimeout(() -> getRollout(rollout.getId()), result -> success(result), 60_000, 100))
|
||||
.isNotNull();
|
||||
assertThat(doWithTimeout(() -> getRollout(rollout.getId()), this::success, 60_000, 100)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -566,10 +567,10 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
final int amountTargetsRollout2 = 25;
|
||||
final int amountTargetsRollout3 = 25;
|
||||
final int amountTargetsOther = 25;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargetsRollout1, "rollout1", "rollout1"));
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargetsRollout2, "rollout2", "rollout2"));
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargetsRollout3, "rollout3", "rollout3"));
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargetsOther, "other1", "other1"));
|
||||
testdataFactory.createTargets(amountTargetsRollout1, "rollout1", "rollout1");
|
||||
testdataFactory.createTargets(amountTargetsRollout2, "rollout2", "rollout2");
|
||||
testdataFactory.createTargets(amountTargetsRollout3, "rollout3", "rollout3");
|
||||
testdataFactory.createTargets(amountTargetsOther, "other1", "other1");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
createRollout("rollout1", 5, dsA.getId(), "controllerId==rollout1*");
|
||||
@@ -600,7 +601,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
public void retrieveRolloutGroupsForSpecificRolloutWithRSQLParam() throws Exception {
|
||||
// setup
|
||||
final int amountTargets = 20;
|
||||
targetManagement.createTargets(testdataFactory.generateTargets(amountTargets, "rollout", "rollout"));
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
// create rollout including the created targets with prefix 'rollout'
|
||||
@@ -667,22 +668,20 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
final String targetFilterQuery) throws Exception {
|
||||
mvc.perform(post("/rest/v1/rollouts")
|
||||
.content(JsonBuilder.rollout(name, "desc", groupSize, distributionSetId, targetFilterQuery,
|
||||
new RolloutGroupConditionBuilder().build()))
|
||||
new RolloutGroupConditionBuilder().withDefaults().build()))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()).andReturn();
|
||||
}
|
||||
|
||||
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId,
|
||||
final String targetFilterQuery) {
|
||||
Rollout rollout = entityFactory.generateRollout();
|
||||
rollout.setDistributionSet(distributionSetManagement.findDistributionSetById(distributionSetId));
|
||||
rollout.setName(name);
|
||||
rollout.setTargetFilterQuery(targetFilterQuery);
|
||||
rollout = rolloutManagement.createRollout(rollout, amountGroups, new RolloutGroupConditionBuilder()
|
||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build());
|
||||
final Rollout rollout = rolloutManagement.createRollout(
|
||||
entityFactory.rollout().create().name(name).set(distributionSetId).targetFilterQuery(targetFilterQuery),
|
||||
amountGroups, new RolloutGroupConditionBuilder().withDefaults()
|
||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build());
|
||||
|
||||
// Run here, because Scheduler is disabled during tests
|
||||
rolloutManagement.fillRolloutGroupsWithTargets(rolloutManagement.findRolloutById(rollout.getId()));
|
||||
rolloutManagement.fillRolloutGroupsWithTargets(rollout.getId());
|
||||
|
||||
return rolloutManagement.findRolloutById(rollout.getId());
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,6 +36,7 @@ import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.Constants;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
@@ -91,16 +91,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
final String updateVendor = "newVendor1";
|
||||
final String updateDescription = "newDescription1";
|
||||
|
||||
softwareManagement
|
||||
.createSoftwareModule(entityFactory.generateSoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||
softwareManagement.createSoftwareModule(
|
||||
entityFactory.generateSoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
|
||||
softwareManagement
|
||||
.createSoftwareModule(entityFactory.generateSoftwareModule(osType, "poky", "3.0.2", null, ""));
|
||||
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, knownSWName, knownSWVersion,
|
||||
knownSWDescription, knownSWVendor);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
SoftwareModule sm = softwareManagement.createSoftwareModule(entityFactory.softwareModule().create().type(osType)
|
||||
.name(knownSWName).version(knownSWVersion).description(knownSWDescription).vendor(knownSWVendor));
|
||||
|
||||
assertThat(sm.getName()).as("Wrong name of the software module").isEqualTo(knownSWName);
|
||||
|
||||
@@ -120,13 +112,18 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
.andExpect(jsonPath("$.description", equalTo(updateDescription)))
|
||||
.andExpect(jsonPath("$.name", equalTo(knownSWName))).andReturn();
|
||||
|
||||
sm = softwareManagement.findSoftwareModuleById(sm.getId());
|
||||
assertThat(sm.getName()).isEqualTo(knownSWName);
|
||||
assertThat(sm.getVendor()).isEqualTo(updateVendor);
|
||||
assertThat(sm.getLastModifiedBy()).isEqualTo("smUpdateTester");
|
||||
assertThat(sm.getDescription()).isEqualTo(updateDescription);
|
||||
|
||||
}
|
||||
|
||||
@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 {
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
// create test file
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
@@ -191,8 +188,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0);
|
||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(0);
|
||||
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final MockMultipartFile file = new MockMultipartFile("file", "orig", null, new byte[0]);
|
||||
|
||||
@@ -204,8 +200,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
@Test
|
||||
@Description("Verfies that the system does not accept identical artifacts uploads for the same software module. Expected response: CONFLICT")
|
||||
public void duplicateUploadArtifact() throws Exception {
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
final String md5sum = HashGeneratorUtils.generateMD5(random);
|
||||
@@ -226,8 +221,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
@Test
|
||||
@Description("verfies that option to upload artifacts with a custom defined by metadata, i.e. not the file name of the binary itself.")
|
||||
public void uploadArtifactWithCustomName() throws Exception {
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(0);
|
||||
|
||||
// create test file
|
||||
@@ -253,8 +247,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
@Test
|
||||
@Description("Verfies that the system refuses upload of an artifact where the provided hash sums do not match. Expected result: BAD REQUEST")
|
||||
public void uploadArtifactWithHashCheck() throws Exception {
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(0);
|
||||
|
||||
// create test file
|
||||
@@ -297,8 +290,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
@Test
|
||||
@Description("Tests binary download of an artifact including verfication that the downloaded binary is consistent and that the etag header is as expected identical to the SHA1 hash of the file.")
|
||||
public void downloadArtifact() throws Exception {
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
|
||||
@@ -332,8 +324,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
@Description("Verifies the listing of one defined artifact assigned to a given software module. That includes the artifact metadata and download links.")
|
||||
public void getArtifact() throws Exception {
|
||||
// prepare data for test
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
|
||||
@@ -358,8 +349,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
@Test
|
||||
@Description("Verifies the listing of all artifacts assigned to a software module. That includes the artifact metadata and download links.")
|
||||
public void getArtifacts() throws Exception {
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
|
||||
@@ -399,8 +389,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
final MockMultipartFile file = new MockMultipartFile("file", "orig", null, random);
|
||||
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
// no artifact available
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts/1234567/download", sm.getId()))
|
||||
@@ -432,8 +421,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
@Test
|
||||
@Description("Verfies that the system refuses unsupported request types and answers as defined to them, e.g. NOT FOUND on a non existing resource. Or a HTTP POST for updating a resource results in METHOD NOT ALLOWED etc.")
|
||||
public void invalidRequestsOnSoftwaremodulesResource() throws Exception {
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final List<SoftwareModule> modules = Lists.newArrayList(sm);
|
||||
|
||||
@@ -458,8 +446,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
final SoftwareModule toLongName = entityFactory.generateSoftwareModule(osType,
|
||||
RandomStringUtils.randomAscii(80), "version 1", null, null);
|
||||
final SoftwareModule toLongName = entityFactory.softwareModule().create().type(osType)
|
||||
.name(RandomStringUtils.randomAscii(80)).build();
|
||||
mvc.perform(
|
||||
post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(Lists.newArrayList(toLongName)))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
@@ -525,25 +513,17 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Test retrieval of all software modules the user has access to.")
|
||||
public void getSoftwareModules() throws Exception {
|
||||
SoftwareModule os = entityFactory.generateSoftwareModule(osType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
os = softwareManagement.createSoftwareModule(os);
|
||||
|
||||
SoftwareModule jvm = entityFactory.generateSoftwareModule(runtimeType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
jvm = softwareManagement.createSoftwareModule(jvm);
|
||||
|
||||
SoftwareModule ah = entityFactory.generateSoftwareModule(appType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
ah = softwareManagement.createSoftwareModule(ah);
|
||||
final SoftwareModule os = testdataFactory.createSoftwareModuleOs();
|
||||
final SoftwareModule app = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules").accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os.getId() + ")].name", contains("name1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os.getId() + ")].version", contains("version1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os.getId() + ")].description", contains("description1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os.getId() + ")].vendor", contains("vendor1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os.getId() + ")].name", contains(os.getName())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os.getId() + ")].version", contains(os.getVersion())))
|
||||
.andExpect(
|
||||
jsonPath("$.content.[?(@.id==" + os.getId() + ")].description", contains(os.getDescription())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os.getId() + ")].vendor", contains(os.getVendor())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os.getId() + ")].type", contains("os")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os.getId() + ")].createdBy", contains("uploadTester")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os.getId() + ")].createdAt", contains(os.getCreatedAt())))
|
||||
@@ -556,121 +536,83 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os.getId() + ")]._links.metadata.href",
|
||||
contains("http://localhost/rest/v1/softwaremodules/" + os.getId()
|
||||
+ "/metadata?offset=0&limit=50")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm.getId() + ")].name", contains("name1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm.getId() + ")].version", contains("version1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm.getId() + ")].description", contains("description1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm.getId() + ")].vendor", contains("vendor1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm.getId() + ")].type", contains("runtime")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm.getId() + ")].createdBy", contains("uploadTester")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm.getId() + ")].createdAt", contains(jvm.getCreatedAt())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm.getId() + ")]._links.type.href",
|
||||
contains("http://localhost/rest/v1/softwaremoduletypes/" + runtimeType.getId())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm.getId() + ")]._links.self.href",
|
||||
contains("http://localhost/rest/v1/softwaremodules/" + jvm.getId())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm.getId() + ")]._links.artifacts.href",
|
||||
contains("http://localhost/rest/v1/softwaremodules/" + jvm.getId() + "/artifacts")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm.getId() + ")]._links.metadata.href",
|
||||
contains("http://localhost/rest/v1/softwaremodules/" + jvm.getId()
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")].name", contains(app.getName())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")].version", contains(app.getVersion())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")].description",
|
||||
contains(app.getDescription())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")].vendor", contains(app.getVendor())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")].type", contains("application")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")].createdBy", contains("uploadTester")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")].createdAt", contains(app.getCreatedAt())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")]._links.artifacts.href",
|
||||
contains("http://localhost/rest/v1/softwaremodules/" + app.getId() + "/artifacts")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")]._links.metadata.href",
|
||||
contains("http://localhost/rest/v1/softwaremodules/" + app.getId()
|
||||
+ "/metadata?offset=0&limit=50")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah.getId() + ")].name", contains("name1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah.getId() + ")].version", contains("version1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah.getId() + ")].description", contains("description1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah.getId() + ")].vendor", contains("vendor1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah.getId() + ")].type", contains("application")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah.getId() + ")].createdBy", contains("uploadTester")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah.getId() + ")].createdAt", contains(ah.getCreatedAt())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah.getId() + ")]._links.artifacts.href",
|
||||
contains("http://localhost/rest/v1/softwaremodules/" + ah.getId() + "/artifacts")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah.getId() + ")]._links.metadata.href",
|
||||
contains("http://localhost/rest/v1/softwaremodules/" + ah.getId()
|
||||
+ "/metadata?offset=0&limit=50")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah.getId() + ")]._links.type.href",
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")]._links.type.href",
|
||||
contains("http://localhost/rest/v1/softwaremoduletypes/" + appType.getId())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah.getId() + ")]._links.self.href",
|
||||
contains("http://localhost/rest/v1/softwaremodules/" + ah.getId())));
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")]._links.self.href",
|
||||
contains("http://localhost/rest/v1/softwaremodules/" + app.getId())));
|
||||
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).as("Softwaremodule size is wrong").hasSize(3);
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).as("Softwaremodule size is wrong").hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test the various filter parameters, e.g. filter by name or type of the module.")
|
||||
public void getSoftwareModulesWithFilterParameters() throws Exception {
|
||||
SoftwareModule os1 = entityFactory.generateSoftwareModule(osType, "osName1", "1.0.0", "description1",
|
||||
"vendor1");
|
||||
os1 = softwareManagement.createSoftwareModule(os1);
|
||||
final SoftwareModule os1 = testdataFactory.createSoftwareModuleOs("1");
|
||||
final SoftwareModule app1 = testdataFactory.createSoftwareModuleApp("1");
|
||||
testdataFactory.createSoftwareModuleOs("2");
|
||||
final SoftwareModule app2 = testdataFactory.createSoftwareModuleApp("2");
|
||||
|
||||
SoftwareModule jvm1 = entityFactory.generateSoftwareModule(runtimeType, "runtimeName1", "2.0.0", "description1",
|
||||
"vendor1");
|
||||
jvm1 = softwareManagement.createSoftwareModule(jvm1);
|
||||
|
||||
SoftwareModule ah1 = entityFactory.generateSoftwareModule(appType, "appName1", "3.0.0", "description1",
|
||||
"vendor1");
|
||||
ah1 = softwareManagement.createSoftwareModule(ah1);
|
||||
|
||||
SoftwareModule os2 = entityFactory.generateSoftwareModule(osType, "osName2", "1.0.1", "description2",
|
||||
"vendor2");
|
||||
os2 = softwareManagement.createSoftwareModule(os2);
|
||||
|
||||
SoftwareModule jvm2 = entityFactory.generateSoftwareModule(runtimeType, "runtimeName2", "2.0.1", "description2",
|
||||
"vendor2");
|
||||
jvm2 = softwareManagement.createSoftwareModule(jvm2);
|
||||
|
||||
SoftwareModule ah2 = entityFactory.generateSoftwareModule(appType, "appName2", "3.0.1", "description2",
|
||||
"vendor2");
|
||||
ah2 = softwareManagement.createSoftwareModule(ah2);
|
||||
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(6);
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(4);
|
||||
|
||||
// only by name, only one exists per name
|
||||
mvc.perform(get("/rest/v1/softwaremodules?q=name==osName1").accept(MediaType.APPLICATION_JSON))
|
||||
mvc.perform(get("/rest/v1/softwaremodules?q=name==" + os1.getName()).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].name", contains("osName1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].version", contains("1.0.0")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].description", contains("description1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].vendor", contains("vendor1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].name", contains(os1.getName())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].version", contains(os1.getVersion())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].description",
|
||||
contains(os1.getDescription())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].vendor", contains(os1.getVendor())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].type", contains("os")))
|
||||
.andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1)));
|
||||
|
||||
// by type, 2 software modules per type exists
|
||||
mvc.perform(get("/rest/v1/softwaremodules?q=type==application").accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
mvc.perform(get("/rest/v1/softwaremodules?q=type==" + Constants.SMT_DEFAULT_APP_KEY)
|
||||
.accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah1.getId() + ")].name", contains("appName1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah1.getId() + ")].version", contains("3.0.0")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah1.getId() + ")].description", contains("description1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah1.getId() + ")].vendor", contains("vendor1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah1.getId() + ")].type", contains("application")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah2.getId() + ")].name", contains("appName2")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah2.getId() + ")].version", contains("3.0.1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah2.getId() + ")].description", contains("description2")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah2.getId() + ")].vendor", contains("vendor2")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + ah2.getId() + ")].type", contains("application")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].name", contains(app1.getName())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].version", contains(app1.getVersion())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].description",
|
||||
contains(app1.getDescription())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].vendor", contains(app1.getVendor())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].type",
|
||||
contains(Constants.SMT_DEFAULT_APP_KEY)))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app2.getId() + ")].name", contains(app2.getName())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app2.getId() + ")].version", contains(app2.getVersion())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app2.getId() + ")].description",
|
||||
contains(app2.getDescription())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app2.getId() + ")].vendor", contains(app2.getVendor())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app2.getId() + ")].type",
|
||||
contains(Constants.SMT_DEFAULT_APP_KEY)))
|
||||
.andExpect(jsonPath("$.content", hasSize(2))).andExpect(jsonPath("$.total", equalTo(2)));
|
||||
|
||||
// by type and version=2.0.0 -> only one result
|
||||
mvc.perform(get("/rest/v1/softwaremodules?q=type==runtime;version==2.0.0").accept(MediaType.APPLICATION_JSON))
|
||||
mvc.perform(get(
|
||||
"/rest/v1/softwaremodules?q=type==" + Constants.SMT_DEFAULT_APP_KEY + ";version==" + app1.getVersion())
|
||||
.accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm1.getId() + ")].name", contains("runtimeName1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm1.getId() + ")].version", contains("2.0.0")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm1.getId() + ")].description", contains("description1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm1.getId() + ")].vendor", contains("vendor1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].name", contains(app1.getName())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].version", contains(app1.getVersion())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].description",
|
||||
contains(app1.getDescription())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].vendor", contains(app1.getVendor())))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].type",
|
||||
contains(Constants.SMT_DEFAULT_APP_KEY)))
|
||||
.andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1)));
|
||||
|
||||
// by type and version range >=2.0.0 -> 2 result
|
||||
mvc.perform(get("/rest/v1/softwaremodules?q=type==runtime;version=ge=2.0.0").accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm1.getId() + ")].name", contains("runtimeName1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm1.getId() + ")].version", contains("2.0.0")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm1.getId() + ")].description", contains("description1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm1.getId() + ")].vendor", contains("vendor1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm2.getId() + ")].name", contains("runtimeName2")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm2.getId() + ")].version", contains("2.0.1")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm2.getId() + ")].description", contains("description2")))
|
||||
.andExpect(jsonPath("$.content.[?(@.id==" + jvm2.getId() + ")].vendor", contains("vendor2")))
|
||||
.andExpect(jsonPath("$.content", hasSize(2))).andExpect(jsonPath("$.total", equalTo(2)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -693,16 +635,16 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Tests GET request on /rest/v1/softwaremodules/{smId}.")
|
||||
public void getSoftwareModule() throws Exception {
|
||||
SoftwareModule os = entityFactory.generateSoftwareModule(osType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
os = softwareManagement.createSoftwareModule(os);
|
||||
final SoftwareModule os = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}", os.getId()).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("$.name", equalTo("name1"))).andExpect(jsonPath("$.version", equalTo("version1")))
|
||||
.andExpect(jsonPath("$.description", equalTo("description1")))
|
||||
.andExpect(jsonPath("$.vendor", equalTo("vendor1"))).andExpect(jsonPath("$.type", equalTo("os")))
|
||||
.andExpect(jsonPath("$.name", equalTo(os.getName())))
|
||||
.andExpect(jsonPath("$.version", equalTo(os.getVersion())))
|
||||
.andExpect(jsonPath("$.description", equalTo(os.getDescription())))
|
||||
.andExpect(jsonPath("$.vendor", equalTo(os.getVendor())))
|
||||
.andExpect(jsonPath("$.type", equalTo(os.getType().getKey())))
|
||||
.andExpect(jsonPath("$.createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("$.createdAt", equalTo(os.getCreatedAt())))
|
||||
.andExpect(jsonPath("$._links.metadata.href",
|
||||
@@ -713,65 +655,19 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
.andExpect(jsonPath("$._links.artifacts.href",
|
||||
equalTo("http://localhost/rest/v1/softwaremodules/" + os.getId() + "/artifacts")));
|
||||
|
||||
SoftwareModule jvm = entityFactory.generateSoftwareModule(runtimeType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
jvm = softwareManagement.createSoftwareModule(jvm);
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}", jvm.getId()).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("$.name", equalTo("name1"))).andExpect(jsonPath("$.version", equalTo("version1")))
|
||||
.andExpect(jsonPath("$.description", equalTo("description1")))
|
||||
.andExpect(jsonPath("$.vendor", equalTo("vendor1"))).andExpect(jsonPath("$.type", equalTo("runtime")))
|
||||
.andExpect(jsonPath("$.createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("$.createdAt", equalTo(jvm.getCreatedAt())))
|
||||
.andExpect(jsonPath("$._links.metadata.href",
|
||||
equalTo("http://localhost/rest/v1/softwaremodules/" + jvm.getId()
|
||||
+ "/metadata?offset=0&limit=50")))
|
||||
.andExpect(jsonPath("$._links.type.href",
|
||||
equalTo("http://localhost/rest/v1/softwaremoduletypes/" + runtimeType.getId())))
|
||||
.andExpect(jsonPath("$._links.artifacts.href",
|
||||
equalTo("http://localhost/rest/v1/softwaremodules/" + jvm.getId() + "/artifacts")));
|
||||
|
||||
SoftwareModule ah = entityFactory.generateSoftwareModule(appType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
ah = softwareManagement.createSoftwareModule(ah);
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}", ah.getId()).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("$.name", equalTo("name1"))).andExpect(jsonPath("$.version", equalTo("version1")))
|
||||
.andExpect(jsonPath("$.description", equalTo("description1")))
|
||||
.andExpect(jsonPath("$.vendor", equalTo("vendor1")))
|
||||
.andExpect(jsonPath("$.type", equalTo("application")))
|
||||
.andExpect(jsonPath("$.createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("$.createdAt", equalTo(ah.getCreatedAt())))
|
||||
.andExpect(jsonPath("$._links.metadata.href",
|
||||
equalTo("http://localhost/rest/v1/softwaremodules/" + ah.getId()
|
||||
+ "/metadata?offset=0&limit=50")))
|
||||
.andExpect(jsonPath("$._links.type.href",
|
||||
equalTo("http://localhost/rest/v1/softwaremoduletypes/" + appType.getId())))
|
||||
.andExpect(jsonPath("$._links.artifacts.href",
|
||||
equalTo("http://localhost/rest/v1/softwaremodules/" + ah.getId() + "/artifacts")));
|
||||
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).as("Softwaremodule size is wrong").hasSize(3);
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).as("Softwaremodule size is wrong").hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Verfies that the create request actually results in the creation of the modules in the repository.")
|
||||
public void createSoftwareModules() throws JSONException, Exception {
|
||||
final SoftwareModule os = entityFactory.generateSoftwareModule(osType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
final SoftwareModule jvm = entityFactory.generateSoftwareModule(runtimeType, "name2", "version1",
|
||||
"description1", "vendor1");
|
||||
final SoftwareModule ah = entityFactory.generateSoftwareModule(appType, "name3", "version1", "description1",
|
||||
"vendor1");
|
||||
final SoftwareModule os = entityFactory.softwareModule().create().name("name1").type(osType).version("version1")
|
||||
.vendor("vendor1").description("description1").build();
|
||||
final SoftwareModule ah = entityFactory.softwareModule().create().name("name3").type(appType)
|
||||
.version("version3").vendor("vendor3").description("description3").build();
|
||||
|
||||
final List<SoftwareModule> modules = new ArrayList<>();
|
||||
modules.add(os);
|
||||
modules.add(jvm);
|
||||
modules.add(ah);
|
||||
final List<SoftwareModule> modules = Lists.newArrayList(os, ah);
|
||||
|
||||
final long current = System.currentTimeMillis();
|
||||
|
||||
@@ -785,25 +681,17 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
.andExpect(jsonPath("[0].description", equalTo("description1")))
|
||||
.andExpect(jsonPath("[0].vendor", equalTo("vendor1"))).andExpect(jsonPath("[0].type", equalTo("os")))
|
||||
.andExpect(jsonPath("[0].createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("[1].name", equalTo("name2")))
|
||||
.andExpect(jsonPath("[1].version", equalTo("version1")))
|
||||
.andExpect(jsonPath("[1].description", equalTo("description1")))
|
||||
.andExpect(jsonPath("[1].vendor", equalTo("vendor1")))
|
||||
.andExpect(jsonPath("[1].type", equalTo("runtime")))
|
||||
.andExpect(jsonPath("[1].name", equalTo("name3")))
|
||||
.andExpect(jsonPath("[1].version", equalTo("version3")))
|
||||
.andExpect(jsonPath("[1].description", equalTo("description3")))
|
||||
.andExpect(jsonPath("[1].vendor", equalTo("vendor3")))
|
||||
.andExpect(jsonPath("[1].type", equalTo("application")))
|
||||
.andExpect(jsonPath("[1].createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("[2].name", equalTo("name3")))
|
||||
.andExpect(jsonPath("[2].version", equalTo("version1")))
|
||||
.andExpect(jsonPath("[2].description", equalTo("description1")))
|
||||
.andExpect(jsonPath("[2].vendor", equalTo("vendor1")))
|
||||
.andExpect(jsonPath("[2].type", equalTo("application")))
|
||||
.andExpect(jsonPath("[2].createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("[2].createdAt", not(equalTo(0)))).andReturn();
|
||||
.andExpect(jsonPath("[1].createdAt", not(equalTo(0)))).andReturn();
|
||||
|
||||
final SoftwareModule osCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name1", "version1",
|
||||
osType);
|
||||
final SoftwareModule jvmCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name2", "version1",
|
||||
runtimeType);
|
||||
final SoftwareModule ahCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name3", "version1",
|
||||
final SoftwareModule appCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name3", "version3",
|
||||
appType);
|
||||
|
||||
assertThat(
|
||||
@@ -816,29 +704,19 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
|
||||
assertThat(
|
||||
JsonPath.compile("[1]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
.as("Response contains invalid self href")
|
||||
.isEqualTo("http://localhost/rest/v1/softwaremodules/" + jvmCreated.getId());
|
||||
assertThat(JsonPath.compile("[1]_links.artifacts.href").read(mvcResult.getResponse().getContentAsString())
|
||||
.toString()).as("Response contains invalid artfacts href")
|
||||
.isEqualTo("http://localhost/rest/v1/softwaremodules/" + jvmCreated.getId() + "/artifacts");
|
||||
|
||||
assertThat(
|
||||
JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
.as("Response contains links self href")
|
||||
.isEqualTo("http://localhost/rest/v1/softwaremodules/" + ahCreated.getId());
|
||||
assertThat(JsonPath.compile("[2]_links.artifacts.href").read(mvcResult.getResponse().getContentAsString())
|
||||
.isEqualTo("http://localhost/rest/v1/softwaremodules/" + appCreated.getId());
|
||||
assertThat(JsonPath.compile("[1]_links.artifacts.href").read(mvcResult.getResponse().getContentAsString())
|
||||
.toString()).as("Response contains invalid artifacts href")
|
||||
.isEqualTo("http://localhost/rest/v1/softwaremodules/" + ahCreated.getId() + "/artifacts");
|
||||
.isEqualTo("http://localhost/rest/v1/softwaremodules/" + appCreated.getId() + "/artifacts");
|
||||
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).as("Wrong softwaremodule size").hasSize(3);
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).as("Wrong softwaremodule size").hasSize(2);
|
||||
assertThat(softwareManagement.findSoftwareModulesByType(pageReq, osType.getId()).getContent().get(0).getName())
|
||||
.as("Softwaremoudle name is wrong").isEqualTo(os.getName());
|
||||
assertThat(softwareManagement.findSoftwareModulesByType(pageReq, osType.getId()).getContent().get(0)
|
||||
.getCreatedBy()).as("Softwaremoudle created by is wrong").isEqualTo("uploadTester");
|
||||
assertThat(softwareManagement.findSoftwareModulesByType(pageReq, osType.getId()).getContent().get(0)
|
||||
.getCreatedAt()).as("Softwaremoudle created at is wrong").isGreaterThanOrEqualTo(current);
|
||||
assertThat(softwareManagement.findSoftwareModulesByType(pageReq, runtimeType.getId()).getContent().get(0)
|
||||
.getName()).as("Softwaremoudle name is wrong").isEqualTo(jvm.getName());
|
||||
assertThat(softwareManagement.findSoftwareModulesByType(pageReq, appType.getId()).getContent().get(0).getName())
|
||||
.as("Softwaremoudle name is wrong").isEqualTo(ah.getName());
|
||||
}
|
||||
@@ -847,8 +725,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
@Description("Verifies successfull deletion of software modules that are not in use, i.e. assigned to a DS.")
|
||||
public void deleteUnassignedSoftwareModule() throws Exception {
|
||||
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
|
||||
@@ -895,8 +772,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
@Description("Tests the deletion of an artifact including verfication that the artifact is actually erased in the repository and removed from the software module.")
|
||||
public void deleteArtifact() throws Exception {
|
||||
// Create 1 SM
|
||||
SoftwareModule sm = entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
|
||||
@@ -933,8 +809,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownKey2 = "knownKey1";
|
||||
final String knownValue2 = "knownValue1";
|
||||
|
||||
final SoftwareModule sm = softwareManagement
|
||||
.createSoftwareModule(entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final JSONArray jsonArray = new JSONArray();
|
||||
jsonArray.put(new JSONObject().put("key", knownKey1).put("value", knownValue1));
|
||||
@@ -962,10 +837,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownValue = "knownValue";
|
||||
final String updateValue = "valueForUpdate";
|
||||
|
||||
final SoftwareModule sm = softwareManagement
|
||||
.createSoftwareModule(entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
softwareManagement
|
||||
.createSoftwareModuleMetadata(entityFactory.generateSoftwareModuleMetadata(sm, knownKey, knownValue));
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
softwareManagement.createSoftwareModuleMetadata(sm.getId(),
|
||||
entityFactory.generateMetadata(knownKey, knownValue));
|
||||
|
||||
final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue);
|
||||
|
||||
@@ -986,10 +860,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownKey = "knownKey";
|
||||
final String knownValue = "knownValue";
|
||||
|
||||
final SoftwareModule sm = softwareManagement
|
||||
.createSoftwareModule(entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
softwareManagement
|
||||
.createSoftwareModuleMetadata(entityFactory.generateSoftwareModuleMetadata(sm, knownKey, knownValue));
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
softwareManagement.createSoftwareModuleMetadata(sm.getId(),
|
||||
entityFactory.generateMetadata(knownKey, knownValue));
|
||||
|
||||
mvc.perform(delete("/rest/v1/softwaremodules/{swId}/metadata/{key}", sm.getId(), knownKey))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
@@ -1008,13 +881,11 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
final int totalMetadata = 10;
|
||||
final String knownKeyPrefix = "knownKey";
|
||||
final String knownValuePrefix = "knownValue";
|
||||
final SoftwareModule sm = softwareManagement
|
||||
.createSoftwareModule(entityFactory.generateSoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
for (int index = 0; index < totalMetadata; index++) {
|
||||
softwareManagement.createSoftwareModuleMetadata(
|
||||
entityFactory.generateSoftwareModuleMetadata(softwareManagement.findSoftwareModuleById(sm.getId()),
|
||||
knownKeyPrefix + index, knownValuePrefix + index));
|
||||
softwareManagement.createSoftwareModuleMetadata(sm.getId(),
|
||||
entityFactory.generateMetadata(knownKeyPrefix + index, knownValuePrefix + index));
|
||||
}
|
||||
|
||||
final String rsqlSearchValue1 = "value==knownValue1";
|
||||
@@ -1029,9 +900,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTest
|
||||
char character = 'a';
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String str = String.valueOf(character);
|
||||
final SoftwareModule softwareModule = entityFactory.generateSoftwareModule(osType, str, str, str, str);
|
||||
|
||||
softwareManagement.createSoftwareModule(softwareModule);
|
||||
softwareManagement.createSoftwareModule(entityFactory.softwareModule().create().type(osType).name(str)
|
||||
.description(str).vendor(str).version(str));
|
||||
character++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||
@@ -57,10 +56,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes GET requests.")
|
||||
public void getSoftwareModuleTypes() throws Exception {
|
||||
SoftwareModuleType testType = softwareManagement.createSoftwareModuleType(
|
||||
entityFactory.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = softwareManagement.updateSoftwareModuleType(testType);
|
||||
final SoftwareModuleType testType = createTestType();
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremoduletypes").accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -95,14 +91,19 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
.andExpect(jsonPath("$.total", equalTo(4)));
|
||||
}
|
||||
|
||||
private SoftwareModuleType createTestType() {
|
||||
SoftwareModuleType testType = softwareManagement.createSoftwareModuleType(entityFactory.softwareModuleType()
|
||||
.create().key("test123").name("TestName123").description("Desc123").maxAssignments(5));
|
||||
testType = softwareManagement.updateSoftwareModuleType(
|
||||
entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234"));
|
||||
return testType;
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes GET requests with sorting by MAXASSIGNMENTS field.")
|
||||
public void getSoftwareModuleTypesSortedByMaxAssignments() throws Exception {
|
||||
SoftwareModuleType testType = softwareManagement.createSoftwareModuleType(
|
||||
entityFactory.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = softwareManagement.updateSoftwareModuleType(testType);
|
||||
final SoftwareModuleType testType = createTestType();
|
||||
|
||||
// descending
|
||||
mvc.perform(get("/rest/v1/softwaremoduletypes").accept(MediaType.APPLICATION_JSON)
|
||||
@@ -143,14 +144,15 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
public void createSoftwareModuleTypesInvalidAssignmentBadRequest() throws JSONException, Exception {
|
||||
|
||||
final List<SoftwareModuleType> types = new ArrayList<>();
|
||||
types.add(entityFactory.generateSoftwareModuleType("test-1", "TestName-1", "Desc-1", -1));
|
||||
types.add(entityFactory.softwareModuleType().create().key("test-1").name("TestName-1").maxAssignments(-1)
|
||||
.build());
|
||||
|
||||
mvc.perform(post("/rest/v1/softwaremoduletypes/").content(JsonBuilder.softwareModuleTypes(types))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest());
|
||||
|
||||
types.clear();
|
||||
types.add(entityFactory.generateSoftwareModuleType("test0", "TestName0", "Desc0", 0));
|
||||
types.add(entityFactory.softwareModuleType().create().key("test0").name("TestName0").maxAssignments(0).build());
|
||||
|
||||
mvc.perform(post("/rest/v1/softwaremoduletypes/").content(JsonBuilder.softwareModuleTypes(types))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
@@ -162,10 +164,13 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes POST requests.")
|
||||
public void createSoftwareModuleTypes() throws JSONException, Exception {
|
||||
|
||||
final List<SoftwareModuleType> types = new ArrayList<>();
|
||||
types.add(entityFactory.generateSoftwareModuleType("test1", "TestName1", "Desc1", 1));
|
||||
types.add(entityFactory.generateSoftwareModuleType("test2", "TestName2", "Desc2", 2));
|
||||
types.add(entityFactory.generateSoftwareModuleType("test3", "TestName3", "Desc3", 3));
|
||||
final List<SoftwareModuleType> types = Lists.newArrayList(
|
||||
entityFactory.softwareModuleType().create().key("test1").name("TestName1").description("Desc1")
|
||||
.colour("col1‚").maxAssignments(1).build(),
|
||||
entityFactory.softwareModuleType().create().key("test2").name("TestName2").description("Desc2")
|
||||
.colour("col2‚").maxAssignments(2).build(),
|
||||
entityFactory.softwareModuleType().create().key("test3").name("TestName3").description("Desc3")
|
||||
.colour("col3‚").maxAssignments(3).build());
|
||||
|
||||
final MvcResult mvcResult = mvc
|
||||
.perform(post("/rest/v1/softwaremoduletypes/").content(JsonBuilder.softwareModuleTypes(types))
|
||||
@@ -207,10 +212,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} GET requests.")
|
||||
public void getSoftwareModuleType() throws Exception {
|
||||
SoftwareModuleType testType = softwareManagement.createSoftwareModuleType(
|
||||
entityFactory.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = softwareManagement.updateSoftwareModuleType(testType);
|
||||
final SoftwareModuleType testType = createTestType();
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremoduletypes/{smtId}", testType.getId()).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -228,8 +230,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} DELETE requests (hard delete scenario).")
|
||||
public void deleteSoftwareModuleTypeUnused() throws Exception {
|
||||
final SoftwareModuleType testType = softwareManagement.createSoftwareModuleType(
|
||||
entityFactory.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
final SoftwareModuleType testType = createTestType();
|
||||
|
||||
assertThat(softwareManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
|
||||
|
||||
@@ -243,10 +244,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} DELETE requests (soft delete scenario).")
|
||||
public void deleteSoftwareModuleTypeUsed() throws Exception {
|
||||
final SoftwareModuleType testType = softwareManagement.createSoftwareModuleType(
|
||||
entityFactory.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
final SoftwareModuleType testType = createTestType();
|
||||
softwareManagement.createSoftwareModule(
|
||||
entityFactory.generateSoftwareModule(testType, "name", "version", "description", "vendor"));
|
||||
entityFactory.softwareModule().create().type(testType).name("name").version("version"));
|
||||
|
||||
assertThat(softwareManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
|
||||
|
||||
@@ -259,8 +259,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Test
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} PUT requests.")
|
||||
public void updateSoftwareModuleTypeOnlyDescriptionAndNameUntouched() throws Exception {
|
||||
final SoftwareModuleType testType = softwareManagement.createSoftwareModuleType(
|
||||
entityFactory.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
final SoftwareModuleType testType = createTestType();
|
||||
|
||||
final String body = new JSONObject().put("id", testType.getId()).put("description", "foobardesc")
|
||||
.put("name", "nameShouldNotBeChanged").toString();
|
||||
@@ -315,8 +314,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Test
|
||||
@Description("Ensures that the server is behaving as expected on invalid requests (wrong media type, wrong ID etc.).")
|
||||
public void invalidRequestsOnSoftwaremoduleTypesResource() throws Exception {
|
||||
final SoftwareModuleType testType = softwareManagement.createSoftwareModuleType(
|
||||
entityFactory.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
final SoftwareModuleType testType = createTestType();
|
||||
|
||||
final List<SoftwareModuleType> types = Lists.newArrayList(testType);
|
||||
|
||||
@@ -342,8 +340,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
final SoftwareModuleType toLongName = entityFactory.generateSoftwareModuleType("test123",
|
||||
RandomStringUtils.randomAscii(80), "Desc123", 5);
|
||||
final SoftwareModuleType toLongName = entityFactory.softwareModuleType().create().key("test123")
|
||||
.name(RandomStringUtils.randomAscii(80)).build();
|
||||
mvc.perform(post("/rest/v1/softwaremoduletypes")
|
||||
.content(JsonBuilder.softwareModuleTypes(Lists.newArrayList(toLongName)))
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
@@ -366,10 +364,10 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Test
|
||||
@Description("Search erquest of software module types.")
|
||||
public void searchSoftwareModuleTypeRsql() throws Exception {
|
||||
final SoftwareModuleType testType = softwareManagement.createSoftwareModuleType(
|
||||
entityFactory.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
final SoftwareModuleType testType2 = softwareManagement.createSoftwareModuleType(
|
||||
entityFactory.generateSoftwareModuleType("test1234", "TestName1234", "Desc123", 5));
|
||||
softwareManagement.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("test123")
|
||||
.name("TestName123").description("Desc123").maxAssignments(5));
|
||||
softwareManagement.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("test1234")
|
||||
.name("TestName1234").description("Desc1234").maxAssignments(5));
|
||||
|
||||
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
|
||||
|
||||
@@ -384,9 +382,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
char character = 'a';
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String str = String.valueOf(character);
|
||||
final SoftwareModule softwareModule = entityFactory.generateSoftwareModule(osType, str, str, str, str);
|
||||
|
||||
softwareManagement.createSoftwareModule(softwareModule);
|
||||
softwareManagement.createSoftwareModule(entityFactory.softwareModule().create().type(osType).name(str)
|
||||
.description(str).vendor(str).version(str));
|
||||
character++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,10 +128,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractRestIntegrationTe
|
||||
final String body = new JSONObject().put("name", filterName2).toString();
|
||||
|
||||
// prepare
|
||||
TargetFilterQuery tfq = entityFactory.generateTargetFilterQuery();
|
||||
tfq.setName(filterName);
|
||||
tfq.setQuery(filterQuery);
|
||||
tfq = targetFilterQueryManagement.createTargetFilterQuery(tfq);
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query(filterQuery));
|
||||
|
||||
mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId()).content(body)
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -319,11 +317,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractRestIntegrationTe
|
||||
final String dsName = "testDS";
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet(dsName);
|
||||
TargetFilterQuery tfq = entityFactory.generateTargetFilterQuery();
|
||||
tfq.setName(knownName);
|
||||
tfq.setQuery(knownQuery);
|
||||
tfq.setAutoAssignDistributionSet(set);
|
||||
tfq = targetFilterQueryManagement.createTargetFilterQuery(tfq);
|
||||
final TargetFilterQuery tfq = createSingleTargetFilterQuery(knownName, knownQuery);
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(tfq.getId(), set.getId());
|
||||
|
||||
assertThat(targetFilterQueryManagement.findTargetFilterQueryById(tfq.getId()).getAutoAssignDistributionSet())
|
||||
.isEqualTo(set);
|
||||
@@ -343,10 +338,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractRestIntegrationTe
|
||||
}
|
||||
|
||||
private TargetFilterQuery createSingleTargetFilterQuery(final String name, final String query) {
|
||||
final TargetFilterQuery target = entityFactory.generateTargetFilterQuery();
|
||||
target.setName(name);
|
||||
target.setQuery(query);
|
||||
return targetFilterQueryManagement.createTargetFilterQuery(target);
|
||||
return targetFilterQueryManagement
|
||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name(name).query(query));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.rest.resource;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
@@ -25,7 +24,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -39,8 +37,6 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.ActionFields;
|
||||
import org.eclipse.hawkbit.repository.exception.ConstraintViolationException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetInfo;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
@@ -111,9 +107,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final int limitSize = 2;
|
||||
final String knownTargetId = "targetId";
|
||||
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
|
||||
actions.get(0).setStatus(Status.FINISHED);
|
||||
controllerManagament.addUpdateActionStatus(entityFactory.generateActionStatus(actions.get(0), Status.FINISHED,
|
||||
System.currentTimeMillis(), "testmessage"));
|
||||
controllerManagament.addUpdateActionStatus(
|
||||
entityFactory.actionStatus().create(actions.get(0).getId()).status(Status.FINISHED).message("test"));
|
||||
|
||||
final PageRequest pageRequest = new PageRequest(0, 1000, Direction.ASC, ActionFields.ID.getFieldName());
|
||||
final ActionStatus status = deploymentManagement
|
||||
@@ -142,7 +137,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
public void securityTokenIsNotInResponseIfMissingPermission() throws Exception {
|
||||
|
||||
final String knownControllerId = "knownControllerId";
|
||||
targetManagement.createTarget(entityFactory.generateTarget(knownControllerId));
|
||||
testdataFactory.createTarget(knownControllerId);
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("securityToken").doesNotExist());
|
||||
@@ -155,7 +150,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
public void securityTokenIsInResponseWithCorrectPermission() throws Exception {
|
||||
|
||||
final String knownControllerId = "knownControllerId";
|
||||
final Target createTarget = targetManagement.createTarget(entityFactory.generateTarget(knownControllerId));
|
||||
final Target createTarget = testdataFactory.createTarget(knownControllerId);
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("securityToken", equalTo(createTarget.getSecurityToken())));
|
||||
@@ -186,11 +181,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
}
|
||||
|
||||
private void createTarget(final String controllerId) {
|
||||
final JpaTarget target = (JpaTarget) entityFactory.generateTarget(controllerId);
|
||||
final JpaTargetInfo targetInfo = new JpaTargetInfo(target);
|
||||
targetInfo.setAddress(IpUtil.createHttpUri("127.0.0.1").toString());
|
||||
target.setTargetInfo(targetInfo);
|
||||
targetManagement.createTarget(target);
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId(controllerId)
|
||||
.address(IpUtil.createHttpUri("127.0.0.1").toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -199,9 +191,9 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
|
||||
// prepare test
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
final Target createTarget = targetManagement.createTarget(entityFactory.generateTarget("knownTargetId"));
|
||||
final Target createTarget = testdataFactory.createTarget("knownTargetId");
|
||||
|
||||
deploymentManagement.assignDistributionSet(dsA, Lists.newArrayList(createTarget));
|
||||
assignDistributionSet(dsA, Lists.newArrayList(createTarget));
|
||||
|
||||
final String rsqlPendingStatus = "status==pending";
|
||||
final String rsqlFinishedStatus = "status==finished";
|
||||
@@ -279,8 +271,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
deploymentManagement.cancelAction(tA.getActions().get(0), tA);
|
||||
|
||||
// find the current active action
|
||||
final List<Action> cancelActions = deploymentManagement.findActionsByTarget(new PageRequest(0, 100), tA)
|
||||
.getContent().stream().filter(action -> action.isCancelingOrCanceled()).collect(Collectors.toList());
|
||||
final List<Action> cancelActions = deploymentManagement.findActionsByTarget(pageReq, tA).getContent().stream()
|
||||
.filter(Action::isCancelingOrCanceled).collect(Collectors.toList());
|
||||
assertThat(cancelActions).hasSize(1);
|
||||
assertThat(cancelActions.get(0).isCancelingOrCanceled()).isTrue();
|
||||
|
||||
@@ -306,7 +298,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
@Description("Ensures that deletion is executed if permitted.")
|
||||
public void deleteTargetReturnsOK() throws Exception {
|
||||
final String knownControllerId = "knownControllerIdDelete";
|
||||
targetManagement.createTarget(entityFactory.generateTarget(knownControllerId));
|
||||
testdataFactory.createTarget(knownControllerId);
|
||||
|
||||
mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId))
|
||||
.andExpect(status().isOk());
|
||||
@@ -342,10 +334,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final String body = new JSONObject().put("description", knownNewDescription).toString();
|
||||
|
||||
// prepare
|
||||
final Target t = entityFactory.generateTarget(knownControllerId);
|
||||
t.setDescription("old description");
|
||||
t.setName(knownNameNotModiy);
|
||||
targetManagement.createTarget(t);
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId(knownControllerId)
|
||||
.name(knownNameNotModiy).description("old description"));
|
||||
|
||||
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -367,9 +357,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final String body = new JSONObject().put("securityToken", knownNewToken).toString();
|
||||
|
||||
// prepare
|
||||
final Target t = entityFactory.generateTarget(knownControllerId);
|
||||
t.setName(knownNameNotModiy);
|
||||
targetManagement.createTarget(t);
|
||||
targetManagement
|
||||
.createTarget(entityFactory.target().create().controllerId(knownControllerId).name(knownNameNotModiy));
|
||||
|
||||
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -391,9 +380,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final String body = new JSONObject().put("address", knownNewAddress).toString();
|
||||
|
||||
// prepare
|
||||
final Target t = entityFactory.generateTarget(knownControllerId);
|
||||
t.setName(knownNameNotModiy);
|
||||
targetManagement.createTarget(t);
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId(knownControllerId)
|
||||
.name(knownNameNotModiy).address(knownNewAddress));
|
||||
|
||||
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -578,7 +566,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final String knownName = "someName";
|
||||
createSingleTarget(knownControllerId, knownName);
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
||||
deploymentManagement.assignDistributionSet(ds.getId(), knownControllerId);
|
||||
assignDistributionSet(ds.getId(), knownControllerId);
|
||||
|
||||
// test
|
||||
|
||||
@@ -674,12 +662,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
@Description("Verfies that a mandatory properties of new targets are validated as not null.")
|
||||
public void createTargetWithMissingMandatoryPropertyBadRequest() throws Exception {
|
||||
final Target test1 = entityFactory.generateTarget("id1", "token");
|
||||
test1.setName(null);
|
||||
|
||||
final MvcResult mvcResult = mvc
|
||||
.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)
|
||||
.content(JsonBuilder.targets(Lists.newArrayList(test1), true))
|
||||
.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content("[{\"name\":\"id1\"}]")
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
|
||||
|
||||
@@ -695,13 +679,11 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
@Description("Verfies that a properties of new targets are validated as in allowed size range.")
|
||||
public void createTargetWithInvalidPropertyBadRequest() throws Exception {
|
||||
final Target test1 = entityFactory.generateTarget("id1", "token");
|
||||
test1.setName(RandomStringUtils.randomAscii(80));
|
||||
final Target test1 = entityFactory.target().create().controllerId("id1").name(RandomStringUtils.randomAscii(80))
|
||||
.build();
|
||||
|
||||
final MvcResult mvcResult = mvc
|
||||
.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)
|
||||
.content(JsonBuilder.targets(Lists.newArrayList(test1), true))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
final MvcResult mvcResult = mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)
|
||||
.content(JsonBuilder.targets(Lists.newArrayList(test1), true)).contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
|
||||
|
||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
|
||||
@@ -715,21 +697,14 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void createTargetsListReturnsSuccessful() throws Exception {
|
||||
final Target test1 = entityFactory.generateTarget("id1", "token");
|
||||
test1.setDescription("testid1");
|
||||
test1.setName("testname1");
|
||||
test1.getTargetInfo().setAddress("amqp://test123/foobar");
|
||||
final Target test2 = entityFactory.generateTarget("id2");
|
||||
test2.setDescription("testid2");
|
||||
test2.setName("testname2");
|
||||
final Target test3 = entityFactory.generateTarget("id3");
|
||||
test3.setName("testname3");
|
||||
test3.setDescription("testid3");
|
||||
final Target test1 = entityFactory.target().create().controllerId("id1").name("testname1")
|
||||
.securityToken("token").address("amqp://test123/foobar").description("testid1").build();
|
||||
final Target test2 = entityFactory.target().create().controllerId("id2").name("testname2")
|
||||
.description("testid2").build();
|
||||
final Target test3 = entityFactory.target().create().controllerId("id3").name("testname3")
|
||||
.description("testid3").build();
|
||||
|
||||
final List<Target> targets = new ArrayList<>();
|
||||
targets.add(test1);
|
||||
targets.add(test2);
|
||||
targets.add(test3);
|
||||
final List<Target> targets = Lists.newArrayList(test1, test2, test3);
|
||||
|
||||
final MvcResult mvcResult = mvc
|
||||
.perform(post("/rest/v1/targets/").content(JsonBuilder.targets(targets, true))
|
||||
@@ -850,8 +825,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
public void getActionWithEmptyResult() throws Exception {
|
||||
final String knownTargetId = "targetId";
|
||||
final Target target = entityFactory.generateTarget(knownTargetId);
|
||||
targetManagement.createTarget(target);
|
||||
final Target target = testdataFactory.createTarget(knownTargetId);
|
||||
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/"
|
||||
+ MgmtRestConstants.TARGET_V1_ACTIONS)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -1063,22 +1037,19 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
private List<Action> generateTargetWithTwoUpdatesWithOneOverride(final String knownTargetId)
|
||||
throws InterruptedException {
|
||||
|
||||
Target target = entityFactory.generateTarget(knownTargetId);
|
||||
target = targetManagement.createTarget(target);
|
||||
final List<Target> targets = new ArrayList<>();
|
||||
targets.add(target);
|
||||
final Target target = testdataFactory.createTarget(knownTargetId);
|
||||
final List<Target> targets = Lists.newArrayList(target);
|
||||
|
||||
final Iterator<DistributionSet> sets = testdataFactory.createDistributionSets(2).iterator();
|
||||
final DistributionSet one = sets.next();
|
||||
final DistributionSet two = sets.next();
|
||||
|
||||
// Update
|
||||
final List<Target> updatedTargets = deploymentManagement.assignDistributionSet(one, targets)
|
||||
.getAssignedEntity();
|
||||
final List<Target> updatedTargets = assignDistributionSet(one, targets).getAssignedEntity();
|
||||
// 2nd update
|
||||
// sleep 10ms to ensure that we can sort by reportedAt
|
||||
Thread.sleep(10);
|
||||
deploymentManagement.assignDistributionSet(two, updatedTargets);
|
||||
assignDistributionSet(two, updatedTargets);
|
||||
|
||||
// two updates, one cancellation
|
||||
final List<Action> actions = deploymentManagement.findActionsByTarget(target);
|
||||
@@ -1108,7 +1079,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
public void assignDistributionSetToTarget() throws Exception {
|
||||
|
||||
targetManagement.createTarget(entityFactory.generateTarget("fsdfsd"));
|
||||
testdataFactory.createTarget("fsdfsd");
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
|
||||
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS")
|
||||
@@ -1121,7 +1092,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
public void assignDistributionSetToTargetWithActionTimeForcedAndTime() throws Exception {
|
||||
|
||||
final Target target = targetManagement.createTarget(entityFactory.generateTarget("fsdfsd"));
|
||||
final Target target = testdataFactory.createTarget("fsdfsd");
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
|
||||
final long forceTime = System.currentTimeMillis();
|
||||
@@ -1148,7 +1119,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
||||
|
||||
targetManagement.createTarget(entityFactory.generateTarget("fsdfsd"));
|
||||
testdataFactory.createTarget("fsdfsd");
|
||||
|
||||
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS")
|
||||
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON))
|
||||
@@ -1238,8 +1209,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final Map<String, String> knownControllerAttrs = new HashMap<>();
|
||||
knownControllerAttrs.put("a", "1");
|
||||
knownControllerAttrs.put("b", "2");
|
||||
final Target target = entityFactory.generateTarget(knownTargetId);
|
||||
targetManagement.createTarget(target);
|
||||
final Target target = testdataFactory.createTarget(knownTargetId);
|
||||
controllerManagament.updateControllerAttributes(knownTargetId, knownControllerAttrs);
|
||||
|
||||
// test query target over rest resource
|
||||
@@ -1252,8 +1222,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
public void getControllerEmptyAttributesReturnsNoContent() throws Exception {
|
||||
// create target with attributes
|
||||
final String knownTargetId = "targetIdWithAttributes";
|
||||
final Target target = entityFactory.generateTarget(knownTargetId);
|
||||
targetManagement.createTarget(target);
|
||||
final Target target = testdataFactory.createTarget(knownTargetId);
|
||||
|
||||
// test query target over rest resource
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/attributes"))
|
||||
@@ -1286,10 +1255,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
}
|
||||
|
||||
private Target createSingleTarget(final String controllerId, final String name) {
|
||||
final Target target = entityFactory.generateTarget(controllerId);
|
||||
target.setName(name);
|
||||
target.setDescription(TARGET_DESCRIPTION_TEST);
|
||||
targetManagement.createTarget(target);
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId(controllerId).name(name)
|
||||
.description(TARGET_DESCRIPTION_TEST));
|
||||
return controllerManagament.updateLastTargetQuery(controllerId, null);
|
||||
}
|
||||
|
||||
@@ -1304,10 +1271,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
char character = 'a';
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String str = String.valueOf(character);
|
||||
final Target target = entityFactory.generateTarget(str);
|
||||
target.setName(str);
|
||||
target.setDescription(str);
|
||||
targetManagement.createTarget(target);
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId(str).name(str).description(str));
|
||||
controllerManagament.updateLastTargetQuery(str, null);
|
||||
character++;
|
||||
}
|
||||
@@ -1318,10 +1282,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
*
|
||||
*/
|
||||
private void feedbackToByInSync(final Long actionId) {
|
||||
final Action action = deploymentManagement.findAction(actionId);
|
||||
|
||||
final ActionStatus actionStatus = entityFactory.generateActionStatus(action, Status.FINISHED, 0L);
|
||||
controllerManagement.addUpdateActionStatus(actionStatus);
|
||||
controllerManagement
|
||||
.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Status.FINISHED));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1332,10 +1294,9 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
private Target createTargetAndStartAction() {
|
||||
// prepare test
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
final Target tA = targetManagement
|
||||
.createTarget(testdataFactory.generateTarget("target-id-A", "first description"));
|
||||
final Target tA = testdataFactory.createTarget("target-id-A");
|
||||
// assign a distribution set so we get an active update action
|
||||
deploymentManagement.assignDistributionSet(dsA, newArrayList(tA));
|
||||
assignDistributionSet(dsA, Lists.newArrayList(tA));
|
||||
// verify active action
|
||||
final Slice<Action> actionsByTarget = deploymentManagement.findActionsByTarget(new PageRequest(0, 100), tA);
|
||||
assertThat(actionsByTarget.getContent()).hasSize(1);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
|
||||
#logging.level.org.eclipse.hawkbit.rest.util.MockMvcResultPrinter=DEBUG
|
||||
logging.level.=INFO
|
||||
logging.level.org.eclipse.persistence=ERROR
|
||||
|
||||
|
||||
Reference in New Issue
Block a user