From eca716244841da36f06b5b6a67cde0001951875c Mon Sep 17 00:00:00 2001 From: Mykola Rudyk Date: Wed, 16 Aug 2023 15:50:58 +0300 Subject: [PATCH 1/2] feat: add table configuration class --- .../com/lpvs/util/LPVSTableConfiguration.java | 54 +++++++++++++++++++ .../lpvs/util/LPVSTableConfigurationTest.java | 54 +++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 src/main/java/com/lpvs/util/LPVSTableConfiguration.java create mode 100644 src/test/java/com/lpvs/util/LPVSTableConfigurationTest.java diff --git a/src/main/java/com/lpvs/util/LPVSTableConfiguration.java b/src/main/java/com/lpvs/util/LPVSTableConfiguration.java new file mode 100644 index 00000000..2cd8742d --- /dev/null +++ b/src/main/java/com/lpvs/util/LPVSTableConfiguration.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. + * + * Use of this source code is governed by a MIT license that can be + * found in the LICENSE file. + */ + +package com.lpvs.util; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component +public class LPVSTableConfiguration { + @Value("${app.table.detectedLicenseName}") + private String detectedLicenseName; + + @Value("${app.table.detectedLicenseShema}") + private String detectedLicenseShema; + + @Value("${app.table.diffFileName}") + private String diffFileName; + + @Value("${app.table.pullRequestsName}") + private String pulLRequestsName; + + @Value("${app.table.queueName}") + private String queueName; + + // Configuration for detected license name + public String getDetectedLicenseName() { + return detectedLicenseName; + } + + // Configuration for detected license shema + public String getDetectedLicenseShema() { + return detectedLicenseShema; + } + + // Configuration for diff file name table + public String getDiffFileName() { + return diffFileName; + } + + // Configuration for pull request name table + public String getPullRequestsName() { + return pulLRequestsName; + } + + // Configurations for queue name + public String getQueueName() { + return queueName; + } +} diff --git a/src/test/java/com/lpvs/util/LPVSTableConfigurationTest.java b/src/test/java/com/lpvs/util/LPVSTableConfigurationTest.java new file mode 100644 index 00000000..3468c864 --- /dev/null +++ b/src/test/java/com/lpvs/util/LPVSTableConfigurationTest.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved. + * + * Use of this source code is governed by a MIT license that can be + * found in the LICENSE file. + */ + +package com.lpvs.util; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@SpringBootTest(classes = LPVSTableConfiguration.class) +@TestPropertySource(properties = { + "app.table.detectedLicenseName=mockDetectedLicenseName", + "app.table.detectedLicenseShema=mockDetectedLicenseShema", + "app.table.diffFileName=mockDiffFileName", + "app.table.pullRequestsName=mockPullRequestsName", + "app.table.queueName=mockQueueName" +}) +public class LPVSTableConfigurationTest { + + @Autowired + private LPVSTableConfiguration config; + + @Test + public void testGetDetectedLicenseName() { + assertEquals("mockDetectedLicenseName", config.getDetectedLicenseName()); + } + + @Test + public void testGetDetectedLicenseShema() { + assertEquals("mockDetectedLicenseShema", config.getDetectedLicenseShema()); + } + + @Test + public void testGetDiffFileName() { + assertEquals("mockDiffFileName", config.getDiffFileName()); + } + + @Test + public void testGetPullRequestsName() { + assertEquals("mockPullRequestsName", config.getPullRequestsName()); + } + + @Test + public void testGetQueueName() { + assertEquals("mockQueueName", config.getQueueName()); + } +} From a3c9dd0119591e61d44718038747d84f34fa3955 Mon Sep 17 00:00:00 2001 From: Mykola Rudyk Date: Mon, 28 Aug 2023 11:40:53 +0300 Subject: [PATCH 2/2] fix: apply remarks after review --- .../java/com/lpvs/util/LPVSTableConfiguration.java | 10 +++++----- .../java/com/lpvs/util/LPVSTableConfigurationTest.java | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/lpvs/util/LPVSTableConfiguration.java b/src/main/java/com/lpvs/util/LPVSTableConfiguration.java index 2cd8742d..69a30321 100644 --- a/src/main/java/com/lpvs/util/LPVSTableConfiguration.java +++ b/src/main/java/com/lpvs/util/LPVSTableConfiguration.java @@ -15,8 +15,8 @@ public class LPVSTableConfiguration { @Value("${app.table.detectedLicenseName}") private String detectedLicenseName; - @Value("${app.table.detectedLicenseShema}") - private String detectedLicenseShema; + @Value("${app.table.detectedLicenseSchema}") + private String detectedLicenseSchema; @Value("${app.table.diffFileName}") private String diffFileName; @@ -32,9 +32,9 @@ public String getDetectedLicenseName() { return detectedLicenseName; } - // Configuration for detected license shema - public String getDetectedLicenseShema() { - return detectedLicenseShema; + // Configuration for detected license schema + public String getDetectedLicenseSchema() { + return detectedLicenseSchema; } // Configuration for diff file name table diff --git a/src/test/java/com/lpvs/util/LPVSTableConfigurationTest.java b/src/test/java/com/lpvs/util/LPVSTableConfigurationTest.java index 3468c864..9afe154b 100644 --- a/src/test/java/com/lpvs/util/LPVSTableConfigurationTest.java +++ b/src/test/java/com/lpvs/util/LPVSTableConfigurationTest.java @@ -17,7 +17,7 @@ @SpringBootTest(classes = LPVSTableConfiguration.class) @TestPropertySource(properties = { "app.table.detectedLicenseName=mockDetectedLicenseName", - "app.table.detectedLicenseShema=mockDetectedLicenseShema", + "app.table.detectedLicenseSchema=mockDetectedLicenseSchema", "app.table.diffFileName=mockDiffFileName", "app.table.pullRequestsName=mockPullRequestsName", "app.table.queueName=mockQueueName" @@ -33,8 +33,8 @@ public void testGetDetectedLicenseName() { } @Test - public void testGetDetectedLicenseShema() { - assertEquals("mockDetectedLicenseShema", config.getDetectedLicenseShema()); + public void testGetDetectedLicenseSchema() { + assertEquals("mockDetectedLicenseSchema", config.getDetectedLicenseSchema()); } @Test