package sg.ncl.common;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import sg.ncl.common.AvScannerPropertiesTest.TestConfig;

import javax.inject.Inject;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Created by teye
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestConfig.class, webEnvironment = WebEnvironment.NONE)
@TestPropertySource(properties = {
        "ncl.av-scanner.host=123.123.123.123",
        "ncl.av-scanner.port=1234"
})
public class AvScannerPropertiesTest {

    @Configuration
    @EnableConfigurationProperties(AvScannerProperties.class)
    static class TestConfig {
    }

    @Inject
    private AvScannerProperties properties;

    @Test
    public void testGetHost() throws Exception {
        assertThat(properties.getHost()).isEqualTo("123.123.123.123");
    }

    @Test
    public void testGetPort() throws Exception {
        assertThat(properties.getPort()).isEqualTo(1234);
    }

}

@@ -793,16 +793,61 @@
 ies = %7B%0A
+        %22ncl.av-scanner.cron=* 0 2 * * SUN%22,%0A
         
@@ -1399,10 +1399,145 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testGetCron() throws Exception %7B%0A        assertThat(properties.getCron()).isEqualTo(%22* 0 2 * * SUN%22);%0A    %7D%0A%0A
 %7D%0A

update avscanner properties test to include cron expression