io.qameta.allure.Description Java Examples
The following examples show how to use
io.qameta.allure.Description.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MgmtSoftwareModuleResourceTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Verfies the successfull search of a metadata entry based on value.") public void searchSoftwareModuleMetadataRsql() throws Exception { final int totalMetadata = 10; final String knownKeyPrefix = "knownKey"; final String knownValuePrefix = "knownValue"; final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); for (int index = 0; index < totalMetadata; index++) { softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(sm.getId()) .key(knownKeyPrefix + index).value(knownValuePrefix + index)); } final String rsqlSearchValue1 = "value==knownValue1"; mvc.perform(get("/rest/v1/softwaremodules/{swId}/metadata?q=" + rsqlSearchValue1, sm.getId())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("size", equalTo(1))) .andExpect(jsonPath("total", equalTo(1))).andExpect(jsonPath("content[0].key", equalTo("knownKey1"))) .andExpect(jsonPath("content[0].value", equalTo("knownValue1"))); }
Example #2
Source File: AmqpMessageHandlerServiceIntegrationTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Verfiy receiving a download message if a deployment is done with window configured but before maintenance window start time.") @ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2)}) public void receiveDownloadMessageBeforeMaintenanceWindowStartTime() { final String controllerId = TARGET_PREFIX + "receiveDownLoadMessageBeforeMaintenanceWindowStartTime"; // setup registerAndAssertTargetWithExistingTenant(controllerId); final DistributionSet distributionSet = testdataFactory.createDistributionSet(UUID.randomUUID().toString()); testdataFactory.addSoftwareModuleMetadata(distributionSet); assignDistributionSetWithMaintenanceWindow(distributionSet.getId(), controllerId, getTestSchedule(2), getTestDuration(1), getTestTimeZone()); // test registerSameTargetAndAssertBasedOnVersion(controllerId, 1, TargetUpdateStatus.PENDING); // verify assertDownloadMessage(distributionSet.getModules(), controllerId); Mockito.verifyZeroInteractions(getDeadletterListener()); }
Example #3
Source File: DeploymentManagementTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Assigning distribution set to the list of targets with a non-existing one leads to successful assignment of valid targets, while not found targets are silently ignored.") public void assignDistributionSetToNotExistingTarget() { final String notExistingId = "notExistingTarget"; final DistributionSet createdDs = testdataFactory.createDistributionSet(); final String[] knownTargetIdsArray = { "1", "2" }; final List<String> knownTargetIds = Lists.newArrayList(knownTargetIdsArray); testdataFactory.createTargets(knownTargetIdsArray); // add not existing target to targets knownTargetIds.add(notExistingId); final List<DistributionSetAssignmentResult> assignDistributionSetsResults = assignDistributionSetToTargets( createdDs, knownTargetIds); for (final DistributionSetAssignmentResult assignDistributionSetsResult : assignDistributionSetsResults) { assertThat(assignDistributionSetsResult.getAlreadyAssigned()).isEqualTo(0); assertThat(assignDistributionSetsResult.getAssigned()).isEqualTo(2); assertThat(assignDistributionSetsResult.getTotal()).isEqualTo(2); } }
Example #4
Source File: ControllerManagementTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Controller confirmation fails with invalid messages.") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3) }) public void controllerConfirmationFailsWithInvalidMessages() { final Long actionId = createTargetAndAssignDs(); simulateIntermediateStatusOnUpdate(actionId); assertThatExceptionOfType(ConstraintViolationException.class) .as("set invalid description text should not be created") .isThrownBy(() -> controllerManagement.addUpdateActionStatus(entityFactory.actionStatus() .create(actionId).status(Action.Status.FINISHED).message(INVALID_TEXT_HTML))); assertThatExceptionOfType(ConstraintViolationException.class) .as("set invalid description text should not be created") .isThrownBy(() -> controllerManagement.addUpdateActionStatus( entityFactory.actionStatus().create(actionId).status(Action.Status.FINISHED) .messages(Arrays.asList("this is valid.", INVALID_TEXT_HTML)))); assertThat(actionStatusRepository.count()).isEqualTo(6); assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(6); }
Example #5
Source File: AmqpMessageDispatcherServiceIntegrationTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Verify that attribute update is requested after device successfully closed software update.") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = TargetAttributesRequestedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void attributeRequestAfterSuccessfulUpdate() { final String controllerId = TARGET_PREFIX + "attributeUpdateRequest"; registerAndAssertTargetWithExistingTenant(controllerId); final long actionId1 = assignNewDsToTarget(controllerId); updateActionViaDmfClient(controllerId, actionId1, DmfActionStatus.ERROR); waitUntilTargetHasStatus(controllerId, TargetUpdateStatus.ERROR); assertRequestAttributesUpdateMessageAbsent(); final long actionId2 = assignNewDsToTarget(controllerId); updateActionViaDmfClient(controllerId, actionId2, DmfActionStatus.FINISHED); waitUntilTargetHasStatus(controllerId, TargetUpdateStatus.IN_SYNC); assertRequestAttributesUpdateMessage(controllerId); }
Example #6
Source File: MgmtTargetResourceTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Ensures that method not allowed is returned if cancelation is triggered on already canceled action.") public void cancelAndCancelActionIsNotAllowed() throws Exception { // prepare test final Target tA = createTargetAndStartAction(); // cancel the active action deploymentManagement.cancelAction( deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE).getContent().get(0).getId()); // find the current active action final List<Action> cancelActions = deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE) .getContent().stream().filter(Action::isCancelingOrCanceled).collect(Collectors.toList()); assertThat(cancelActions).hasSize(1); // test - cancel an cancel action returns forbidden mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", tA.getControllerId(), cancelActions.get(0).getId())).andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); }
Example #7
Source File: MgmtTargetResourceTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Ensures that post request for creating a target with no payload returns a bad request.") public void createTargetWithoutPayloadBadRequest() throws Exception { final MvcResult mvcResult = mvc .perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn(); assertThat(targetManagement.count()).isEqualTo(0); // verify response json exception message final ExceptionInfo exceptionInfo = ResourceUtility .convertException(mvcResult.getResponse().getContentAsString()); assertThat(exceptionInfo.getErrorCode()).isEqualTo(SpServerError.SP_REST_BODY_NOT_READABLE.getKey()); assertThat(exceptionInfo.getMessage()).isEqualTo(SpServerError.SP_REST_BODY_NOT_READABLE.getMessage()); }
Example #8
Source File: MgmtDistributionSetTypeResourceTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @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 = distributionSetTypeManagement.create(entityFactory.distributionSetType() .create().key("test123").name("TestName123").description("Desc123").colour("col12")); distributionSetManagement.create(entityFactory.distributionSet().create().name("sdfsd").description("dsfsdf") .version("1").type(testType)); assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES + 1); assertThat(distributionSetManagement.count()).isEqualTo(1); mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId())).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(false))); mvc.perform(delete("/rest/v1/distributionsettypes/{dstId}", testType.getId())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId())).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(true))); assertThat(distributionSetManagement.count()).isEqualTo(1); assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES); }
Example #9
Source File: TargetResourceDocumentationTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Delete a single meta data." + " Required Permission: " + SpPermission.UPDATE_REPOSITORY) public void deleteMetadata() throws Exception { // prepare and create metadata for deletion final String knownKey = "knownKey"; final String knownValue = "knownValue"; final Target testTarget = testdataFactory.createTarget(targetId); targetManagement.createMetaData(testTarget.getControllerId(), Collections.singletonList(entityFactory.generateTargetMetadata(knownKey, knownValue))); mockMvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{key}", testTarget.getControllerId(), knownKey)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID), parameterWithName("key").description(ApiModelPropertiesGeneric.ITEM_ID)))); }
Example #10
Source File: ControllerManagementTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Register a controller which does not exist, when a ConcurrencyFailureException is raised, the " + "exception is not rethrown when the max retries are not yet reached") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void findOrRegisterTargetIfItDoesNotExistDoesNotThrowExceptionBeforeMaxRetries() { final TargetRepository mockTargetRepository = Mockito.mock(TargetRepository.class); ((JpaControllerManagement) controllerManagement).setTargetRepository(mockTargetRepository); final Target target = testdataFactory.createTarget(); when(mockTargetRepository.findOne(any())).thenThrow(ConcurrencyFailureException.class) .thenThrow(ConcurrencyFailureException.class).thenReturn(Optional.of((JpaTarget) target)); when(mockTargetRepository.save(any())).thenReturn(target); try { final Target targetFromControllerManagement = controllerManagement .findOrRegisterTargetIfItDoesNotExist(target.getControllerId(), LOCALHOST); verify(mockTargetRepository, times(3)).findOne(any()); verify(mockTargetRepository, times(1)).save(any()); assertThat(target).isEqualTo(targetFromControllerManagement); } finally { // revert ((JpaControllerManagement) controllerManagement).setTargetRepository(targetRepository); } }
Example #11
Source File: DdiRootControllerTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Ensures that tenant specific polling time, which is saved in the db, is delivered to the controller.") @WithUser(principal = "knownpricipal", allSpPermissions = false) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void pollWithModifiedGloablPollingTime() throws Exception { securityRule.runAs(WithSpringAuthorityRule.withUser("tenantadmin", HAS_AUTH_TENANT_CONFIGURATION), () -> { tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.POLLING_TIME_INTERVAL, "00:02:00"); return null; }); securityRule.runAs(WithSpringAuthorityRule.withUser("controller", CONTROLLER_ROLE_ANONYMOUS), () -> { mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:02:00"))); return null; }); }
Example #12
Source File: PreAuthTokenSourceTrustAuthenticationProviderTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Testing that the controllerId in the URI request match with the controllerId in the request header but the request are not coming from a trustful source.") public void priniciapAndCredentialsAreTheSameButSourceIpRequestNotMatching() { final String remoteAddress = "192.168.1.1"; final String principal = "controllerId"; final String credentials = "controllerId"; final PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken(principal, Arrays.asList(credentials)); token.setDetails(webAuthenticationDetailsMock); when(webAuthenticationDetailsMock.getRemoteAddress()).thenReturn(remoteAddress); // test, should throw authentication exception try { underTestWithSourceIpCheck.authenticate(token); fail("as source is not trusted."); } catch (final InsufficientAuthenticationException e) { } }
Example #13
Source File: TargetManagementSearchTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Verfies that targets with given installed DS are returned from repository.") public void findTargetByInstalledDistributionSet() { final DistributionSet assignedSet = testdataFactory.createDistributionSet(""); final DistributionSet installedSet = testdataFactory.createDistributionSet("another"); testdataFactory.createTargets(10, "unassigned", "unassigned"); List<Target> installedtargets = testdataFactory.createTargets(10, "assigned", "assigned"); // set on installed and assign another one assignDistributionSet(installedSet, installedtargets).getAssignedEntity().forEach(action -> controllerManagement .addUpdateActionStatus(entityFactory.actionStatus().create(action.getId()).status(Status.FINISHED))); assignDistributionSet(assignedSet, installedtargets); // get final updated version of targets installedtargets = targetManagement .getByControllerID(installedtargets.stream().map(Target::getControllerId).collect(Collectors.toList())); assertThat(targetManagement.findByInstalledDistributionSet(PAGE, installedSet.getId())) .as("Contains the assigned targets").containsAll(installedtargets) .as("and that means the following expected amount").hasSize(10); }
Example #14
Source File: AmqpMessageHandlerServiceIntegrationTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Verify that sending an update controller attribute message with invalid body to an existing target does not work.") @ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 0), @Expect(type = TargetPollEvent.class, count = 1)}) public void updateAttributesWithWrongBody() { // setup final String target = "ControllerAttributeTestTarget"; registerAndAssertTargetWithExistingTenant(target); final DmfAttributeUpdate controllerAttribute = new DmfAttributeUpdate(); controllerAttribute.getAttributes().put("test1", "testA"); controllerAttribute.getAttributes().put("test2", "testB"); final Message createUpdateAttributesMessageWrongBody = createUpdateAttributesMessageWrongBody(target, TENANT_EXIST); // test getDmfClient().send(createUpdateAttributesMessageWrongBody); // verify verifyOneDeadLetterMessage(); }
Example #15
Source File: DistributionSetTypeManagementTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Tests the successful module update of unused distribution set type which is in fact allowed.") public void updateUnassignedDistributionSetTypeModules() { final DistributionSetType updatableType = distributionSetTypeManagement .create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted")); assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty(); // add OS distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(), Sets.newHashSet(osType.getId())); assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()) .containsOnly(osType); // add JVM distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(), Sets.newHashSet(runtimeType.getId())); assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()) .containsOnly(osType, runtimeType); // remove OS distributionSetTypeManagement.unassignSoftwareModuleType(updatableType.getId(), osType.getId()); assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()) .containsOnly(runtimeType); }
Example #16
Source File: TargetFilterQueriesResourceDocumentationTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Handles the POST request of setting a distribution set for auto assignment within SP. Required Permission: CREATE_TARGET.") public void postAutoAssignDS() throws Exception { enableMultiAssignments(); final TargetFilterQuery tfq = createTargetFilterQuery(); final DistributionSet distributionSet = createDistributionSet(); final String autoAssignBody = new JSONObject().put("id", distributionSet.getId()) .put("type", MgmtActionType.SOFT.getName()).put("weight", 200).toString(); this.mockMvc .perform( post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", tfq.getId()).contentType(MediaType.APPLICATION_JSON).content(autoAssignBody.toString())) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters(parameterWithName("targetFilterQueryId") .description(ApiModelPropertiesGeneric.ITEM_ID)), requestFields(requestFieldWithPath("id").description(MgmtApiModelProperties.DS_ID), optionalRequestFieldWithPath("type") .description(MgmtApiModelProperties.ACTION_FORCE_TYPE) .attributes(key("value").value("['forced', 'soft', 'downloadonly']")), requestFieldWithPathMandatoryInMultiAssignMode("weight") .description(MgmtApiModelProperties.RESULTING_ACTIONS_WEIGHT) .attributes(key("value").value("0 - 1000"))), getResponseFieldTargetFilterQuery(false))); }
Example #17
Source File: TargetFilterQueriesResourceDocumentationTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Handles the POST request of creating a new target filter query within SP. Required Permission: CREATE_TARGET.") public void postTargetFilterQuery() throws Exception { final String tfqJson = createTargetFilterQueryJson(EXAMPLE_TFQ_NAME, EXAMPLE_TFQ_QUERY); this.mockMvc .perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING) .contentType(MediaType.APPLICATION_JSON).content(tfqJson)) .andExpect(status().isCreated()).andDo(MockMvcResultPrinter.print()).andDo( this.document.document( requestFields(requestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), requestFieldWithPath("query") .description(MgmtApiModelProperties.TARGET_FILTER_QUERY)), getResponseFieldTargetFilterQuery(false))); }
Example #18
Source File: PropertyBasedArtifactUrlHandlerTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Tests the generation of custom download url with a CoAP example that supports DMF only.") public void urlGenerationWithCustomConfiguration() { final UrlProtocol proto = new UrlProtocol(); proto.setIp("127.0.0.1"); proto.setPort(5683); proto.setProtocol(TEST_PROTO); proto.setRel(TEST_REL); proto.setSupports(Arrays.asList(ApiType.DMF)); proto.setRef("{protocol}://{ip}:{port}/fw/{tenant}/{controllerId}/sha1/{artifactSHA1}"); properties.getProtocols().put(TEST_PROTO, proto); List<ArtifactUrl> urls = urlHandlerUnderTest.getUrls(placeholder, ApiType.DDI); assertThat(urls).isEmpty(); urls = urlHandlerUnderTest.getUrls(placeholder, ApiType.DMF); assertThat(urls).containsExactly(new ArtifactUrl(TEST_PROTO.toUpperCase(), TEST_REL, "coap://127.0.0.1:5683/fw/" + TENANT + "/" + CONTROLLER_ID + "/sha1/" + SHA1HASH)); }
Example #19
Source File: DeploymentManagementTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Test verifies that the 'max actions per target' quota is enforced.") public void assertMaxActionsPerTargetQuotaIsEnforced() { final int maxActions = quotaManagement.getMaxActionsPerTarget(); final Target testTarget = testdataFactory.createTarget(); final DistributionSet ds1 = testdataFactory.createDistributionSet("ds1"); enableMultiAssignments(); for (int i = 0; i < maxActions; i++) { deploymentManagement.offlineAssignedDistributionSets(Collections .singletonList(new SimpleEntry<String, Long>(testTarget.getControllerId(), ds1.getId()))); } assertThatExceptionOfType(AssignmentQuotaExceededException.class) .isThrownBy(() -> assignDistributionSet(ds1.getId(), testTarget.getControllerId(), 77)); }
Example #20
Source File: S3RepositoryTest.java From hawkbit-extensions with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Verifies that the amazonS3 client is not called to put the object to S3 due the artifact already exists on S3") public void artifactIsNotUploadedIfAlreadyExists() throws NoSuchAlgorithmException, IOException { final byte[] rndBytes = randomBytes(); final String knownSHA1 = getSha1OfBytes(rndBytes); final String knownContentType = "application/octet-stream"; when(amazonS3Mock.putObject(any(), any(), any(), any())).thenReturn(putObjectResultMock); // test storeRandomBytes(rndBytes, knownContentType); // verify Mockito.verify(amazonS3Mock, never()).putObject(eq(s3Properties.getBucketName()), eq(knownSHA1), inputStreamCaptor.capture(), objectMetaDataCaptor.capture()); }
Example #21
Source File: AmqpMessageHandlerServiceIntegrationTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Register a target and send a valid update action status (cancel_rejected). Verfiy if the updated action status is correct.") @ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1)}) public void canceledRejectedActionStatus() { final String controllerId = TARGET_PREFIX + "canceledRejectedActionStatus"; final Long actionId = registerTargetAndCancelActionId(controllerId); sendActionUpdateStatus(new DmfActionUpdateStatus(actionId, DmfActionStatus.CANCEL_REJECTED)); assertAction(actionId, 1, Status.RUNNING, Status.CANCELING, Status.CANCEL_REJECTED); }
Example #22
Source File: MgmtTargetFilterQueryResourceTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Ensures that update request is reflected by repository.") public void updateTargetFilterQueryQuery() throws Exception { final String filterName = "filter_02"; final String filterQuery = "name=test_02"; final String filterQuery2 = "name=test_02_changed"; final String body = new JSONObject().put("query", filterQuery2).toString(); // prepare final TargetFilterQuery tfq = createSingleTargetFilterQuery(filterName, filterQuery); mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId()).content(body) .contentType(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_ID, equalTo(tfq.getId().intValue()))) .andExpect(jsonPath(JSON_PATH_QUERY, equalTo(filterQuery2))) .andExpect(jsonPath(JSON_PATH_NAME, equalTo(filterName))); final TargetFilterQuery tfqCheck = targetFilterQueryManagement.get(tfq.getId()).get(); assertThat(tfqCheck.getQuery()).isEqualTo(filterQuery2); assertThat(tfqCheck.getName()).isEqualTo(filterName); }
Example #23
Source File: ControllerManagementTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Register a controller which does not exist, when a ConcurrencyFailureException is raised, the " + "exception is rethrown after max retries") public void findOrRegisterTargetIfItDoesNotExistThrowsExceptionAfterMaxRetries() { final TargetRepository mockTargetRepository = Mockito.mock(TargetRepository.class); when(mockTargetRepository.findOne(any())).thenThrow(ConcurrencyFailureException.class); ((JpaControllerManagement) controllerManagement).setTargetRepository(mockTargetRepository); try { assertThatExceptionOfType(ConcurrencyFailureException.class) .as("Expected an ConcurrencyFailureException to be thrown!") .isThrownBy(() -> controllerManagement.findOrRegisterTargetIfItDoesNotExist("AA", LOCALHOST)); verify(mockTargetRepository, times(TX_RT_MAX)).findOne(any()); } finally { // revert ((JpaControllerManagement) controllerManagement).setTargetRepository(targetRepository); } }
Example #24
Source File: AmqpMessageHandlerServiceIntegrationTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Verify receiving a download_and_install message if a deployment is done with window configured and during maintenance window start time.") @ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2)}) public void receiveDownloadAndInstallMessageDuringMaintenanceWindow() { final String controllerId = TARGET_PREFIX + "receiveDownLoadAndInstallMessageDuringMaintenanceWindow"; // setup registerAndAssertTargetWithExistingTenant(controllerId); final DistributionSet distributionSet = testdataFactory.createDistributionSet(UUID.randomUUID().toString()); testdataFactory.addSoftwareModuleMetadata(distributionSet); assignDistributionSetWithMaintenanceWindow(distributionSet.getId(), controllerId, getTestSchedule(-5), getTestDuration(10), getTestTimeZone()); // test registerSameTargetAndAssertBasedOnVersion(controllerId, 1, TargetUpdateStatus.PENDING); // verify assertDownloadAndInstallMessage(distributionSet.getModules(), controllerId); Mockito.verifyZeroInteractions(getDeadletterListener()); }
Example #25
Source File: AmqpMessageHandlerServiceTest.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Test @Description("Tests a invalid message without event topic") public void invalidEventTopic() { final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final Message message = new Message(new byte[0], messageProperties); assertThatExceptionOfType(AmqpRejectAndDontRequeueException.class) .as(FAIL_MESSAGE_AMQP_REJECT_REASON + "due to unknown message type").isThrownBy( () -> amqpMessageHandlerService.onMessage(message, "unknownMessageType", TENANT, VIRTUAL_HOST)); messageProperties.setHeader(MessageHeaderKey.TOPIC, "wrongTopic"); assertThatExceptionOfType(AmqpRejectAndDontRequeueException.class) .as(FAIL_MESSAGE_AMQP_REJECT_REASON + "due to unknown topic").isThrownBy(() -> amqpMessageHandlerService .onMessage(message, MessageType.EVENT.name(), TENANT, VIRTUAL_HOST)); messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.CANCEL_DOWNLOAD.name()); assertThatExceptionOfType(AmqpRejectAndDontRequeueException.class) .as(FAIL_MESSAGE_AMQP_REJECT_REASON + "because there was no event topic") .isThrownBy(() -> amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, VIRTUAL_HOST)); }
Example #26
Source File: DistributionSetTagResourceDocumentationTest.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
@Test @Description("Handles the DELETE request for a single distribution set tag") public void deleteDistributionSetTag() throws Exception { final Long tagId = createDistributionSetTagId(); this.mockMvc .perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{distributionsetTagId}", tagId).contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document(pathParameters( parameterWithName("distributionsetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)))); }
Example #27
Source File: TargetFilterQueriesResourceDocumentationTest.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
@Test @Description("Handles the GET request of retrieving all target filter queries within SP. Required Permission: READ_TARGET.") public void getTargetFilterQueries() throws Exception { createTargetFilterQueryWithDS(createDistributionSet()); mockMvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING)).andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()) .andDo(this.document.document(responseFields( fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), fieldWithPath("content").description(MgmtApiModelProperties.TARGET_FILTER_QUERIES_LIST), fieldWithPath("content[].id").description(ApiModelPropertiesGeneric.ITEM_ID), fieldWithPath("content[].name").description(ApiModelPropertiesGeneric.NAME), fieldWithPath("content[].query").description(MgmtApiModelProperties.TARGET_FILTER_QUERY), fieldWithPath("content[].autoAssignDistributionSet") .description(MgmtApiModelProperties.TARGET_FILTER_QUERY_AUTO_ASSIGN_DS_ID) .type(JsonFieldType.NUMBER.toString()), fieldWithPath("content[].autoAssignActionType") .description(MgmtApiModelProperties.ACTION_FORCE_TYPE) .type(JsonFieldType.STRING.toString()) .attributes(key("value").value("['forced', 'soft', 'downloadonly']")), fieldWithPath("content[].createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), fieldWithPath("content[].createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), fieldWithPath("content[].lastModifiedAt") .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), fieldWithPath("content[].lastModifiedBy") .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), fieldWithPath("content[]._links.self").ignored()))); }
Example #28
Source File: MgmtRolloutResourceTest.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
@Test @Description("Testing that starting rollout the first rollout group is in running state") public void startingRolloutFirstRolloutGroupIsInRunningState() throws Exception { // setup final int amountTargets = 10; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); // create rollout including the created targets with prefix 'rollout' final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*"); // starting rollout mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // Run here, because scheduler is disabled during tests rolloutManagement.handleRollouts(); // retrieve rollout groups from created rollout - 2 groups exists // (amountTargets / groupSize = 2) mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups?sort=ID:ASC", rollout.getId()) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.content", hasSize(2))).andExpect(jsonPath("$.total", equalTo(2))) .andExpect(jsonPath("$.content[0].status", equalTo("running"))) .andExpect(jsonPath("$.content[1].status", equalTo("scheduled"))); }
Example #29
Source File: MgmtSoftwareModuleResourceTest.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
@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 { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final int artifactSize = 5 * 1024; final byte random[] = randomBytes(artifactSize); final Artifact artifact = artifactManagement .create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize)); final Artifact artifact2 = artifactManagement .create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file2", false, artifactSize)); mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[0].id", equalTo(artifact.getId().intValue()))) .andExpect(jsonPath("$.[0].size", equalTo(random.length))) .andExpect(jsonPath("$.[0].hashes.md5", equalTo(artifact.getMd5Hash()))) .andExpect(jsonPath("$.[0].hashes.sha1", equalTo(artifact.getSha1Hash()))) .andExpect(jsonPath("$.[0].hashes.sha256", equalTo(artifact.getSha256Hash()))) .andExpect(jsonPath("$.[0].providedFilename", equalTo("file1"))) .andExpect(jsonPath("$.[0]._links.self.href", equalTo("http://localhost/rest/v1/softwaremodules/" + sm.getId() + "/artifacts/" + artifact.getId()))) .andExpect(jsonPath("$.[1].id", equalTo(artifact2.getId().intValue()))) .andExpect(jsonPath("$.[1].hashes.md5", equalTo(artifact2.getMd5Hash()))) .andExpect(jsonPath("$.[1].hashes.sha1", equalTo(artifact2.getSha1Hash()))) .andExpect(jsonPath("$.[1].hashes.sha256", equalTo(artifact2.getSha256Hash()))) .andExpect(jsonPath("$.[1].providedFilename", equalTo("file2"))) .andExpect(jsonPath("$.[1]._links.self.href", equalTo( "http://localhost/rest/v1/softwaremodules/" + sm.getId() + "/artifacts/" + artifact2.getId()))); }
Example #30
Source File: AmqpMessageDispatcherServiceTest.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
@Test @Description("Verifies that sending update controller attributes event works.") public void sendUpdateAttributesRequest() { final String amqpUri = "amqp://anyhost"; final TargetAttributesRequestedEvent targetAttributesRequestedEvent = new TargetAttributesRequestedEvent(TENANT, 1L, CONTROLLER_ID, amqpUri, Target.class.getName(), serviceMatcher.getServiceId()); amqpMessageDispatcherService.targetTriggerUpdateAttributes(targetAttributesRequestedEvent); final Message sendMessage = createArgumentCapture(URI.create(amqpUri)); assertUpdateAttributesMessage(sendMessage); }