package com.atlassian.bitbucket.mail;

import org.junit.Test;

import static org.junit.Assert.*;

public class MailHostConfigTest {
    
    @Test
    public void testMailHostBuilder() {
        MailHostConfiguration config = new MailHostConfiguration.Builder()
                .hostname("host")
                .port(25)
                .username("user")
                .password("password")
                .build();
        
        assertEquals("host", config.getHostname());
        assertEquals(Integer.valueOf(25), config.getPort());
        assertEquals("user", config.getUsername());
        assertEquals("password", config.getPassword());

        MailHostConfiguration config2 = new MailHostConfiguration.Builder(config)
                .hostname("host2")
                .build();

        // verify config is unchanged
        assertEquals("host", config.getHostname());
        assertEquals(Integer.valueOf(25), config.getPort());
        assertEquals("user", config.getUsername());
        assertEquals("password", config.getPassword());

        // verify all properties have been copied from config --> config2
        assertEquals("host2", config2.getHostname());
        assertEquals(Integer.valueOf(25), config2.getPort());
        assertEquals("user", config2.getUsername());
        assertEquals("password", config2.getPassword());
    }
}
