protected static void Establish_context() { entity = PartyRoleData.CreateBasicEntity(); var notAMapping = new OpenNexus.MDM.Contracts.PartyRole(); content = HttpContentExtensions.CreateDataContract(notAMapping); client = new HttpClient(); }
public void VersionConflict() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new PartyRoleService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var message = new AmendMappingRequest { MappingId = 12, Mapping = new MdmId { SystemName = "Test", Identifier = "A" }, Version = 34 }; var party = new MDM.PartyRole(); party.AddDetails(new PartyRoleDetails() { Timestamp = BitConverter.GetBytes(25L) }); var mapping = new PartyRoleMapping { PartyRole = party }; validatorFactory.Setup(x => x.IsValid(It.IsAny <AmendMappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true); repository.Setup(x => x.FindOne <PartyRoleMapping>(12)).Returns(mapping); // Act service.UpdateMapping(message); }
protected static void Establish_context() { client = new HttpClient(); entity = PartyRoleData.CreateBasicEntity(); content = HttpContentExtensions.CreateDataContract(new OpenNexus.MDM.Contracts.PartyRole()); startVersion = CurrentEntityVersion(); }
protected static void Establish_context() { entity = PartyRoleData.CreateBasicEntityWithOneMapping(); client = new HttpClient(); var notAMapping = new MDM.PartyRole(); content = HttpContentExtensions.CreateDataContract(notAMapping); startVersion = CurrentEntityVersion(); }
protected static void Establish_context() { client = new HttpClient(); entity = PartyRoleData.CreateBasicEntity(); var getResponse = client.Get(ServiceUrl["PartyRole"] + entity.Id); updatedContract = getResponse.Content.ReadAsDataContract<OpenNexus.MDM.Contracts.PartyRole>(); content = HttpContentExtensions.CreateDataContract(PartyRoleData.MakeChangeToContract(updatedContract)); }
public static void Compare(Contracts.PartyRole contract, MDM.PartyRole entity) { PartyRoleDetails detailsToCompare = entity.Details[0]; if (contract.Nexus != null) { detailsToCompare = entity.Details.Where(details => details.Validity.Start == contract.Nexus.StartDate).First(); } Assert.AreEqual(contract.Details.Name, detailsToCompare.Name); }
protected static void Because_of() { entity = PartyRoleData.CreateEntityWithTwoDetailsAndTwoMappings(); client = new HttpClient(ServiceUrl["PartyRole"] + "crossmap?source-system=trayport&destination-system=endur&mapping-string=" + entity.Mappings[0].MappingValue + "&as-of=" + entity.Mappings[0].Validity.Start.ToString(DateFormatString)); response = client.Get(); mappingResponse = response.Content.ReadAsDataContract<EnergyTrading.Mdm.Contracts.MappingResponse>(); }
protected static void Because_of() { entity = PartyRoleData.CreateEntityWithTwoDetailsAndTwoMappings(); client = new HttpClient(ServiceUrl["PartyRole"] + "crossmap?source-system=trayport&destination-system=endur&mapping-string=" + entity.Mappings[0].MappingValue + "&as-of=" + entity.Mappings[0].Validity.Start.ToString(DateFormatString)); response = client.Get(); mappingResponse = response.Content.ReadAsDataContract <EnergyTrading.Mdm.Contracts.MappingResponse>(); }
protected static void Establish_context() { entity1 = PartyRoleData.CreateBasicEntity(); entity2 = PartyRoleData.CreateBasicEntity(); client = new HttpClient(); var search = new Search(); PartyRoleData.CreateSearch(search, entity1, entity2); content = HttpContentExtensions.CreateDataContract(search); }
protected static void Establish_context() { entity1 = PartyRoleData.CreateBasicEntity(); entity2 = PartyRoleData.CreateBasicEntity(); client = new HttpClient(); var search = new Search().IsMutliPage().MaxPageSize(1); PartyRoleData.CreateSearch(search, entity1, entity2); content = HttpContentExtensions.CreateDataContract(search); }
protected static void Establish_context() { entity1 = PartyRoleData.CreateBasicEntityWithOneMapping(); client = new HttpClient(); Search search = SearchBuilder.CreateSearch(isMappingSearch: true); search.AddSearchCriteria(SearchCombinator.And).AddCriteria( "MappingValue", SearchCondition.Equals, entity1.Mappings[0].MappingValue).AddCriteria( "System.Name", SearchCondition.Equals, "Endur"); content = HttpContentExtensions.CreateDataContract(search); }
protected static void Establish_context() { entity = PartyRoleData.CreateBasicEntity(); mapping = new EnergyTrading.Mdm.Contracts.Mapping { SystemName = "Endur", Identifier = Guid.NewGuid().ToString(), SourceSystemOriginated = false, DefaultReverseInd = false, StartDate = Script.baseDate, EndDate = Script.baseDate.AddDays(2) }; content = HttpContentExtensions.CreateDataContract(mapping); client = new HttpClient(); }
protected static void Establish_context() { entity = PartyRoleData.CreateBasicEntity(); mapping = new EnergyTrading.Mdm.Contracts.Mapping{ SystemName = "Endur", Identifier = "Test", SourceSystemOriginated = false, DefaultReverseInd = true, StartDate = Script.baseDate, EndDate = Script.baseDate.AddDays(2) }; content = HttpContentExtensions.CreateDataContract(mapping); content2 = HttpContentExtensions.CreateDataContract(mapping); client = new HttpClient(); }
public void ValidDetailsSaved() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new PartyRoleService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var identifier = new MdmId { SystemName = "Test", Identifier = "A" }; var message = new AmendMappingRequest { MappingId = 12, Mapping = identifier, Version = 34 }; var start = new DateTime(2000, 12, 31); var finish = DateUtility.Round(SystemTime.UtcNow().AddDays(5)); var s1 = new MDM.SourceSystem { Name = "Test" }; var m1 = new PartyRoleMapping { Id = 12, System = s1, MappingValue = "1", Version = 34UL.GetVersionByteArray(), Validity = new DateRange(start, DateUtility.MaxDate) }; var m2 = new PartyRoleMapping { Id = 12, System = s1, MappingValue = "1", Validity = new DateRange(start, finish) }; // NB We deliberately bypasses the business logic var party = new MDM.PartyRole(); m1.PartyRole = party; party.Mappings.Add(m1); validatorFactory.Setup(x => x.IsValid(It.IsAny <AmendMappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true); repository.Setup(x => x.FindOne <PartyRoleMapping>(12)).Returns(m1); mappingEngine.Setup(x => x.Map <EnergyTrading.Mdm.Contracts.MdmId, PartyRoleMapping>(identifier)).Returns(m2); // Act service.UpdateMapping(message); // Assert // NB Don't verify result of Update - already covered by PartyRoleMappingFixture repository.Verify(x => x.Save(party)); repository.Verify(x => x.Flush()); }
protected static void Establish_context() { entity = PartyRoleData.CreateBasicEntityWithOneMapping(); currentTrayportMapping = entity.Mappings[0]; mapping = new EnergyTrading.Mdm.Contracts.Mapping { SystemName = currentTrayportMapping.System.Name, Identifier = currentTrayportMapping.MappingValue, SourceSystemOriginated = currentTrayportMapping.IsMaster, DefaultReverseInd = currentTrayportMapping.IsDefault, StartDate = currentTrayportMapping.Validity.Start, EndDate = currentTrayportMapping.Validity.Finish.AddDays(2) }; content = HttpContentExtensions.CreateDataContract(mapping); client = new HttpClient(); }
protected static void Establish_context() { entity = PartyRoleData.CreateBasicEntityWithOneMapping(); currentTrayportMapping = entity.Mappings[0]; mapping = new EnergyTrading.Mdm.Contracts.Mapping{ SystemName = currentTrayportMapping.System.Name, Identifier = currentTrayportMapping.MappingValue, SourceSystemOriginated = currentTrayportMapping.IsMaster, DefaultReverseInd = currentTrayportMapping.IsDefault, StartDate = currentTrayportMapping.Validity.Start, EndDate = currentTrayportMapping.Validity.Finish.AddDays(2) }; content = HttpContentExtensions.CreateDataContract(mapping); client = new HttpClient(); }
public void ValidContractAdded() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new PartyRoleService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var identifier = new MdmId { SystemName = "Test", Identifier = "A" }; var message = new CreateMappingRequest { EntityId = 12, Mapping = identifier }; var system = new MDM.SourceSystem { Name = "Test" }; var mapping = new PartyRoleMapping { System = system, MappingValue = "A" }; validatorFactory.Setup(x => x.IsValid(It.IsAny <CreateMappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true); mappingEngine.Setup(x => x.Map <EnergyTrading.Mdm.Contracts.MdmId, PartyRoleMapping>(identifier)).Returns(mapping); var partyrole = new MDM.PartyRole(); repository.Setup(x => x.FindOne <MDM.PartyRole>(12)).Returns(partyrole); // Act var candidate = (PartyRoleMapping)service.CreateMapping(message); // Assert Assert.AreSame(mapping, candidate); repository.Verify(x => x.Save(partyrole)); repository.Verify(x => x.Flush()); }
public static void CompareContractWithEntityDetails(OpenNexus.MDM.Contracts.PartyRole contract, MDM.PartyRole entity) { MDM.PartyRoleDetails detailsToCompare = entity.Details[0]; if (contract.MdmSystemData != null) { detailsToCompare = entity.Details.Where(details => details.Validity.Start == contract.MdmSystemData.StartDate).First(); } Assert.AreEqual(contract.Details.Name, detailsToCompare.Name); }
protected static void Establish_context() { partyrole = PartyRoleData.CreateBasicEntity(); }
protected static void Because_of() { entity = PartyRoleData.CreateBasicEntity(); client.DefaultHeaders.Add("If-Match", entity.Version.ToString()); response = client.Post(ServiceUrl["PartyRole"] + entity.Id, content); }
protected static void Establish_context() { partyrole = PartyRoleData.CreateEntityWithTwoDetailsAndTwoMappings(); }
protected static void Establish_context() { entity1 = PartyRoleData.CreateBasicEntity(); entity2 = PartyRoleData.CreateBasicEntity(); }
public void ValidContractAdded() { // Arrange var validatorFactory = new Mock<IValidatorEngine>(); var mappingEngine = new Mock<IMappingEngine>(); var repository = new Mock<IRepository>(); var searchCache = new Mock<ISearchCache>(); var service = new PartyRoleService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var identifier = new MdmId { SystemName = "Test", Identifier = "A" }; var message = new CreateMappingRequest { EntityId = 12, Mapping = identifier }; var system = new MDM.SourceSystem { Name = "Test" }; var mapping = new PartyRoleMapping { System = system, MappingValue = "A" }; validatorFactory.Setup(x => x.IsValid(It.IsAny<CreateMappingRequest>(), It.IsAny<IList<IRule>>())).Returns(true); mappingEngine.Setup(x => x.Map<EnergyTrading.Mdm.Contracts.MdmId, PartyRoleMapping>(identifier)).Returns(mapping); var partyrole = new MDM.PartyRole(); repository.Setup(x => x.FindOne<MDM.PartyRole>(12)).Returns(partyrole); // Act var candidate = (PartyRoleMapping)service.CreateMapping(message); // Assert Assert.AreSame(mapping, candidate); repository.Verify(x => x.Save(partyrole)); repository.Verify(x => x.Flush()); }
public void SuccessMatch() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new PartyRoleService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); // Domain details var system = new MDM.SourceSystem { Name = "Endur" }; var mapping = new PartyRoleMapping { System = system, MappingValue = "A", }; var targetSystem = new MDM.SourceSystem { Name = "Trayport" }; var targetMapping = new PartyRoleMapping { System = targetSystem, MappingValue = "B", IsDefault = true }; var details = new MDM.PartyRoleDetails { Name = "PartyRole 1" }; var party = new MDM.PartyRole { Id = 1 }; party.AddDetails(details); party.ProcessMapping(mapping); party.ProcessMapping(targetMapping); // Contract details var targetIdentifier = new MdmId { SystemName = "Trayport", Identifier = "B" }; mappingEngine.Setup(x => x.Map <PartyRoleMapping, MdmId>(targetMapping)).Returns(targetIdentifier); var list = new List <PartyRoleMapping> { mapping }; repository.Setup(x => x.Queryable <PartyRoleMapping>()).Returns(list.AsQueryable()); var request = new CrossMappingRequest { SystemName = "Endur", Identifier = "A", TargetSystemName = "trayport", ValidAt = SystemTime.UtcNow(), Version = 1 }; // Act var response = service.CrossMap(request); var candidate = response.Contract; // Assert Assert.IsNotNull(response, "Contract null"); Assert.IsNotNull(candidate, "Mapping null"); Assert.AreEqual(1, candidate.Mappings.Count, "Identifier count incorrect"); Assert.AreSame(targetIdentifier, candidate.Mappings[0], "Different identifier assigned"); }