public void MatchesPublishingTopic(string subscriptionAsString, string publishingAsString, bool isMatched) { SubscriptionTopic.From(subscriptionAsString) .Matches(PublishingTopic.From(publishingAsString)) .Should() .Be(isMatched); }
public void ToStringReturnsSameTopicAsInput() { const string expectedTopicString = "finance/ibm"; var topic = new SubscriptionTopic(expectedTopicString); Assert.Equal(expectedTopicString, topic.ToString()); }
/// <summary>Adds or updates a Topic</summary> /// <param name="topic">The topic.</param> public static void AddOrUpdate(SubscriptionTopic topic) { if (topic == null) { return; } _instance._AddOrUpdate(topic); }
/// <summary>Creates the topics.</summary> private void CreateTopics() { // make sure our lists are clear _titleTopicDict.Clear(); _canonicalUrlTopicDict.Clear(); _idTopicDict.Clear(); // create our known topics SubscriptionTopic topic = new SubscriptionTopic() { Title = "encounter-start", Id = "encounter-start", Url = "http://argonautproject.org/encounters-ig/SubscriptionTopic/encounter-start", Version = "1.1", Status = PublicationStatus.Draft, Experimental = true, Description = new Markdown("Beginning of a clinical encounter"), Date = "2020-05-11", ResourceTrigger = new SubscriptionTopic.ResourceTriggerComponent() { Description = "Beginning of a clinical encounter", ResourceType = new ResourceType?[] { ResourceType.Encounter, }, QueryCriteria = new SubscriptionTopic.QueryCriteriaComponent() { Previous = "status:not=in-progress", Current = "status:in-progress", RequireBoth = true, }, FhirPathCriteria = new string[] { "%previous.status!='in-progress' and %current.status='in-progress'", }, }, CanFilterBy = new List <SubscriptionTopic.CanFilterByComponent>() { new SubscriptionTopic.CanFilterByComponent() { SearchParamName = "patient", SearchModifier = new SubscriptionSearchModifier?[] { SubscriptionSearchModifier.Equal, SubscriptionSearchModifier.In, }, Documentation = new Markdown("Exact match to a patient resource (reference)"), }, }, }; // add this topic _AddOrUpdate(topic); }
/// <summary>Wrap in basic.</summary> /// <param name="topic">The topic.</param> /// <returns>A Basic.</returns> private Basic WrapInBasic(SubscriptionTopic topic) { return(new Basic() { Id = topic.Id, Code = new CodeableConcept( "http://hl7.org/fhir/resource-types", "R5SubscriptionTopic", "Backported R5 SubscriptionTopic"), Extension = new List <Extension>() { new Extension() { Url = "http://hl7.org/fhir/StructureDefinition/json-embedded-resource", Value = new FhirString(_firelySerializer.SerializeToString(topic)), }, }, }); }
public void TopicWithSingleWildcardMatchesTopicEmptyFragmentAtThatPoint() { var topic = new SubscriptionTopic("finance/+/closingprice"); Assert.True(topic.Matches(new PublicationTopic("finance//closingprice"))); }
public void TopicWithSingleAndMultiWildcardMatchesTopicWithAnyValueAtThoseLevelsAndDeeper() { var topic = new SubscriptionTopic("finance/+/closingprice/month/#"); Assert.True(topic.Matches(new PublicationTopic("finance/ibm/closingprice/month/october/2014"))); }
public void SingleLevelEqualTopicsMatch() { var topic = new SubscriptionTopic("finance"); Assert.True(topic.Matches(new PublicationTopic("finance"))); }
public void TopicsDifferingOnlyByCaseDoNotMatch() { var topic = new SubscriptionTopic("finance"); Assert.False(topic.Matches(new PublicationTopic("Finance"))); }
public void MultiLevelNonEqualTopicsDoNotMatch() { var topic = new SubscriptionTopic("finance/ibm/closingprice"); Assert.False(topic.Matches(new PublicationTopic("some/random/topic"))); }
public void TopicWithSingleWildcardAtEndDoesNotMatchTopicThatGoesDeeper() { var topic = new SubscriptionTopic("finance/+"); Assert.False(topic.Matches(new PublicationTopic("finance/ibm/closingprice"))); }
public void CanCreateSubscriptionFromValidString(string subscriptionAsString) { SubscriptionTopic.From(subscriptionAsString); }
public void CannotCreateInvalidSubscription(string subscriptionAsString) { var ex = Assert.Throws <InvalidTopicException>(() => SubscriptionTopic.From(subscriptionAsString)); Assert.NotNull(ex); }
/// <summary>Adds or updates a Topic</summary> /// <param name="topic">The topic.</param> private void _AddOrUpdate(SubscriptionTopic topic) { string localUrl = Program.UrlForR5ResourceId("SubscriptionTopic", topic.Title); // check for local url already existing if (_localUrlTopicDict.ContainsKey(localUrl)) { SubscriptionTopic oldTopic = _localUrlTopicDict[localUrl]; // remove if this topic exists in other dictionaries RemoveIfExists(_canonicalUrlTopicDict, oldTopic.Url); RemoveIfExists(_titleTopicDict, localUrl); RemoveIfExists(_idTopicDict, oldTopic.Title); // remove from this dict _localUrlTopicDict.Remove(topic.Title); } // check for this canonical url already existing if (_canonicalUrlTopicDict.ContainsKey(topic.Url)) { SubscriptionTopic oldTopic = _canonicalUrlTopicDict[topic.Url]; // remove if this topic exists in other dictionaries RemoveIfExists(_localUrlTopicDict, localUrl); RemoveIfExists(_titleTopicDict, oldTopic.Url); RemoveIfExists(_idTopicDict, oldTopic.Title); // remove from this dict _canonicalUrlTopicDict.Remove(topic.Url); } // check for title already existing if (_titleTopicDict.ContainsKey(topic.Title)) { SubscriptionTopic oldTopic = _titleTopicDict[topic.Title]; // remove if this topic exists in other dictionaries RemoveIfExists(_localUrlTopicDict, localUrl); RemoveIfExists(_canonicalUrlTopicDict, oldTopic.Url); RemoveIfExists(_idTopicDict, oldTopic.Title); // remove from this dict _titleTopicDict.Remove(topic.Title); } // check for this id already existing if (_idTopicDict.ContainsKey(topic.Id)) { SubscriptionTopic oldTopic = _idTopicDict[topic.Id]; // remove if this topic exists in other dictionaries RemoveIfExists(_localUrlTopicDict, localUrl); RemoveIfExists(_canonicalUrlTopicDict, oldTopic.Url); RemoveIfExists(_titleTopicDict, oldTopic.Title); // remove from this dict _idTopicDict.Remove(topic.Id); } // add to local url dictionary _localUrlTopicDict.Add(localUrl, topic); // add to canonical url dictionary _canonicalUrlTopicDict.Add(topic.Url, topic); // add to the title dictionary _titleTopicDict.Add(topic.Title, topic); // add to id dictionary _idTopicDict.Add(topic.Id, topic); }
public void TopicWithSingleWildcardAtEndMatchesTopicWithEmptyLastFragmentAtThatSpot() { var topic = new SubscriptionTopic("finance/ibm/+"); Assert.True(topic.Matches(new PublicationTopic("finance/ibm/"))); }
public void SingleLevelNonEqualTopicsDoNotMatch() { var topic = new SubscriptionTopic("finance"); Assert.False(topic.Matches(new PublicationTopic("money"))); }
public void MultiWildcardOnlyTopicMatchesTopicStartingWithSeparator() { var topic = new SubscriptionTopic("#"); Assert.True(topic.Matches(new PublicationTopic("/finance/ibm/closingprice"))); }
public void TopicWithSingleWildcardAtEndDoesNotMatchTopicThatDoesNotContainAnythingAtSameLevel() { var topic = new SubscriptionTopic("finance/+"); Assert.False(topic.Matches(new PublicationTopic("finance"))); }
public void TopicWithMultiWildcardAtEndMatchesTopicThatDoesNotMatchSameDepth() { var topic = new SubscriptionTopic("finance/#"); Assert.True(topic.Matches(new PublicationTopic("finance"))); }
public void TopicWithMultiWildcardDoesNotMatchTopicWithDifferenceBeforeWildcardLevel() { var topic = new SubscriptionTopic("finance/#"); Assert.False(topic.Matches(new PublicationTopic("money/ibm"))); }
public void TopicWithMultiWildcardAtEndMatchesTopicWithAnythingAtWildcardLevel() { var topic = new SubscriptionTopic("finance/#"); Assert.True(topic.Matches(new PublicationTopic("finance/ibm"))); }
public void TopicWithSingleWildcardAtEndMatchesAnythingInSameLevel() { var topic = new SubscriptionTopic("finance/+/closingprice"); Assert.True(topic.Matches(new PublicationTopic("finance/ibm/closingprice"))); }
public void TopicWithMoreThanOneSingleWildcardAtDifferentLevelsMatchesTopicWithAnyValueAtThoseLevels() { var topic = new SubscriptionTopic("finance/+/closingprice/month/+"); Assert.True(topic.Matches(new PublicationTopic("finance/ibm/closingprice/month/october"))); }
public void MultiWildcardOnlyTopicMatchesAnyRandomTopic() { var topic = new SubscriptionTopic("#"); Assert.True(topic.Matches(new PublicationTopic("finance/ibm/closingprice"))); }
/// <summary>Attempts to get topic a SubscriptionTopic from the given string.</summary> /// <param name="key"> The key for the topic</param> /// <param name="topic">[out] The topic.</param> /// <returns>True if it succeeds, false if it fails.</returns> public static bool TryGetTopic(string key, out SubscriptionTopic topic) { topic = GetTopic(key); return(topic != null); }