Worked on the interfaces and documentation.
Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -30,10 +30,10 @@ import org.eclipse.hawkbit.TestDataUtil;
|
||||
import org.eclipse.hawkbit.WithUser;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.DsMetadataCompositeKey;
|
||||
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.DsMetadataCompositeKey;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||
@@ -76,7 +76,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final DistributionSet disSet = TestDataUtil.generateDistributionSetWithNoSoftwareModules("Eris", "560a",
|
||||
distributionSetManagement);
|
||||
final List<Long> smIDs = new ArrayList<Long>();
|
||||
SoftwareModule sm = new SoftwareModule(osType, "Dysnomia ", "15,772", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "Dysnomia ", "15,772", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
smIDs.add(sm.getId());
|
||||
final JSONArray smList = new JSONArray();
|
||||
@@ -92,7 +92,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String[] knownTargetIds = new String[] { "1", "2" };
|
||||
final JSONArray list = new JSONArray();
|
||||
for (final String targetId : knownTargetIds) {
|
||||
targetManagement.createTarget(new Target(targetId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(targetId));
|
||||
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
|
||||
}
|
||||
deploymentManagement.assignDistributionSet(disSet.getId(), knownTargetIds[0]);
|
||||
@@ -120,7 +120,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final DistributionSet disSet = TestDataUtil.generateDistributionSetWithNoSoftwareModules("Mars", "686,980",
|
||||
distributionSetManagement);
|
||||
final List<Long> smIDs = new ArrayList<>();
|
||||
SoftwareModule sm = new SoftwareModule(osType, "Phobos", "0,3189", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "Phobos", "0,3189", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
smIDs.add(sm.getId());
|
||||
final JSONArray smList = new JSONArray();
|
||||
@@ -136,7 +136,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String[] knownTargetIds = new String[] { "1", "2" };
|
||||
final JSONArray list = new JSONArray();
|
||||
for (final String targetId : knownTargetIds) {
|
||||
targetManagement.createTarget(new Target(targetId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(targetId));
|
||||
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
|
||||
}
|
||||
// assign DisSet to target and test assignment
|
||||
@@ -150,8 +150,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.andExpect(jsonPath("$.total", equalTo(knownTargetIds.length)));
|
||||
|
||||
// Create another SM and post assignment
|
||||
final List<Long> smID2s = new ArrayList<Long>();
|
||||
SoftwareModule sm2 = new SoftwareModule(appType, "Deimos", "1,262", null, null);
|
||||
final List<Long> smID2s = new ArrayList<>();
|
||||
SoftwareModule sm2 = softwareManagement.generateSoftwareModule(appType, "Deimos", "1,262", null, null);
|
||||
sm2 = softwareManagement.createSoftwareModule(sm2);
|
||||
smID2s.add(sm2.getId());
|
||||
final JSONArray smList2 = new JSONArray();
|
||||
@@ -178,13 +178,13 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.andExpect(jsonPath("$.size", equalTo(disSet.getModules().size())));
|
||||
// create Software Modules
|
||||
final List<Long> smIDs = new ArrayList<Long>();
|
||||
SoftwareModule sm = new SoftwareModule(osType, "Europa", "3,551", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "Europa", "3,551", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
smIDs.add(sm.getId());
|
||||
SoftwareModule sm2 = new SoftwareModule(appType, "Ganymed", "7,155", null, null);
|
||||
SoftwareModule sm2 = softwareManagement.generateSoftwareModule(appType, "Ganymed", "7,155", null, null);
|
||||
sm2 = softwareManagement.createSoftwareModule(sm2);
|
||||
smIDs.add(sm2.getId());
|
||||
SoftwareModule sm3 = new SoftwareModule(runtimeType, "Kallisto", "16,689", null, null);
|
||||
SoftwareModule sm3 = softwareManagement.generateSoftwareModule(runtimeType, "Kallisto", "16,689", null, null);
|
||||
sm3 = softwareManagement.createSoftwareModule(sm3);
|
||||
smIDs.add(sm3.getId());
|
||||
final JSONArray list = new JSONArray();
|
||||
@@ -234,7 +234,7 @@ 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(new Target(targetId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(targetId));
|
||||
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
|
||||
}
|
||||
// assign already one target to DS
|
||||
@@ -258,7 +258,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownTargetId = "knownTargetId1";
|
||||
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
|
||||
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
|
||||
targetManagement.createTarget(new Target(knownTargetId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(knownTargetId));
|
||||
deploymentManagement.assignDistributionSet(createdDs.getId(), knownTargetId);
|
||||
|
||||
mvc.perform(get(
|
||||
@@ -285,10 +285,10 @@ 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(new Target(knownTargetId));
|
||||
final Target createTarget = targetManagement.createTarget(targetManagement.generateTarget(knownTargetId));
|
||||
// create some dummy targets which are not assigned or installed
|
||||
targetManagement.createTarget(new Target("dummy1"));
|
||||
targetManagement.createTarget(new Target("dummy2"));
|
||||
targetManagement.createTarget(targetManagement.generateTarget("dummy1"));
|
||||
targetManagement.createTarget(targetManagement.generateTarget("dummy2"));
|
||||
// assign knownTargetId to distribution set
|
||||
deploymentManagement.assignDistributionSet(createdDs.getId(), knownTargetId);
|
||||
// make it in install state
|
||||
@@ -348,7 +348,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
@Description("Ensures that multiple DS requested are listed with expected payload.")
|
||||
public void getDistributionSets() throws Exception {
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(0);
|
||||
|
||||
DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
@@ -361,7 +362,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
// load also lazy stuff
|
||||
set = distributionSetManagement.findDistributionSetByIdWithDetails(set.getId());
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(1);
|
||||
|
||||
// perform request
|
||||
mvc.perform(get("/rest/v1/distributionsets").accept(MediaType.APPLICATION_JSON))
|
||||
@@ -425,14 +427,15 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Ensures that multipe DS posted to API are created in the repository.")
|
||||
public void createDistributionSets() throws JSONException, Exception {
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(0);
|
||||
|
||||
final SoftwareModule ah = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||
final SoftwareModule jvm = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
|
||||
final SoftwareModule ah = softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||
final SoftwareModule jvm = softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
|
||||
final SoftwareModule os = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", null, ""));
|
||||
.createSoftwareModule(softwareManagement.generateSoftwareModule(osType, "poky", "3.0.2", null, ""));
|
||||
|
||||
DistributionSet one = TestDataUtil.buildDistributionSet("one", "one", standardDsType, os, jvm, ah);
|
||||
DistributionSet two = TestDataUtil.buildDistributionSet("two", "two", standardDsType, os, jvm, ah);
|
||||
@@ -527,7 +530,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.isEqualTo(String.valueOf(three.getId()));
|
||||
|
||||
// check in database
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(3);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(3);
|
||||
assertThat(one.isRequiredMigrationStep()).isEqualTo(false);
|
||||
assertThat(two.isRequiredMigrationStep()).isEqualTo(false);
|
||||
assertThat(three.isRequiredMigrationStep()).isEqualTo(true);
|
||||
@@ -541,19 +545,22 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
@Description("Ensures that DS deletion request to API is reflected by the repository.")
|
||||
public void deleteUnassignedistributionSet() throws Exception {
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(0);
|
||||
|
||||
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(1);
|
||||
|
||||
// perform request
|
||||
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk());
|
||||
|
||||
// check repository content
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).isEmpty();
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.isEmpty();
|
||||
assertThat(distributionSetRepository.findAll()).isEmpty();
|
||||
}
|
||||
|
||||
@@ -561,22 +568,26 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
@Description("Ensures that assigned DS deletion request to API is reflected by the repository by means of deleted flag set.")
|
||||
public void deleteAssignedDistributionSet() throws Exception {
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(0);
|
||||
|
||||
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
targetManagement.createTarget(new Target("test"));
|
||||
targetManagement.createTarget(targetManagement.generateTarget("test"));
|
||||
deploymentManagement.assignDistributionSet(set.getId(), "test");
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(1);
|
||||
|
||||
// perform request
|
||||
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk());
|
||||
|
||||
// check repository content
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, true, true)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, true, true))
|
||||
.hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -584,14 +595,16 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
public void updateDistributionSet() throws Exception {
|
||||
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(0);
|
||||
|
||||
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(1);
|
||||
|
||||
final DistributionSet update = new DistributionSet();
|
||||
final DistributionSet update = distributionSetManagement.generateDistributionSet();
|
||||
update.setVersion("anotherVersion");
|
||||
update.setName(null);
|
||||
update.setType(standardDsType);
|
||||
@@ -600,11 +613,10 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true).getContent().get(0)
|
||||
.getVersion()).isEqualTo("anotherVersion");
|
||||
assertThat(
|
||||
distributionSetManagement.findDistributionSetsAll(pageReq, false, true).getContent().get(0).getName())
|
||||
.isEqualTo(set.getName());
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true)
|
||||
.getContent().get(0).getVersion()).isEqualTo("anotherVersion");
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true)
|
||||
.getContent().get(0).getName()).isEqualTo(set.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -692,8 +704,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
|
||||
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
distributionSetManagement
|
||||
.createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, knownValue));
|
||||
distributionSetManagement.createDistributionSetMetadata(
|
||||
distributionSetManagement.generateDistributionSetMetadata(testDS, knownKey, knownValue));
|
||||
|
||||
final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue);
|
||||
|
||||
@@ -718,8 +730,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
|
||||
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
distributionSetManagement
|
||||
.createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, knownValue));
|
||||
distributionSetManagement.createDistributionSetMetadata(
|
||||
distributionSetManagement.generateDistributionSetMetadata(testDS, knownKey, knownValue));
|
||||
|
||||
mvc.perform(delete("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
@@ -740,8 +752,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownValue = "knownValue";
|
||||
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
distributionSetManagement
|
||||
.createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, knownValue));
|
||||
distributionSetManagement.createDistributionSetMetadata(
|
||||
distributionSetManagement.generateDistributionSetMetadata(testDS, knownKey, knownValue));
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -760,8 +772,9 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
for (int index = 0; index < totalMetadata; index++) {
|
||||
distributionSetManagement.createDistributionSetMetadata(new DistributionSetMetadata(knownKeyPrefix + index,
|
||||
distributionSetManagement.findDistributionSetById(testDS.getId()), knownValuePrefix + index));
|
||||
distributionSetManagement.createDistributionSetMetadata(distributionSetManagement
|
||||
.generateDistributionSetMetadata(distributionSetManagement.findDistributionSetById(testDS.getId()),
|
||||
knownKeyPrefix + index, knownValuePrefix + index));
|
||||
}
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsets/{dsId}/metadata?offset=" + offsetParam + "&limit=" + limitParam,
|
||||
@@ -795,8 +808,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
public void filterDistributionSetComplete() throws Exception {
|
||||
final int amount = 10;
|
||||
TestDataUtil.generateDistributionSets(amount, softwareManagement, distributionSetManagement);
|
||||
distributionSetManagement.createDistributionSet(new DistributionSet("incomplete", "2", "incomplete",
|
||||
distributionSetManagement.findDistributionSetTypeByKey("ecl_os"), null));
|
||||
distributionSetManagement.createDistributionSet(distributionSetManagement.generateDistributionSet("incomplete",
|
||||
"2", "incomplete", distributionSetManagement.findDistributionSetTypeByKey("ecl_os"), null));
|
||||
|
||||
final String rsqlFindLikeDs1OrDs2 = "complete==" + Boolean.TRUE;
|
||||
|
||||
@@ -815,7 +828,7 @@ 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(new Target(targetId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(targetId));
|
||||
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
|
||||
}
|
||||
|
||||
@@ -840,8 +853,9 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
for (int index = 0; index < totalMetadata; index++) {
|
||||
distributionSetManagement.createDistributionSetMetadata(new DistributionSetMetadata(knownKeyPrefix + index,
|
||||
distributionSetManagement.findDistributionSetById(testDS.getId()), knownValuePrefix + index));
|
||||
distributionSetManagement.createDistributionSetMetadata(distributionSetManagement
|
||||
.generateDistributionSetMetadata(distributionSetManagement.findDistributionSetById(testDS.getId()),
|
||||
knownKeyPrefix + index, knownValuePrefix + index));
|
||||
}
|
||||
|
||||
final String rsqlSearchValue1 = "value==knownValue1";
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.WithUser;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
@@ -58,8 +57,8 @@ 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(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = distributionSetManagement.updateDistributionSetType(testType);
|
||||
|
||||
@@ -96,8 +95,8 @@ 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(new DistributionSetType("zzzzz", "TestName123", "Desc123"));
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("zzzzz", "TestName123", "Desc123"));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = distributionSetManagement.updateDistributionSetType(testType);
|
||||
|
||||
@@ -136,12 +135,12 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(3);
|
||||
|
||||
final List<DistributionSetType> types = new ArrayList<>();
|
||||
types.add(new DistributionSetType("test1", "TestName1", "Desc1").addMandatoryModuleType(osType)
|
||||
.addOptionalModuleType(runtimeType));
|
||||
types.add(new DistributionSetType("test2", "TestName2", "Desc2").addOptionalModuleType(osType)
|
||||
.addOptionalModuleType(runtimeType).addOptionalModuleType(appType));
|
||||
types.add(new DistributionSetType("test3", "TestName3", "Desc3").addMandatoryModuleType(osType)
|
||||
.addMandatoryModuleType(runtimeType));
|
||||
types.add(distributionSetManagement.generateDistributionSetType("test1", "TestName1", "Desc1")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(runtimeType));
|
||||
types.add(distributionSetManagement.generateDistributionSetType("test2", "TestName2", "Desc2")
|
||||
.addOptionalModuleType(osType).addOptionalModuleType(runtimeType).addOptionalModuleType(appType));
|
||||
types.add(distributionSetManagement.generateDistributionSetType("test3", "TestName3", "Desc3")
|
||||
.addMandatoryModuleType(osType).addMandatoryModuleType(runtimeType));
|
||||
|
||||
final MvcResult mvcResult = mvc
|
||||
.perform(post("/rest/v1/distributionsettypes/").content(JsonBuilder.distributionSetTypes(types))
|
||||
@@ -205,8 +204,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@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(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
|
||||
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType.getId())
|
||||
@@ -224,8 +223,8 @@ 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(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
|
||||
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId())
|
||||
@@ -244,8 +243,8 @@ 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(new DistributionSetType("test123", "TestName123", "Desc123")
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
@@ -263,8 +262,8 @@ 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(new DistributionSetType("test123", "TestName123", "Desc123")
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
@@ -283,8 +282,8 @@ 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(new DistributionSetType("test123", "TestName123", "Desc123")
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
@@ -305,8 +304,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@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(new DistributionSetType("test123", "TestName123", "Desc123")
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
@@ -327,8 +326,8 @@ 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(new DistributionSetType("test123", "TestName123", "Desc123")
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
@@ -349,8 +348,8 @@ 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(new DistributionSetType("test123", "TestName123", "Desc123")
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
@@ -372,8 +371,8 @@ 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(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = distributionSetManagement.updateDistributionSetType(testType);
|
||||
|
||||
@@ -391,8 +390,8 @@ 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(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
|
||||
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(4);
|
||||
|
||||
@@ -406,10 +405,10 @@ 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(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
distributionSetManagement
|
||||
.createDistributionSet(new DistributionSet("sdfsd", "dsfsdf", "sdfsdf", testType, null));
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
distributionSetManagement.createDistributionSet(
|
||||
distributionSetManagement.generateDistributionSet("sdfsd", "dsfsdf", "sdfsdf", testType, null));
|
||||
|
||||
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(4);
|
||||
assertThat(distributionSetTypeRepository.count()).isEqualTo(4);
|
||||
@@ -424,8 +423,8 @@ 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(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
|
||||
final String body = new JSONObject().put("id", testType.getId()).put("description", "foobardesc")
|
||||
.put("name", "nameShouldNotBeChanged").toString();
|
||||
@@ -479,11 +478,11 @@ 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(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
|
||||
final SoftwareModuleType testSmType = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
final SoftwareModuleType testSmType = softwareManagement.createSoftwareModuleType(
|
||||
softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
|
||||
final List<DistributionSetType> types = new ArrayList<>();
|
||||
types.add(testType);
|
||||
@@ -526,8 +525,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
|
||||
// Modules types at creation time invalid
|
||||
|
||||
final DistributionSetType testNewType = new DistributionSetType("test123", "TestName123", "Desc123");
|
||||
testNewType.addMandatoryModuleType(new SoftwareModuleType("foo", "bar", "test", Integer.MAX_VALUE));
|
||||
final DistributionSetType testNewType = distributionSetManagement.generateDistributionSetType("test123",
|
||||
"TestName123", "Desc123");
|
||||
testNewType.addMandatoryModuleType(
|
||||
softwareManagement.generateSoftwareModuleType("foo", "bar", "test", Integer.MAX_VALUE));
|
||||
|
||||
mvc.perform(post("/rest/v1/distributionsettypes")
|
||||
.content(JsonBuilder.distributionSetTypes(Lists.newArrayList(testNewType)))
|
||||
@@ -560,10 +561,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Test
|
||||
@Description("Search erquest of software module types.")
|
||||
public void searchDistributionSetTypeRsql() throws Exception {
|
||||
final DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
final DistributionSetType testType2 = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test1234", "TestName1234", "Desc123"));
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
final DistributionSetType testType2 = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test1234", "TestName1234", "Desc123"));
|
||||
|
||||
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
|
||||
|
||||
@@ -577,7 +578,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
char character = 'a';
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String str = String.valueOf(character);
|
||||
final SoftwareModule softwareModule = new SoftwareModule(osType, str, str, str, str);
|
||||
final SoftwareModule softwareModule = softwareManagement.generateSoftwareModule(osType, str, str, str, str);
|
||||
|
||||
softwareManagement.createSoftwareModule(softwareModule);
|
||||
character++;
|
||||
|
||||
@@ -30,8 +30,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupConditionBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
@@ -577,7 +577,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
|
||||
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId,
|
||||
final String targetFilterQuery) {
|
||||
final Rollout rollout = new Rollout();
|
||||
final Rollout rollout = rolloutManagement.generateRollout();
|
||||
rollout.setDistributionSet(distributionSetManagement.findDistributionSetById(distributionSetId));
|
||||
rollout.setName(name);
|
||||
rollout.setTargetFilterQuery(targetFilterQuery);
|
||||
|
||||
@@ -44,7 +44,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey;
|
||||
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTestWithMongoDB;
|
||||
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
@@ -92,11 +91,15 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
final String updateVendor = "newVendor1";
|
||||
final String updateDescription = "newDescription1";
|
||||
|
||||
softwareManagement.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||
softwareManagement.createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
|
||||
softwareManagement.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", null, ""));
|
||||
softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||
softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
|
||||
softwareManagement
|
||||
.createSoftwareModule(softwareManagement.generateSoftwareModule(osType, "poky", "3.0.2", null, ""));
|
||||
|
||||
SoftwareModule sm = new SoftwareModule(osType, knownSWName, knownSWVersion, knownSWDescription, knownSWVendor);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, knownSWName, knownSWVersion,
|
||||
knownSWDescription, knownSWVendor);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
assertThat(sm.getName()).as("Wrong name of the software module").isEqualTo(knownSWName);
|
||||
@@ -122,7 +125,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@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 = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
@@ -191,7 +194,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0);
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final MockMultipartFile file = new MockMultipartFile("file", "orig", null, new byte[0]);
|
||||
@@ -204,7 +207,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@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 = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
@@ -226,7 +229,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@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 = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
@@ -253,7 +256,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@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 = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
@@ -297,7 +300,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@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 = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
@@ -332,7 +335,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@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 = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
@@ -358,7 +361,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@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 = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
@@ -401,7 +404,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
final MockMultipartFile file = new MockMultipartFile("file", "orig", null, random);
|
||||
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
// no artifact available
|
||||
@@ -434,7 +437,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@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 = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final List<SoftwareModule> modules = new ArrayList<>();
|
||||
@@ -516,13 +519,16 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Test retrieval of all software modules the user has access to.")
|
||||
public void getSoftwareModules() throws Exception {
|
||||
SoftwareModule os = new SoftwareModule(osType, "name1", "version1", "description1", "vendor1");
|
||||
SoftwareModule os = softwareManagement.generateSoftwareModule(osType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
os = softwareManagement.createSoftwareModule(os);
|
||||
|
||||
SoftwareModule jvm = new SoftwareModule(runtimeType, "name1", "version1", "description1", "vendor1");
|
||||
SoftwareModule jvm = softwareManagement.generateSoftwareModule(runtimeType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
jvm = softwareManagement.createSoftwareModule(jvm);
|
||||
|
||||
SoftwareModule ah = new SoftwareModule(appType, "name1", "version1", "description1", "vendor1");
|
||||
SoftwareModule ah = softwareManagement.generateSoftwareModule(appType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
ah = softwareManagement.createSoftwareModule(ah);
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules").accept(MediaType.APPLICATION_JSON))
|
||||
@@ -584,22 +590,28 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@Test
|
||||
@Description("Test the various filter parameters, e.g. filter by name or type of the module.")
|
||||
public void getSoftwareModulesWithFilterParameters() throws Exception {
|
||||
SoftwareModule os1 = new SoftwareModule(osType, "osName1", "1.0.0", "description1", "vendor1");
|
||||
SoftwareModule os1 = softwareManagement.generateSoftwareModule(osType, "osName1", "1.0.0", "description1",
|
||||
"vendor1");
|
||||
os1 = softwareManagement.createSoftwareModule(os1);
|
||||
|
||||
SoftwareModule jvm1 = new SoftwareModule(runtimeType, "runtimeName1", "2.0.0", "description1", "vendor1");
|
||||
SoftwareModule jvm1 = softwareManagement.generateSoftwareModule(runtimeType, "runtimeName1", "2.0.0",
|
||||
"description1", "vendor1");
|
||||
jvm1 = softwareManagement.createSoftwareModule(jvm1);
|
||||
|
||||
SoftwareModule ah1 = new SoftwareModule(appType, "appName1", "3.0.0", "description1", "vendor1");
|
||||
SoftwareModule ah1 = softwareManagement.generateSoftwareModule(appType, "appName1", "3.0.0", "description1",
|
||||
"vendor1");
|
||||
ah1 = softwareManagement.createSoftwareModule(ah1);
|
||||
|
||||
SoftwareModule os2 = new SoftwareModule(osType, "osName2", "1.0.1", "description2", "vendor2");
|
||||
SoftwareModule os2 = softwareManagement.generateSoftwareModule(osType, "osName2", "1.0.1", "description2",
|
||||
"vendor2");
|
||||
os2 = softwareManagement.createSoftwareModule(os2);
|
||||
|
||||
SoftwareModule jvm2 = new SoftwareModule(runtimeType, "runtimeName2", "2.0.1", "description2", "vendor2");
|
||||
SoftwareModule jvm2 = softwareManagement.generateSoftwareModule(runtimeType, "runtimeName2", "2.0.1",
|
||||
"description2", "vendor2");
|
||||
jvm2 = softwareManagement.createSoftwareModule(jvm2);
|
||||
|
||||
SoftwareModule ah2 = new SoftwareModule(appType, "appName2", "3.0.1", "description2", "vendor2");
|
||||
SoftwareModule ah2 = softwareManagement.generateSoftwareModule(appType, "appName2", "3.0.1", "description2",
|
||||
"vendor2");
|
||||
ah2 = softwareManagement.createSoftwareModule(ah2);
|
||||
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(6);
|
||||
@@ -676,7 +688,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Tests GET request on /rest/v1/softwaremodules/{smId}.")
|
||||
public void getSoftareModule() throws Exception {
|
||||
SoftwareModule os = new SoftwareModule(osType, "name1", "version1", "description1", "vendor1");
|
||||
SoftwareModule os = softwareManagement.generateSoftwareModule(osType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
os = softwareManagement.createSoftwareModule(os);
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}", os.getId()).accept(MediaType.APPLICATION_JSON))
|
||||
@@ -695,7 +708,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
.andExpect(jsonPath("$_links.artifacts.href",
|
||||
equalTo("http://localhost/rest/v1/softwaremodules/" + os.getId() + "/artifacts")));
|
||||
|
||||
SoftwareModule jvm = new SoftwareModule(runtimeType, "name1", "version1", "description1", "vendor1");
|
||||
SoftwareModule jvm = softwareManagement.generateSoftwareModule(runtimeType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
jvm = softwareManagement.createSoftwareModule(jvm);
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}", jvm.getId()).accept(MediaType.APPLICATION_JSON))
|
||||
@@ -714,7 +728,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
.andExpect(jsonPath("$_links.artifacts.href",
|
||||
equalTo("http://localhost/rest/v1/softwaremodules/" + jvm.getId() + "/artifacts")));
|
||||
|
||||
SoftwareModule ah = new SoftwareModule(appType, "name1", "version1", "description1", "vendor1");
|
||||
SoftwareModule ah = softwareManagement.generateSoftwareModule(appType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
ah = softwareManagement.createSoftwareModule(ah);
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}", ah.getId()).accept(MediaType.APPLICATION_JSON))
|
||||
@@ -740,9 +755,12 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@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 = new SoftwareModule(osType, "name1", "version1", "description1", "vendor1");
|
||||
final SoftwareModule jvm = new SoftwareModule(runtimeType, "name2", "version1", "description1", "vendor1");
|
||||
final SoftwareModule ah = new SoftwareModule(appType, "name3", "version1", "description1", "vendor1");
|
||||
final SoftwareModule os = softwareManagement.generateSoftwareModule(osType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
final SoftwareModule jvm = softwareManagement.generateSoftwareModule(runtimeType, "name2", "version1",
|
||||
"description1", "vendor1");
|
||||
final SoftwareModule ah = softwareManagement.generateSoftwareModule(appType, "name3", "version1",
|
||||
"description1", "vendor1");
|
||||
|
||||
final List<SoftwareModule> modules = new ArrayList<>();
|
||||
modules.add(os);
|
||||
@@ -823,7 +841,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@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 = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
@@ -879,7 +897,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@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 = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
@@ -918,8 +936,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
final String knownKey2 = "knownKey1";
|
||||
final String knownValue2 = "knownValue1";
|
||||
|
||||
final SoftwareModule sm = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
final SoftwareModule sm = softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
|
||||
final JSONArray jsonArray = new JSONArray();
|
||||
jsonArray.put(new JSONObject().put("key", knownKey1).put("value", knownValue1));
|
||||
@@ -932,10 +950,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
.andExpect(jsonPath("[1]key", equalTo(knownKey2)))
|
||||
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
|
||||
|
||||
final SoftwareModuleMetadata metaKey1 = softwareManagement
|
||||
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey1));
|
||||
final SoftwareModuleMetadata metaKey2 = softwareManagement
|
||||
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey2));
|
||||
final SoftwareModuleMetadata metaKey1 = softwareManagement.findSoftwareModuleMetadata(sm, knownKey1);
|
||||
final SoftwareModuleMetadata metaKey2 = softwareManagement.findSoftwareModuleMetadata(sm, knownKey2);
|
||||
|
||||
assertThat(metaKey1.getValue()).as("Metadata key is wrong").isEqualTo(knownValue1);
|
||||
assertThat(metaKey2.getValue()).as("Metadata key is wrong").isEqualTo(knownValue2);
|
||||
@@ -949,9 +965,10 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
final String knownValue = "knownValue";
|
||||
final String updateValue = "valueForUpdate";
|
||||
|
||||
final SoftwareModule sm = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
softwareManagement.createSoftwareModuleMetadata(new SoftwareModuleMetadata(knownKey, sm, knownValue));
|
||||
final SoftwareModule sm = softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
softwareManagement.createSoftwareModuleMetadata(
|
||||
softwareManagement.generateSoftwareModuleMetadata(sm, knownKey, knownValue));
|
||||
|
||||
final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue);
|
||||
|
||||
@@ -961,8 +978,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
|
||||
|
||||
final SoftwareModuleMetadata assertDS = softwareManagement
|
||||
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey));
|
||||
final SoftwareModuleMetadata assertDS = softwareManagement.findSoftwareModuleMetadata(sm, knownKey);
|
||||
assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue);
|
||||
}
|
||||
|
||||
@@ -973,15 +989,16 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
final String knownKey = "knownKey";
|
||||
final String knownValue = "knownValue";
|
||||
|
||||
final SoftwareModule sm = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
softwareManagement.createSoftwareModuleMetadata(new SoftwareModuleMetadata(knownKey, sm, knownValue));
|
||||
final SoftwareModule sm = softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
softwareManagement.createSoftwareModuleMetadata(
|
||||
softwareManagement.generateSoftwareModuleMetadata(sm, knownKey, knownValue));
|
||||
|
||||
mvc.perform(delete("/rest/v1/softwaremodules/{swId}/metadata/{key}", sm.getId(), knownKey))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
|
||||
try {
|
||||
softwareManagement.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey));
|
||||
softwareManagement.findSoftwareModuleMetadata(sm, knownKey);
|
||||
fail("expected EntityNotFoundException but didn't throw");
|
||||
} catch (final EntityNotFoundException e) {
|
||||
// ok as expected
|
||||
@@ -994,12 +1011,13 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
final int totalMetadata = 10;
|
||||
final String knownKeyPrefix = "knownKey";
|
||||
final String knownValuePrefix = "knownValue";
|
||||
final SoftwareModule sm = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
final SoftwareModule sm = softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
|
||||
for (int index = 0; index < totalMetadata; index++) {
|
||||
softwareManagement.createSoftwareModuleMetadata(new SoftwareModuleMetadata(knownKeyPrefix + index,
|
||||
softwareManagement.findSoftwareModuleById(sm.getId()), knownValuePrefix + index));
|
||||
softwareManagement.createSoftwareModuleMetadata(softwareManagement.generateSoftwareModuleMetadata(
|
||||
softwareManagement.findSoftwareModuleById(sm.getId()), knownKeyPrefix + index,
|
||||
knownValuePrefix + index));
|
||||
}
|
||||
|
||||
final String rsqlSearchValue1 = "value==knownValue1";
|
||||
@@ -1014,7 +1032,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
char character = 'a';
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String str = String.valueOf(character);
|
||||
final SoftwareModule softwareModule = new SoftwareModule(osType, str, str, str, str);
|
||||
final SoftwareModule softwareModule = softwareManagement.generateSoftwareModule(osType, str, str, str, str);
|
||||
|
||||
softwareManagement.createSoftwareModule(softwareModule);
|
||||
character++;
|
||||
|
||||
@@ -54,8 +54,8 @@ 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(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
SoftwareModuleType testType = softwareManagement.createSoftwareModuleType(
|
||||
softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = softwareManagement.updateSoftwareModuleType(testType);
|
||||
|
||||
@@ -97,7 +97,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@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(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = softwareManagement.updateSoftwareModuleType(testType);
|
||||
|
||||
@@ -138,9 +138,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
public void createSoftwareModuleTypes() throws JSONException, Exception {
|
||||
|
||||
final List<SoftwareModuleType> types = new ArrayList<>();
|
||||
types.add(new SoftwareModuleType("test1", "TestName1", "Desc1", 1));
|
||||
types.add(new SoftwareModuleType("test2", "TestName2", "Desc2", 2));
|
||||
types.add(new SoftwareModuleType("test3", "TestName3", "Desc3", 3));
|
||||
types.add(softwareManagement.generateSoftwareModuleType("test1", "TestName1", "Desc1", 1));
|
||||
types.add(softwareManagement.generateSoftwareModuleType("test2", "TestName2", "Desc2", 2));
|
||||
types.add(softwareManagement.generateSoftwareModuleType("test3", "TestName3", "Desc3", 3));
|
||||
|
||||
final MvcResult mvcResult = mvc
|
||||
.perform(post("/rest/v1/softwaremoduletypes/").content(JsonBuilder.softwareModuleTypes(types))
|
||||
@@ -183,7 +183,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} GET requests.")
|
||||
public void getSoftwareModuleType() throws Exception {
|
||||
SoftwareModuleType testType = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = softwareManagement.updateSoftwareModuleType(testType);
|
||||
|
||||
@@ -204,7 +204,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@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(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
|
||||
assertThat(softwareManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
|
||||
|
||||
@@ -219,9 +219,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@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(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(testType, "name", "version", "description", "vendor"));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(testType, "name", "version", "description", "vendor"));
|
||||
|
||||
assertThat(softwareManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
|
||||
assertThat(softwareModuleTypeRepository.count()).isEqualTo(4);
|
||||
@@ -237,7 +237,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} PUT requests.")
|
||||
public void updateSoftwareModuleTypeOnlyDescriptionAndNameUntouched() throws Exception {
|
||||
final SoftwareModuleType testType = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
|
||||
final String body = new JSONObject().put("id", testType.getId()).put("description", "foobardesc")
|
||||
.put("name", "nameShouldNotBeChanged").toString();
|
||||
@@ -293,7 +293,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@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(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
|
||||
final List<SoftwareModuleType> types = new ArrayList<>();
|
||||
types.add(testType);
|
||||
@@ -332,9 +332,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Description("Search erquest of software module types.")
|
||||
public void searchSoftwareModuleTypeRsql() throws Exception {
|
||||
final SoftwareModuleType testType = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
final SoftwareModuleType testType2 = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test1234", "TestName1234", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test1234", "TestName1234", "Desc123", 5));
|
||||
|
||||
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
|
||||
|
||||
@@ -349,7 +349,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
char character = 'a';
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String str = String.valueOf(character);
|
||||
final SoftwareModule softwareModule = new SoftwareModule(osType, str, str, str, str);
|
||||
final SoftwareModule softwareModule = softwareManagement.generateSoftwareModule(osType, str, str, str, str);
|
||||
|
||||
softwareManagement.createSoftwareModule(softwareModule);
|
||||
character++;
|
||||
|
||||
@@ -37,6 +37,9 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.ActionFields;
|
||||
import org.eclipse.hawkbit.repository.ActionStatusFields;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||
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;
|
||||
@@ -44,7 +47,6 @@ import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||
import org.eclipse.hawkbit.rest.exception.MessageNotReadableException;
|
||||
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
||||
@@ -56,7 +58,6 @@ import org.json.JSONObject;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -110,9 +111,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final String knownTargetId = "targetId";
|
||||
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
|
||||
actions.get(0).setStatus(Status.FINISHED);
|
||||
controllerManagament.addUpdateActionStatus(
|
||||
new ActionStatus(actions.get(0), Status.FINISHED, System.currentTimeMillis(), "testmessage"),
|
||||
actions.get(0));
|
||||
controllerManagament.addUpdateActionStatus(controllerManagament.generateActionStatus(actions.get(0),
|
||||
Status.FINISHED, System.currentTimeMillis(), "testmessage"));
|
||||
|
||||
final PageRequest pageRequest = new PageRequest(0, 1000, Direction.ASC, ActionFields.ID.getFieldName());
|
||||
final ActionStatus status = deploymentManagement
|
||||
@@ -141,7 +141,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
public void securityTokenIsNotInResponseIfMissingPermission() throws Exception {
|
||||
|
||||
final String knownControllerId = "knownControllerId";
|
||||
targetManagement.createTarget(new Target(knownControllerId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(knownControllerId));
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("securityToken").doesNotExist());
|
||||
@@ -154,7 +154,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
public void securityTokenIsInResponseWithCorrectPermission() throws Exception {
|
||||
|
||||
final String knownControllerId = "knownControllerId";
|
||||
final Target createTarget = targetManagement.createTarget(new Target(knownControllerId));
|
||||
final Target createTarget = targetManagement.createTarget(targetManagement.generateTarget(knownControllerId));
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("securityToken", equalTo(createTarget.getSecurityToken())));
|
||||
@@ -185,8 +185,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
}
|
||||
|
||||
private void createTarget(final String controllerId) {
|
||||
final Target target = new Target(controllerId);
|
||||
final TargetInfo targetInfo = new TargetInfo(target);
|
||||
final JpaTarget target = (JpaTarget) targetManagement.generateTarget(controllerId);
|
||||
final JpaTargetInfo targetInfo = new JpaTargetInfo(target);
|
||||
targetInfo.setAddress(IpUtil.createHttpUri("127.0.0.1").toString());
|
||||
target.setTargetInfo(targetInfo);
|
||||
targetManagement.createTarget(target);
|
||||
@@ -199,7 +199,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
// prepare test
|
||||
final DistributionSet dsA = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
final Target createTarget = targetManagement.createTarget(new Target("knownTargetId"));
|
||||
final Target createTarget = targetManagement.createTarget(targetManagement.generateTarget("knownTargetId"));
|
||||
|
||||
deploymentManagement.assignDistributionSet(dsA, Lists.newArrayList(createTarget));
|
||||
|
||||
@@ -306,7 +306,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(new Target(knownControllerId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(knownControllerId));
|
||||
|
||||
mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId))
|
||||
.andExpect(status().isOk());
|
||||
@@ -342,7 +342,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final String body = new JSONObject().put("description", knownNewDescription).toString();
|
||||
|
||||
// prepare
|
||||
final Target t = new Target(knownControllerId);
|
||||
final Target t = targetManagement.generateTarget(knownControllerId);
|
||||
t.setDescription("old description");
|
||||
t.setName(knownNameNotModiy);
|
||||
targetManagement.createTarget(t);
|
||||
@@ -599,9 +599,10 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
// assign ds to target
|
||||
deploymentManagement.assignDistributionSet(ds.getId(), knownControllerId);
|
||||
final Long actionId = deploymentManagement.assignDistributionSet(ds.getId(), knownControllerId).getActions()
|
||||
.get(0);
|
||||
// give feedback, so installedDS is in SNYC
|
||||
feedbackToByInSync(knownControllerId, ds);
|
||||
feedbackToByInSync(actionId);
|
||||
// test
|
||||
|
||||
final SoftwareModule os = ds.findFirstModuleByType(osType);
|
||||
@@ -683,13 +684,13 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void createTargetsListReturnsSuccessful() throws Exception {
|
||||
final Target test1 = new Target("id1");
|
||||
final Target test1 = targetManagement.generateTarget("id1");
|
||||
test1.setDescription("testid1");
|
||||
test1.setName("testname1");
|
||||
final Target test2 = new Target("id2");
|
||||
final Target test2 = targetManagement.generateTarget("id2");
|
||||
test2.setDescription("testid2");
|
||||
test2.setName("testname2");
|
||||
final Target test3 = new Target("id3");
|
||||
final Target test3 = targetManagement.generateTarget("id3");
|
||||
test3.setName("testname3");
|
||||
test3.setDescription("testid3");
|
||||
|
||||
@@ -812,7 +813,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
public void getActionWithEmptyResult() throws Exception {
|
||||
final String knownTargetId = "targetId";
|
||||
final Target target = new Target(knownTargetId);
|
||||
final Target target = targetManagement.generateTarget(knownTargetId);
|
||||
targetManagement.createTarget(target);
|
||||
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/"
|
||||
@@ -1027,12 +1028,12 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
|
||||
final PageRequest pageRequest = new PageRequest(0, 100, Direction.ASC, ActionStatusFields.ID.getFieldName());
|
||||
|
||||
Target target = new Target(knownTargetId);
|
||||
Target target = targetManagement.generateTarget(knownTargetId);
|
||||
target = targetManagement.createTarget(target);
|
||||
final List<Target> targets = new ArrayList<>();
|
||||
targets.add(target);
|
||||
|
||||
final Iterator<DistributionSet> sets = TestDataUtil
|
||||
final Iterator<JpaDistributionSet> sets = TestDataUtil
|
||||
.generateDistributionSets(2, softwareManagement, distributionSetManagement).iterator();
|
||||
final DistributionSet one = sets.next();
|
||||
final DistributionSet two = sets.next();
|
||||
@@ -1045,8 +1046,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
Thread.sleep(10);
|
||||
deploymentManagement.assignDistributionSet(two, updatedTargets);
|
||||
|
||||
// two updates, one cancelation
|
||||
final List<Action> actions = actionRepository.findAll(pageRequest).getContent();
|
||||
// two updates, one cancellation
|
||||
final List<Action> actions = deploymentManagement.findActionsByTarget(target);
|
||||
|
||||
assertThat(actions).hasSize(2);
|
||||
return actions;
|
||||
@@ -1073,7 +1074,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
public void assignDistributionSetToTarget() throws Exception {
|
||||
|
||||
final Target target = targetManagement.createTarget(new Target("fsdfsd"));
|
||||
final Target target = targetManagement.createTarget(targetManagement.generateTarget("fsdfsd"));
|
||||
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
|
||||
@@ -1087,7 +1088,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
public void assignDistributionSetToTargetWithActionTimeForcedAndTime() throws Exception {
|
||||
|
||||
final Target target = targetManagement.createTarget(new Target("fsdfsd"));
|
||||
final Target target = targetManagement.createTarget(targetManagement.generateTarget("fsdfsd"));
|
||||
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
|
||||
@@ -1116,7 +1117,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
||||
|
||||
targetManagement.createTarget(new Target("fsdfsd"));
|
||||
targetManagement.createTarget(targetManagement.generateTarget("fsdfsd"));
|
||||
|
||||
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS")
|
||||
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON))
|
||||
@@ -1206,7 +1207,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final Map<String, String> knownControllerAttrs = new HashMap<>();
|
||||
knownControllerAttrs.put("a", "1");
|
||||
knownControllerAttrs.put("b", "2");
|
||||
final Target target = new Target(knownTargetId);
|
||||
final Target target = targetManagement.generateTarget(knownTargetId);
|
||||
targetManagement.createTarget(target);
|
||||
controllerManagament.updateControllerAttributes(knownTargetId, knownControllerAttrs);
|
||||
|
||||
@@ -1220,7 +1221,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
public void getControllerEmptyAttributesReturnsNoContent() throws Exception {
|
||||
// create target with attributes
|
||||
final String knownTargetId = "targetIdWithAttributes";
|
||||
final Target target = new Target(knownTargetId);
|
||||
final Target target = targetManagement.generateTarget(knownTargetId);
|
||||
targetManagement.createTarget(target);
|
||||
|
||||
// test query target over rest resource
|
||||
@@ -1254,7 +1255,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
}
|
||||
|
||||
private void createSingleTarget(final String controllerId, final String name) {
|
||||
final Target target = new Target(controllerId);
|
||||
final Target target = targetManagement.generateTarget(controllerId);
|
||||
target.setName(name);
|
||||
target.setDescription(TARGET_DESCRIPTION_TEST);
|
||||
targetManagement.createTarget(target);
|
||||
@@ -1271,7 +1272,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 = new Target(str);
|
||||
final Target target = targetManagement.generateTarget(str);
|
||||
target.setName(str);
|
||||
target.setDescription(str);
|
||||
final Target savedTarget = targetManagement.createTarget(target);
|
||||
@@ -1283,20 +1284,12 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
/**
|
||||
* helper method to give feedback mark an target IN_SNCY
|
||||
*
|
||||
* @param controllerId
|
||||
* the controller id to give feedback to
|
||||
* @param savedSet
|
||||
* the distribution set
|
||||
* @throws Exception
|
||||
* @throws JSONException
|
||||
*/
|
||||
private void feedbackToByInSync(final String controllerId, final DistributionSet savedSet)
|
||||
throws Exception, JSONException {
|
||||
final Pageable pageReq = new PageRequest(0, 100);
|
||||
final Action action = actionRepository.findByDistributionSet(pageReq, savedSet).getContent().get(0);
|
||||
private void feedbackToByInSync(final Long actionId) {
|
||||
final Action action = deploymentManagement.findAction(actionId);
|
||||
|
||||
final ActionStatus actionStatus = new ActionStatus(action, Status.FINISHED, 0l);
|
||||
controllerManagement.addUpdateActionStatus(actionStatus, action);
|
||||
final ActionStatus actionStatus = controllerManagement.generateActionStatus(action, Status.FINISHED, 0L);
|
||||
controllerManagement.addUpdateActionStatus(actionStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SMRessourceMisingMongoDbConnectionTest extends AbstractIntegrationT
|
||||
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0);
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
SoftwareModule sm = new SoftwareModule(softwareManagement.findSoftwareModuleTypeByKey("os"), "name 1",
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(softwareManagement.findSoftwareModuleTypeByKey("os"), "name 1",
|
||||
"version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
Reference in New Issue
Block a user