<commit_before>package com.structurizr.model;

import com.structurizr.AbstractWorkspaceTestBase;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

public class RelationshipTests extends AbstractWorkspaceTestBase {

    private SoftwareSystem softwareSystem1, softwareSystem2;

    @Before
    public void setUp() {
        softwareSystem1 = model.addSoftwareSystem(Location.Internal, "Name1", "Description");
        softwareSystem2 = model.addSoftwareSystem(Location.Internal, "Name2", "Description");
    }

    @Test
    public void test_getDescription_NeverReturnsNull() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, null);
        assertEquals("", relationship.getDescription());
    }

    @Test
    public void test_getTags_WhenThereAreNoTags() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "uses");
        assertEquals("Relationship", relationship.getTags());
    }

    @Test
    public void test_getTags_ReturnsTheListOfTags_WhenThereAreSomeTags() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "uses");
        relationship.addTags("tag1", "tag2", "tag3");
        assertEquals("Relationship,tag1,tag2,tag3", relationship.getTags());
    }

    @Test
    public void test_setTags_ClearsTheTags_WhenPassedNull() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "uses");
        relationship.addTags("Tag 1", "Tag 2");
        assertEquals("Relationship,Tag 1,Tag 2", relationship.getTags());
        relationship.setTags(null);
        assertEquals("Relationship", relationship.getTags());
    }

    @Test
    public void test_addTags_DoesNotDoAnything_WhenPassedNull() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "uses");
        relationship.addTags((String)null);
        assertEquals("Relationship", relationship.getTags());

        relationship.addTags(null, null, null);
        assertEquals("Relationship", relationship.getTags());
    }

    @Test
    public void test_addTags_AddsTags_WhenPassedSomeTags() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "uses");
        relationship.addTags(null, "tag1", null, "tag2");
        assertEquals("Relationship,tag1,tag2", relationship.getTags());
    }

    @Test
    public void test_getInteractionStyle_ReturnsNull_WhenNotExplicitlySet() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "uses");
        assertNull(relationship.getInteractionStyle());
    }

    @Test
    public void test_getTags_IncludesTheInteractionStyleWhenSpecified() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "Uses 1", "Technology");
        assertFalse(relationship.getTags().contains(Tags.SYNCHRONOUS));
        assertFalse(relationship.getTags().contains(Tags.ASYNCHRONOUS));

        relationship.setInteractionStyle(InteractionStyle.Synchronous);
        assertTrue(relationship.getTags().contains(Tags.SYNCHRONOUS));
        assertFalse(relationship.getTags().contains(Tags.ASYNCHRONOUS));

        relationship.setInteractionStyle(InteractionStyle.Asynchronous);
        assertFalse(relationship.getTags().contains(Tags.SYNCHRONOUS));
        assertTrue(relationship.getTags().contains(Tags.ASYNCHRONOUS));
    }

    @Test
    public void test_setUrl() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "Uses 1", "Technology");
        relationship.setUrl("https://structurizr.com");
        assertEquals("https://structurizr.com", relationship.getUrl());
    }

    @Test(expected = IllegalArgumentException.class)
    public void test_setUrl_ThrowsAnIllegalArgumentException_WhenAnInvalidUrlIsSpecified() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "Uses 1", "Technology");
        relationship.setUrl("htt://blah");
    }

    @Test
    public void test_setUrl_DoesNothing_WhenANullUrlIsSpecified() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "Uses 1", "Technology");
        relationship.setUrl(null);
        assertNull(relationship.getUrl());
    }

    @Test
    public void test_setUrl_DoesNothing_WhenAnEmptyUrlIsSpecified() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "Uses 1", "Technology");
        relationship.setUrl(" ");
        assertNull(relationship.getUrl());
    }

    @Test
    public void test_interactionStyle_CanBeSetToNull() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "Uses 1", "Technology", null);

        assertNull(relationship.getInteractionStyle());<commit_msg>Adds support to close #169 (ability to reset URL to null).<commit_after>package com.structurizr.model;

import com.structurizr.AbstractWorkspaceTestBase;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

public class RelationshipTests extends AbstractWorkspaceTestBase {

    private SoftwareSystem softwareSystem1, softwareSystem2;

    @Before
    public void setUp() {
        softwareSystem1 = model.addSoftwareSystem(Location.Internal, "Name1", "Description");
        softwareSystem2 = model.addSoftwareSystem(Location.Internal, "Name2", "Description");
    }

    @Test
    public void test_getDescription_NeverReturnsNull() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, null);
        assertEquals("", relationship.getDescription());
    }

    @Test
    public void test_getTags_WhenThereAreNoTags() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "uses");
        assertEquals("Relationship", relationship.getTags());
    }

    @Test
    public void test_getTags_ReturnsTheListOfTags_WhenThereAreSomeTags() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "uses");
        relationship.addTags("tag1", "tag2", "tag3");
        assertEquals("Relationship,tag1,tag2,tag3", relationship.getTags());
    }

    @Test
    public void test_setTags_ClearsTheTags_WhenPassedNull() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "uses");
        relationship.addTags("Tag 1", "Tag 2");
        assertEquals("Relationship,Tag 1,Tag 2", relationship.getTags());
        relationship.setTags(null);
        assertEquals("Relationship", relationship.getTags());
    }

    @Test
    public void test_addTags_DoesNotDoAnything_WhenPassedNull() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "uses");
        relationship.addTags((String)null);
        assertEquals("Relationship", relationship.getTags());

        relationship.addTags(null, null, null);
        assertEquals("Relationship", relationship.getTags());
    }

    @Test
    public void test_addTags_AddsTags_WhenPassedSomeTags() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "uses");
        relationship.addTags(null, "tag1", null, "tag2");
        assertEquals("Relationship,tag1,tag2", relationship.getTags());
    }

    @Test
    public void test_getInteractionStyle_ReturnsNull_WhenNotExplicitlySet() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "uses");
        assertNull(relationship.getInteractionStyle());
    }

    @Test
    public void test_getTags_IncludesTheInteractionStyleWhenSpecified() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "Uses 1", "Technology");
        assertFalse(relationship.getTags().contains(Tags.SYNCHRONOUS));
        assertFalse(relationship.getTags().contains(Tags.ASYNCHRONOUS));

        relationship.setInteractionStyle(InteractionStyle.Synchronous);
        assertTrue(relationship.getTags().contains(Tags.SYNCHRONOUS));
        assertFalse(relationship.getTags().contains(Tags.ASYNCHRONOUS));

        relationship.setInteractionStyle(InteractionStyle.Asynchronous);
        assertFalse(relationship.getTags().contains(Tags.SYNCHRONOUS));
        assertTrue(relationship.getTags().contains(Tags.ASYNCHRONOUS));
    }

    @Test
    public void test_setUrl() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "Uses 1", "Technology");
        relationship.setUrl("https://structurizr.com");
        assertEquals("https://structurizr.com", relationship.getUrl());
    }

    @Test(expected = IllegalArgumentException.class)
    public void test_setUrl_ThrowsAnIllegalArgumentException_WhenAnInvalidUrlIsSpecified() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "Uses 1", "Technology");
        relationship.setUrl("htt://blah");
    }

    @Test
    public void test_setUrl_ResetsTheUrl_WhenANullUrlIsSpecified() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "Uses 1", "Technology");
        relationship.setUrl("https://structurizr.com");
        relationship.setUrl(null);
        assertNull(relationship.getUrl());
    }

    @Test
    public void test_setUrl_ResetsTheUrl_WhenAnEmptyUrlIsSpecified() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "Uses 1", "Technology");
        relationship.setUrl("https://structurizr.com");
        relationship.setUrl(" ");
        assertNull(relationship.getUrl());
    }

    @Test
    public void test_interactionStyle_CanBeSetToNull() {
        Relationship relationship = softwareSystem1.uses(softwareSystem2, "Uses 1", "Technology", null);

        assertNull(relationship.getInteractionStyle());
{'fraction_non_alphanumeric': 0.1085972850678733, 'fraction_numerical': 0.01125960223087446, 'mean_word_length': 4.250828729281768, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4046229', 'n_tokens_mistral': 2669, 'n_tokens_neox': 2520, 'n_words': 415}