public async Task GET_Many_With_BusinessTypeFilter() { //Arrange var(token, _) = await CreateStakeHolderUserInNewOrganizationAsync(); var businessType1 = A <string>(); var businessType2 = A <string>(); const int organizationId = TestEnvironment.DefaultOrganizationId; var correctBusinessType = await EntityOptionHelper.CreateBusinessTypeAsync(businessType1, organizationId); var incorrectBusinessType = await EntityOptionHelper.CreateBusinessTypeAsync(businessType2, organizationId); var correctBusinessTypeId = TestEnvironment.GetEntityUuid <BusinessType>(correctBusinessType.Id); var unexpectedWrongBusinessType = await CreateSystemAsync(organizationId, AccessModifier.Public); var expected = await CreateSystemAsync(organizationId, AccessModifier.Public); using var setBt1 = await ItSystemHelper.SendSetBusinessTypeRequestAsync(expected.dbId, correctBusinessType.Id, organizationId); using var setBt2 = await ItSystemHelper.SendSetBusinessTypeRequestAsync(unexpectedWrongBusinessType.dbId, incorrectBusinessType.Id, organizationId); Assert.Equal(HttpStatusCode.OK, setBt1.StatusCode); Assert.Equal(HttpStatusCode.OK, setBt2.StatusCode); //Act var systems = (await ItSystemV2Helper.GetManyAsync(token, businessTypeId: correctBusinessTypeId)).ToList(); //Assert var dto = Assert.Single(systems); Assert.Equal(dto.Uuid, expected.uuid); }
public async Task Can_Get_SpecificBusinessType_That_Is_Available() { //Arrange var orgId = TestEnvironment.DefaultOrganizationId; var businessTypeName = A <string>(); var createdBusinessType = await EntityOptionHelper.CreateBusinessTypeAsync(businessTypeName, orgId); var organisation = await OrganizationHelper.GetOrganizationAsync(orgId); var businessTypes = await BusinessTypeV2Helper.GetBusinessTypesAsync(organisation.Uuid.Value, 100, 0); //100 should be more than enough to get all. var businessType = businessTypes.Where(x => x.Name.Equals(businessTypeName)).First(); //Get the newly created businessType. //Act var businessTypeResult = await BusinessTypeV2Helper.GetBusinessTypeAsync(businessType.Uuid, organisation.Uuid.Value); //Assert Assert.Equal(businessTypeName, businessTypeResult.Name); Assert.Equal(businessType.Uuid, businessTypeResult.Uuid); Assert.True(businessTypeResult.IsAvailable); }
public async Task GET_ItSystem_Returns_Expected_Data() { //Arrange var(token, _) = await CreateStakeHolderUserInNewOrganizationAsync(); var rightsHolderOrganization = await CreateOrganizationAsync(); var organizationId = TestEnvironment.DefaultOrganizationId; var system = await CreateSystemAsync(organizationId, AccessModifier.Public); var parentSystem = await CreateSystemAsync(organizationId, AccessModifier.Public); var businessType = await EntityOptionHelper.CreateBusinessTypeAsync(CreateName(), organizationId); var businessTypeUuid = TestEnvironment.GetEntityUuid <BusinessType>(businessType.Id); var exposedInterface = await InterfaceHelper.CreateInterface(InterfaceHelper.CreateInterfaceDto(A <string>(), A <string>(), organizationId, AccessModifier.Public)); DatabaseAccess.MutateDatabase(db => { var itSystem = db.ItSystems.AsQueryable().ByUuid(system.uuid); var interfaceToExpose = db.Set <ItInterface>().AsQueryable().ById(exposedInterface.Id); var taskRef = db.TaskRefs.AsQueryable().First(); itSystem.PreviousName = A <string>(); itSystem.Description = A <string>(); itSystem.Disabled = A <bool>(); itSystem.ArchiveDuty = A <ArchiveDutyRecommendationTypes>(); itSystem.ArchiveDutyComment = A <string>(); itSystem.ParentId = parentSystem.dbId; itSystem.BelongsToId = rightsHolderOrganization.Id; itSystem.BusinessTypeId = businessType.Id; itSystem.TaskRefs.Add(taskRef); db.ItInterfaceExhibits.Add(new ItInterfaceExhibit { ItInterface = interfaceToExpose, ItSystem = itSystem, ObjectOwnerId = 1, LastChangedByUserId = 1 }); var externalReference = new ExternalReference() { ObjectOwnerId = 1, LastChangedByUserId = 1, ItSystem = itSystem, Title = A <string>(), URL = A <string>() }; db.ExternalReferences.Add(externalReference); itSystem.SetMasterReference(externalReference); db.SaveChanges(); }); //Act var systemDTO = await ItSystemV2Helper.GetSingleAsync(token, system.uuid); //Assert - compare db entity with the response DTO Assert.NotNull(systemDTO); DatabaseAccess.MapFromEntitySet <Core.DomainModel.ItSystem.ItSystem, bool>(x => { var dbSystem = x.AsQueryable().ByUuid(system.uuid); var parentDbSystem = x.AsQueryable().ByUuid(parentSystem.uuid); var taskRef = dbSystem.TaskRefs.Single(); var dbExposedInterface = dbSystem.ItInterfaceExhibits.Single().ItInterface; Assert.Equal(dbSystem.Uuid, systemDTO.Uuid); Assert.Equal(dbSystem.Name, systemDTO.Name); Assert.Equal(dbSystem.Description, systemDTO.Description); Assert.Equal(dbSystem.PreviousName, systemDTO.FormerName); Assert.Equal(dbSystem.Disabled, systemDTO.Deactivated); Assert.Equal(dbSystem.Created, systemDTO.Created); Assert.Equal(dbSystem.ObjectOwner.Uuid, systemDTO.CreatedBy.Uuid); Assert.Equal(dbSystem.ObjectOwner.GetFullName(), systemDTO.CreatedBy.Name); Assert.Equal(dbSystem.LastChanged, systemDTO.LastModified); Assert.Equal(dbSystem.LastChangedByUser.Uuid, systemDTO.LastModifiedBy.Uuid); Assert.Equal(dbSystem.LastChangedByUser.GetFullName(), systemDTO.LastModifiedBy.Name); Assert.Equal(dbSystem.ArchiveDuty?.ToString("G"), systemDTO.RecommendedArchiveDutyResponse.Id.ToString("G")); Assert.Equal(dbSystem.ArchiveDutyComment, systemDTO.RecommendedArchiveDutyResponse.Comment); Assert.Equal(parentDbSystem.Uuid, systemDTO.ParentSystem.Uuid); Assert.Equal(parentDbSystem.Name, systemDTO.ParentSystem.Name); Assert.Equal(rightsHolderOrganization.Uuid, systemDTO.RightsHolder.Uuid); Assert.Equal(rightsHolderOrganization.Name, systemDTO.RightsHolder.Name); Assert.Equal(rightsHolderOrganization.GetActiveCvr(), systemDTO.RightsHolder.Cvr); Assert.Equal(businessTypeUuid, systemDTO.BusinessType.Uuid); Assert.Equal(businessType.Name, systemDTO.BusinessType.Name); Assert.Equal(taskRef.Uuid, systemDTO.KLE.Single().Uuid); Assert.Equal(taskRef.TaskKey, systemDTO.KLE.Single().Name); Assert.Equal(dbExposedInterface.Uuid, systemDTO.ExposedInterfaces.Single().Uuid); Assert.Equal(dbExposedInterface.Name, systemDTO.ExposedInterfaces.Single().Name); Assert.Equal(dbSystem.Reference.URL, systemDTO.UrlReference); return(true); }); }