Sonar Fixes (#2233)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -891,23 +891,20 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
||||
.getWithDetails(distributionSetManagement.findByRsql("name==three", PAGE).getContent().get(0).getId())
|
||||
.get();
|
||||
|
||||
assertThat(
|
||||
JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
assertThat((Object)JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString("http://localhost/rest/v1/distributionsets/" + one.getId());
|
||||
|
||||
assertThat(JsonPath.compile("[0]id").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
assertThat((Object)JsonPath.compile("[0]id").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString(String.valueOf(one.getId()));
|
||||
assertThat(
|
||||
JsonPath.compile("[1]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
assertThat((Object)JsonPath.compile("[1]_links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString("http://localhost/rest/v1/distributionsets/" + two.getId());
|
||||
|
||||
assertThat(JsonPath.compile("[1]id").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
assertThat((Object)JsonPath.compile("[1]id").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString(String.valueOf(two.getId()));
|
||||
assertThat(
|
||||
JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
assertThat((Object)JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString("http://localhost/rest/v1/distributionsets/" + three.getId());
|
||||
|
||||
assertThat(JsonPath.compile("[2]id").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
assertThat((Object)JsonPath.compile("[2]id").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString(String.valueOf(three.getId()));
|
||||
|
||||
// check in database
|
||||
|
||||
@@ -685,14 +685,11 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
|
||||
assertThat(created2.getOptionalModuleTypes()).containsOnly(osType, runtimeType, appType);
|
||||
assertThat(created3.getMandatoryModuleTypes()).containsOnly(osType, runtimeType);
|
||||
|
||||
assertThat(
|
||||
JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
assertThat((Object)JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString("http://localhost/rest/v1/distributionsettypes/" + created1.getId());
|
||||
assertThat(
|
||||
JsonPath.compile("[1]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
assertThat((Object)JsonPath.compile("[1]_links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString("http://localhost/rest/v1/distributionsettypes/" + created2.getId());
|
||||
assertThat(
|
||||
JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
assertThat((Object)JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString("http://localhost/rest/v1/distributionsettypes/" + created3.getId());
|
||||
|
||||
assertThat(distributionSetTypeManagement.count()).isEqualTo(7);
|
||||
|
||||
@@ -188,7 +188,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
approvalStrategy.setApproveDecidedBy("testUser");
|
||||
final int amountTargets = 2;
|
||||
final String remark = "Some remark";
|
||||
final List<Target> targets = testdataFactory.createTargets(amountTargets, "rollout");
|
||||
testdataFactory.createTargets(amountTargets, "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
final Rollout rollout = createRollout("rollout1", 3, dsA.getId(), "controllerId==rollout*", false);
|
||||
|
||||
@@ -1927,10 +1927,6 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
retrieveAndCompareRolloutsContent(dsA, urlTemplate, isFullRepresentation, false, null, null);
|
||||
}
|
||||
|
||||
private Rollout getRollout(final long rolloutId) {
|
||||
return rolloutManagement.get(rolloutId).orElseThrow(NoSuchElementException::new);
|
||||
}
|
||||
|
||||
private void retrieveAndCompareRolloutsContent(final DistributionSet dsA, final String urlTemplate,
|
||||
final boolean isFullRepresentation, final boolean isStartTypeScheduled, final Long startAt,
|
||||
final Long forcetime) throws Exception {
|
||||
|
||||
@@ -104,7 +104,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
public void createSMFromAlreadyMarkedAsDeletedType() throws Exception {
|
||||
final String SM_TYPE = "someSmType";
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModule(SM_TYPE);
|
||||
final DistributionSetType t = testdataFactory.findOrCreateDistributionSetType(
|
||||
testdataFactory.findOrCreateDistributionSetType(
|
||||
"testKey", "testType", Collections.singletonList(sm.getType()),
|
||||
Collections.singletonList(sm.getType()));
|
||||
final DistributionSetType type = testdataFactory.findOrCreateDistributionSetType("testKey", "testType");
|
||||
@@ -295,7 +295,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
.andExpect(jsonPath("$.lastModifiedAt", equalTo(sm.getLastModifiedAt())))
|
||||
.andExpect(jsonPath("$.deleted", equalTo(false)));
|
||||
|
||||
final SoftwareModule updatedSm = softwareModuleManagement.get(sm.getId()).get();
|
||||
softwareModuleManagement.get(sm.getId());
|
||||
assertThat(sm.getLastModifiedBy()).isEqualTo("smUpdateTester");
|
||||
assertThat(sm.getLastModifiedAt()).isEqualTo(sm.getLastModifiedAt());
|
||||
assertThat(sm.isDeleted()).isFalse();
|
||||
@@ -400,15 +400,12 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
||||
mvcResult.getResponse().getContentAsString());
|
||||
final Long artId = softwareModuleManagement.get(sm.getId()).get().getArtifacts().get(0).getId();
|
||||
assertThat(artResult.getArtifactId()).as("Wrong artifact id").isEqualTo(artId);
|
||||
assertThat(JsonPath.compile("$._links.self.href")
|
||||
.read(mvcResult.getResponse().getContentAsString())
|
||||
.toString()).as("Link contains no self url")
|
||||
.isEqualTo("http://localhost/rest/v1/softwaremodules/" + sm.getId() + "/artifacts/" + artId);
|
||||
assertThat(JsonPath.compile("$._links.download.href")
|
||||
.read(mvcResult.getResponse().getContentAsString())
|
||||
.toString()).as("response contains no download url ")
|
||||
.isEqualTo(
|
||||
"http://localhost/rest/v1/softwaremodules/" + sm.getId() + "/artifacts/" + artId + "/download");
|
||||
assertThat((Object)JsonPath.compile("$._links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.as("Link contains no self url")
|
||||
.hasToString("http://localhost/rest/v1/softwaremodules/" + sm.getId() + "/artifacts/" + artId);
|
||||
assertThat((Object)JsonPath.compile("$._links.download.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.as("response contains no download url ")
|
||||
.hasToString("http://localhost/rest/v1/softwaremodules/" + sm.getId() + "/artifacts/" + artId + "/download");
|
||||
|
||||
assertArtifact(sm, random);
|
||||
}
|
||||
|
||||
@@ -213,15 +213,12 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
||||
final SoftwareModuleType created2 = softwareModuleTypeManagement.findByKey("test2").get();
|
||||
final SoftwareModuleType created3 = softwareModuleTypeManagement.findByKey("test3").get();
|
||||
|
||||
assertThat(
|
||||
JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
.isEqualTo("http://localhost/rest/v1/softwaremoduletypes/" + created1.getId());
|
||||
assertThat(
|
||||
JsonPath.compile("[1]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
.isEqualTo("http://localhost/rest/v1/softwaremoduletypes/" + created2.getId());
|
||||
assertThat(
|
||||
JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
.isEqualTo("http://localhost/rest/v1/softwaremoduletypes/" + created3.getId());
|
||||
assertThat((Object) JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString("http://localhost/rest/v1/softwaremoduletypes/" + created1.getId());
|
||||
assertThat((Object)JsonPath.compile("[1]_links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString("http://localhost/rest/v1/softwaremoduletypes/" + created2.getId());
|
||||
assertThat((Object)JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString("http://localhost/rest/v1/softwaremoduletypes/" + created3.getId());
|
||||
|
||||
assertThat(softwareModuleTypeManagement.count()).isEqualTo(6);
|
||||
}
|
||||
@@ -334,7 +331,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
||||
|
||||
testType = softwareModuleTypeManagement.get(testType.getId()).get();
|
||||
assertThat(testType.getLastModifiedAt()).isEqualTo(testType.getLastModifiedAt());
|
||||
assertThat(testType.isDeleted()).isEqualTo(false);
|
||||
assertThat(testType.isDeleted()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -466,15 +463,4 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
||||
.update(entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234"));
|
||||
return testType;
|
||||
}
|
||||
|
||||
private void createSoftwareModulesAlphabetical(final int amount) {
|
||||
char character = 'a';
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String str = String.valueOf(character);
|
||||
softwareModuleManagement.create(entityFactory.softwareModule().create().type(osType).name(str)
|
||||
.description(str).vendor(str).version(str));
|
||||
character++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -97,8 +97,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
||||
@Description("Handles the GET request of retrieving all target filter queries within SP.")
|
||||
public void getTargetFilterQueries() throws Exception {
|
||||
final String filterName = "filter_01";
|
||||
final TargetFilterQuery filterQuery = createSingleTargetFilterQuery(filterName, "name==test_01");
|
||||
|
||||
createSingleTargetFilterQuery(filterName, "name==test_01");
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING))
|
||||
.andExpect(status().isOk())
|
||||
.andDo(MockMvcResultPrinter.print());
|
||||
@@ -393,7 +392,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
||||
.andExpect(status().isBadRequest())
|
||||
.andReturn();
|
||||
|
||||
assertThat(targetFilterQueryManagement.count()).isEqualTo(0);
|
||||
assertThat(targetFilterQueryManagement.count()).isZero();
|
||||
|
||||
// verify response json exception message
|
||||
final ExceptionInfo exceptionInfo = ResourceUtility
|
||||
@@ -414,7 +413,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
||||
.andExpect(status().isBadRequest())
|
||||
.andReturn();
|
||||
|
||||
assertThat(targetFilterQueryManagement.count()).isEqualTo(0);
|
||||
assertThat(targetFilterQueryManagement.count()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -613,7 +612,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
||||
|
||||
final List<TargetFilterQuery> filters = targetFilterQueryManagement.findAll(PAGE).getContent();
|
||||
assertThat(filters).hasSize(1);
|
||||
assertThat(filters.get(0).getAutoAssignWeight().get()).isEqualTo(45);
|
||||
assertThat(filters.get(0).getAutoAssignWeight()).contains(45);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
||||
@@ -1006,15 +1006,12 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("[2].createdBy", equalTo("bumlux")))
|
||||
.andReturn();
|
||||
|
||||
assertThat(
|
||||
JsonPath.compile("[0]._links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
.isEqualTo("http://localhost/rest/v1/targets/id1");
|
||||
assertThat(
|
||||
JsonPath.compile("[1]._links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
.isEqualTo("http://localhost/rest/v1/targets/id2");
|
||||
assertThat(
|
||||
JsonPath.compile("[2]._links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
.isEqualTo("http://localhost/rest/v1/targets/id3");
|
||||
assertThat((Object) JsonPath.compile("[0]._links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString("http://localhost/rest/v1/targets/id1");
|
||||
assertThat((Object)JsonPath.compile("[1]._links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString("http://localhost/rest/v1/targets/id2");
|
||||
assertThat((Object)JsonPath.compile("[2]._links.self.href").read(mvcResult.getResponse().getContentAsString()))
|
||||
.hasToString("http://localhost/rest/v1/targets/id3");
|
||||
|
||||
final Target t1 = assertTarget("id1", "testname1", "testid1");
|
||||
assertThat(t1.getSecurityToken()).isEqualTo("token");
|
||||
@@ -2275,7 +2272,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
|
||||
final List<Target> targets = Arrays.asList(test1, test2, test3);
|
||||
|
||||
final MvcResult mvcPostResult = mvc
|
||||
mvc
|
||||
.perform(post("/rest/v1/targets").content(JsonBuilder.targets(targets, true))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
|
||||
@@ -91,9 +91,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
@Test
|
||||
@Description("Handles the GET request of retrieving all targets tags within SP based by parameter")
|
||||
public void getTargetTagsWithParameters() throws Exception {
|
||||
final List<TargetTag> tags = testdataFactory.createTargetTags(2, "");
|
||||
final TargetTag assigned = tags.get(0);
|
||||
final TargetTag unassigned = tags.get(1);
|
||||
testdataFactory.createTargetTags(2, "");
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==targetTag"))
|
||||
.andExpect(status().isOk())
|
||||
.andDo(MockMvcResultPrinter.print());
|
||||
@@ -233,7 +231,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0);
|
||||
final int targetsAssigned = 5;
|
||||
final List<Target> targets = testdataFactory.createTargets(targetsAssigned);
|
||||
targetManagement.assignTag(targets.stream().map(Target::getControllerId).collect(Collectors.toList()), tag.getId());
|
||||
targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId());
|
||||
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned"))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
@@ -254,7 +252,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
final int targetsAssigned = 5;
|
||||
final int limitSize = 1;
|
||||
final List<Target> targets = testdataFactory.createTargets(targetsAssigned);
|
||||
targetManagement.assignTag(targets.stream().map(Target::getControllerId).collect(Collectors.toList()), tag.getId());
|
||||
targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId());
|
||||
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
|
||||
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize)))
|
||||
@@ -278,7 +276,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
final int expectedSize = targetsAssigned - offsetParam;
|
||||
|
||||
final List<Target> targets = testdataFactory.createTargets(targetsAssigned);
|
||||
targetManagement.assignTag(targets.stream().map(Target::getControllerId).collect(Collectors.toList()), tag.getId());
|
||||
targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId());
|
||||
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
|
||||
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam))
|
||||
@@ -306,8 +304,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
.andExpect(status().isOk());
|
||||
|
||||
final List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
|
||||
assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
||||
.containsOnly(assigned.getControllerId());
|
||||
assertThat(updated.stream().map(Target::getControllerId).toList()).containsOnly(assigned.getControllerId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -329,7 +326,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
.andExpect(status().isOk());
|
||||
|
||||
final List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
|
||||
assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
||||
assertThat(updated.stream().map(Target::getControllerId).toList())
|
||||
.containsOnly(assigned0.getControllerId(), assigned1.getControllerId());
|
||||
}
|
||||
|
||||
@@ -459,7 +456,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
final Target assigned = targets.get(0);
|
||||
final Target unassigned = targets.get(1);
|
||||
|
||||
targetManagement.assignTag(targets.stream().map(Target::getControllerId).collect(Collectors.toList()), tag.getId());
|
||||
targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId());
|
||||
|
||||
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" +
|
||||
unassigned.getControllerId()))
|
||||
@@ -467,7 +464,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
.andExpect(status().isOk());
|
||||
|
||||
final List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
|
||||
assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
||||
assertThat(updated.stream().map(Target::getControllerId).toList())
|
||||
.containsOnly(assigned.getControllerId());
|
||||
}
|
||||
|
||||
@@ -484,7 +481,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
final Target unassigned0 = targets.get(1);
|
||||
final Target unassigned1 = targets.get(2);
|
||||
|
||||
targetManagement.assignTag(targets.stream().map(Target::getControllerId).collect(Collectors.toList()), tag.getId());
|
||||
targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId());
|
||||
|
||||
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
|
||||
.content(JsonBuilder.toArray(Arrays.asList(unassigned0.getControllerId(), unassigned1.getControllerId())))
|
||||
@@ -493,7 +490,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
||||
.andExpect(status().isOk());
|
||||
|
||||
final List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
|
||||
assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
||||
assertThat(updated.stream().map(Target::getControllerId).toList())
|
||||
.containsOnly(assigned.getControllerId());
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
String typeNameA = "ATestTypeGETsorted";
|
||||
String typeNameB = "BTestTypeGETsorted";
|
||||
String typeNameC = "CTestTypeGETsorted";
|
||||
TargetType testTypeB = createTestTargetTypeInDB(typeNameB);
|
||||
createTestTargetTypeInDB(typeNameB);
|
||||
TargetType testTypeC = createTestTargetTypeInDB(typeNameC);
|
||||
TargetType testTypeA = createTestTargetTypeInDB(typeNameA);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user