public async Task And_Application_Exists_Stitches_Up_Standard_To_Result( GetApplicationQuery getApplicationQuery, GetApplicationResponse getApplicationResponse, GetStandardsListItem getStandardsListItem, GetCohortsResponse getCohortsResponse, [Frozen] Mock <ICoursesApiClient <CoursesApiConfiguration> > mockCoursesApiClient, [Frozen] Mock <ILevyTransferMatchingService> mockLevyTransferMatchingService, [Frozen] Mock <ICommitmentsV2ApiClient <CommitmentsV2ApiConfiguration> > mockCommitmentsV2ApiClient, GetApplicationQueryHandler getApplicationQueryHandler) { mockLevyTransferMatchingService .Setup(x => x.GetApplication(It.Is <GetApplicationRequest>(y => y.GetUrl.Contains(getApplicationQuery.ApplicationId.ToString())))) .ReturnsAsync(getApplicationResponse); mockCoursesApiClient .Setup(x => x.Get <GetStandardsListItem>(It.Is <GetStandardDetailsByIdRequest>(y => y.GetUrl.Contains(getApplicationResponse.StandardId)))) .ReturnsAsync(getStandardsListItem); mockCommitmentsV2ApiClient .Setup(x => x.Get <GetCohortsResponse>(It.Is <GetCohortsRequest>(y => y.GetUrl.Contains(getApplicationQuery.AccountId.ToString())))) .ReturnsAsync(getCohortsResponse); var result = await getApplicationQueryHandler.Handle(getApplicationQuery, CancellationToken.None); Assert.IsNotNull(result); Assert.AreEqual(getApplicationResponse.Status, result.Status); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetApplicationResponse response = new GetApplicationResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Description", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Description = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Id", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Id = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Name", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Name = unmarshaller.Unmarshall(context); continue; } } return(response); }
public GetApplicationResponse GetApplications(GetApplicationRequest request) { GetApplicationResponse response = new GetApplicationResponse(); response.IsTrue = false; response.Status = 0; if (request != null) { try { //验证Token string tokenMsg = ""; AppSettingInfo app = ApiHelper.VerifyTokenAndGetApp(request.Token, out tokenMsg); if (app != null) { //AES验证签名 if (ApiHelper.AESEncrypt(request.Token, request.TimeStamp, app.Seed) != request.Sign) { response.Msg = "签名验证不通过!"; return(response); } //验证API访问权限 if (ApiHelper.InterfaceRightCheck(app.AppSettingID)) { response.Msg = "无访问接口权限,请联系管理员"; return(response); } List <AppSettingInfoSimple> appList = SystemFactory.Instance.GetAllAppConfig(); response.IsTrue = true; response.Status = 1; response.Msg = "请求成功"; response.Data = appList; } else { response.Msg = tokenMsg; } } catch (Exception ex) { response.Msg = ex.Message; } } else { response.Msg = "非法请求,请重试!"; } return(response); }
public async Task Should_get_Application_object() { // Arrange var getApplicationRequest = new GetApplicationRequest(); // Act GetApplicationResponse getApplicationResponse = await SendAsync(getApplicationRequest); // Assert getApplicationResponse.ShouldNotBeNull(); ApplicationDto application = getApplicationResponse.Application; application.Name.ShouldBe(DbInitializer.ApplicationName); application.Version.ShouldBe(DbInitializer.ApplicationVersion); }
public async Task And_Application_Exists_Response_Returned( GetWithdrawalConfirmationQuery getWithdrawalConfirmationQuery, GetApplicationResponse getApplicationResponse, [Frozen] Mock <ILevyTransferMatchingService> mockLevyTransferMatchingService, GetWithdrawalConfirmationQueryHandler getWithdrawalConfirmationQueryHandler) { mockLevyTransferMatchingService .Setup(x => x.GetApplication(It.Is <GetApplicationRequest>(y => y.GetUrl.Contains(getWithdrawalConfirmationQuery.ApplicationId.ToString())))) .ReturnsAsync(getApplicationResponse); var result = await getWithdrawalConfirmationQueryHandler.Handle(getWithdrawalConfirmationQuery, CancellationToken.None); Assert.IsNotNull(result); Assert.AreEqual(getApplicationResponse.SenderEmployerAccountName, result.PledgeEmployerName); }
public async Task And_Application_Exists_And_No_Specific_Locations_Returned_Stitches_Up_Standard_And_Location_To_Result( GetApplicationQuery getApplicationQuery, GetApplicationResponse getApplicationResponse, [Frozen] Mock <ILevyTransferMatchingService> mockLevyTransferMatchingService, GetApplicationQueryHandler getApplicationQueryHandler) { mockLevyTransferMatchingService .Setup(x => x.GetApplication(It.Is <GetApplicationRequest>(y => y.GetUrl.Contains(getApplicationQuery.PledgeId.ToString()) && y.GetUrl.Contains(getApplicationQuery.ApplicationId.ToString())))) .ReturnsAsync(getApplicationResponse); var result = await getApplicationQueryHandler.Handle(getApplicationQuery, CancellationToken.None); Assert.IsNotNull(result); Assert.AreEqual(getApplicationResponse.Details, result.AboutOpportunity); }
public async Task Then_error_returned_when_the_account_does_not_exist() { // Arrange const long accountId = 7; var applicationId = Guid.NewGuid(); var expected = new GetApplicationResponse(null); _queryDispatcherMock.Setup(x => x.Send <GetApplicationRequest, GetApplicationResponse>( It.Is <GetApplicationRequest>(r => r.AccountId == accountId && r.ApplicationId == applicationId))) .ReturnsAsync(expected); // Act var actual = await _sut.GetApplication(accountId, applicationId) as NotFoundResult; // Assert actual.Should().NotBeNull(); }
public void GetApplicationValidateMessage() { var utcNow = DateTime.UtcNow; HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Created) { StatusCode = HttpStatusCode.OK, Content = new StringContent(@"{ 'id': 'foo', 'allowUpdates': 'true', 'displayName' : 'displayName', 'defaultVersion' : 'beta', 'packages':[ {'version':'fooVersion', 'state':'pending', 'format': 'betaFormat', 'lastActivationTime': '" + utcNow.ToString("o") + @"'}], }") }; response.Headers.Add("x-ms-request-id", "1"); var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK }; var client = GetBatchManagementClient(handler); GetApplicationResponse result = client.Applications.GetApplication("applicationId", "acctName", "id"); // Validate headers - User-Agent for certs, Authorization for tokens Assert.Equal(HttpMethod.Get, handler.Method); Assert.NotNull(handler.RequestHeaders.GetValues("User-Agent")); // Validate result Assert.Equal(HttpStatusCode.OK, result.StatusCode); Assert.Equal("foo", result.Application.Id); Assert.Equal(true, result.Application.AllowUpdates); Assert.Equal("beta", result.Application.DefaultVersion); Assert.Equal("displayName", result.Application.DisplayName); Assert.Equal(1, result.Application.ApplicationPackages.Count); Assert.Equal("betaFormat", result.Application.ApplicationPackages.First().Format); Assert.Equal(PackageState.Pending, result.Application.ApplicationPackages.First().State); Assert.Equal("fooVersion", result.Application.ApplicationPackages.First().Version); Assert.Equal(utcNow, result.Application.ApplicationPackages.First().LastActivationTime); }
public async Task Then_the_application_is_returned() { // Arrange const long accountId = 7; var applicationId = Guid.NewGuid(); var expected = new GetApplicationResponse(_fixture.Create <IncentiveApplicationDto>()); _queryDispatcherMock.Setup(x => x.Send <GetApplicationRequest, GetApplicationResponse>( It.Is <GetApplicationRequest>(r => r.AccountId == accountId && r.ApplicationId == applicationId))) .ReturnsAsync(expected); // Act var actual = await _sut.GetApplication(accountId, applicationId) as OkObjectResult; // Assert actual.Should().NotBeNull(); actual.Value.Should().Be(expected.Application); }
public async Task Then_data_is_fetched_via_data_repository() { //Arrange var query = _fixture.Create <GetApplicationRequest>(); var apprenticeship = _fixture.Build <IncentiveApplicationApprenticeshipDto>().With(x => x.Phase, Enums.Phase.Phase1).With(x => x.PlannedStartDate, new DateTime(2020, 9, 1)).Create(); var data = _fixture.Build <IncentiveApplicationDto>().With(x => x.Apprenticeships, new List <IncentiveApplicationApprenticeshipDto> { apprenticeship }).Create(); var expected = new GetApplicationResponse(data); _applicationRepository.Setup(x => x.Get(dto => dto.Id == query.ApplicationId && dto.AccountId == query.AccountId)).ReturnsAsync(data); //Act var result = await _sut.Handle(query, CancellationToken.None); //Assert result.Should().BeEquivalentTo(expected); }
public async Task And_Application_Exists_Response_Returned( GetAcceptedQuery getAcceptedQuery, GetApplicationResponse getApplicationResponse, Models.Pledge pledgeResponse, [Frozen] Mock <ILevyTransferMatchingService> mockLevyTransferMatchingService, GetAcceptedQueryHandler getAcceptedQueryHandler) { mockLevyTransferMatchingService .Setup(x => x.GetApplication(It.Is <GetApplicationRequest>(y => y.GetUrl.Contains(getAcceptedQuery.ApplicationId.ToString())))) .ReturnsAsync(getApplicationResponse); mockLevyTransferMatchingService .Setup(x => x.GetPledge(It.Is <int>(y => y == getApplicationResponse.PledgeId))) .ReturnsAsync(pledgeResponse); var result = await getAcceptedQueryHandler.Handle(getAcceptedQuery, CancellationToken.None); Assert.IsNotNull(result); Assert.AreEqual(pledgeResponse.DasAccountName, result.EmployerAccountName); }
public void Setup() { _debitApplicationCommand = _fixture.Create <DebitApplicationCommand>(); _getApplicationResponse = _fixture.Create <GetApplicationResponse>(); _coursesApiResponse = _fixture.Create <GetStandardsListItem>(); var applicationApiResponse = new ApiResponse <DebitApplicationRequest>(new DebitApplicationRequest(_debitApplicationCommand.ApplicationId, new DebitApplicationRequest.DebitApplicationRequestData()), HttpStatusCode.OK, string.Empty); _levyTransferMatchingService = new Mock <ILevyTransferMatchingService>(); _coursesApiClient = new Mock <ICoursesApiClient <CoursesApiConfiguration> >(); _levyTransferMatchingService.Setup(x => x.GetApplication(It.Is <GetApplicationRequest>(y => y.GetUrl.Contains(_debitApplicationCommand.ApplicationId.ToString())))) .ReturnsAsync(_getApplicationResponse); _levyTransferMatchingService.Setup(x => x.DebitApplication(It.IsAny <DebitApplicationRequest>())) .Callback <DebitApplicationRequest>(r => _debitApplicationRequest = r) .ReturnsAsync(applicationApiResponse); _coursesApiClient.Setup(x => x.Get <GetStandardsListItem>(It.Is <GetStandardDetailsByIdRequest>(y => y.GetUrl.Contains(_getApplicationResponse.StandardId)))) .ReturnsAsync(_coursesApiResponse); _handler = new DebitApplicationCommandHandler(_levyTransferMatchingService.Object, _coursesApiClient.Object); }
public GetApplicationResponse Get(GetApplicationRequest request) { GetApplicationResponse resp = new GetApplicationResponse(); using (var con = TenantDbFactory.DataDB.GetNewConnection()) { string sql = ""; if (request.id > 0) { sql = "SELECT * FROM eb_applications WHERE id = @id"; } else { sql = "SELECT id, applicationname FROM eb_applications"; } DbParameter[] parameters = { this.TenantDbFactory.ObjectsDB.GetNewParameter("id", System.Data.DbType.Int32, request.id) }; var dt = this.TenantDbFactory.ObjectsDB.DoQuery(sql, parameters); Dictionary <string, object> Dict = new Dictionary <string, object>(); if (dt.Rows.Count > 1) { foreach (var dr in dt.Rows) { Dict.Add(dr[0].ToString(), dr[1]); } } else if (dt.Rows.Count == 1) { Dict.Add("applicationname", dt.Rows[0][0]); Dict.Add("description", dt.Rows[0][1]); } resp.Data = Dict; } return(resp); }
public async Task <GetApplicationResponse> GetApplicationsAsync() { using (var request = new HttpRequestMessage(HttpMethod.Get, path)) { var httpclient = services.GetService <IHttpClientFactory>(); var client = httpclient.CreateClient("AdminAuth"); using (HttpResponseMessage result = await client.SendAsync(request)) { if (result.IsSuccessStatusCode) { var parsedJson = JsonConvert.DeserializeObject <List <Models.ApplicationModel> >(await result.Content.ReadAsStringAsync()); GetApplicationResponse applicationModel = new GetApplicationResponse(true, parsedJson); return(applicationModel); } else { var parsedJson = JsonConvert.DeserializeObject <RequestError>(await result.Content.ReadAsStringAsync()); GetApplicationResponse applicationModel = new GetApplicationResponse(false, parsedJson); return(applicationModel); } } } }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetApplicationResponse response = new GetApplicationResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("ApiGatewayProxy", targetDepth)) { var unmarshaller = ApiGatewayProxyConfigUnmarshaller.Instance; response.ApiGatewayProxy = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("ApplicationId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.ApplicationId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Arn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Arn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("CreatedByAccountId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.CreatedByAccountId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("CreatedTime", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.CreatedTime = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("EnvironmentId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.EnvironmentId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Error", targetDepth)) { var unmarshaller = ErrorResponseUnmarshaller.Instance; response.Error = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("LastUpdatedTime", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.LastUpdatedTime = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Name", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Name = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("OwnerAccountId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.OwnerAccountId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("ProxyType", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.ProxyType = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("State", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.State = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Tags", targetDepth)) { var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance); response.Tags = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("VpcId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.VpcId = unmarshaller.Unmarshall(context); continue; } } return(response); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetApplicationResponse response = new GetApplicationResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("applicationId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.ApplicationId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("author", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Author = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("creationTime", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.CreationTime = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("description", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Description = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("homePageUrl", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.HomePageUrl = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("isVerifiedAuthor", targetDepth)) { var unmarshaller = BoolUnmarshaller.Instance; response.IsVerifiedAuthor = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("labels", targetDepth)) { var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance); response.Labels = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("licenseUrl", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.LicenseUrl = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("name", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Name = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("readmeUrl", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.ReadmeUrl = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("spdxLicenseId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.SpdxLicenseId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("verifiedAuthorUrl", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.VerifiedAuthorUrl = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("version", targetDepth)) { var unmarshaller = VersionUnmarshaller.Instance; response.Version = unmarshaller.Unmarshall(context); continue; } } return(response); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetApplicationResponse response = new GetApplicationResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("arn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Arn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("associatedResourceCount", targetDepth)) { var unmarshaller = IntUnmarshaller.Instance; response.AssociatedResourceCount = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("creationTime", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.CreationTime = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("description", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Description = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("id", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Id = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("integrations", targetDepth)) { var unmarshaller = IntegrationsUnmarshaller.Instance; response.Integrations = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("lastUpdateTime", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.LastUpdateTime = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("name", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Name = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("tags", targetDepth)) { var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance); response.Tags = unmarshaller.Unmarshall(context); continue; } } return(response); }