diff options
author | Ofir Sonsino <os0695@att.com> | 2018-01-31 17:19:00 +0200 |
---|---|---|
committer | Ofir Sonsino <os0695@att.com> | 2018-01-31 17:19:00 +0200 |
commit | 1cfb08779ea0e00be69e072a940b3063e049fe6b (patch) | |
tree | 6602a900387c8393ed0dcd81c0539381632903c6 /vid-app-common/src/test/java/org/onap | |
parent | 2f20b001b9243e0f8b44aecc768ec265fd538732 (diff) |
org.onap migration
Change-Id: I52f0b2851f2c765752b6d21f49b32136d7d72a3d
Issue-ID: VID-86
Signed-off-by: Ofir Sonsino <os0695@att.com>
Diffstat (limited to 'vid-app-common/src/test/java/org/onap')
100 files changed, 9600 insertions, 0 deletions
diff --git a/vid-app-common/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java b/vid-app-common/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java new file mode 100644 index 000000000..8e2e223af --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java @@ -0,0 +1,22 @@ +package org.onap.aai.util; + +import org.junit.Test; +import org.onap.vid.aai.util.JettyObfuscationConversionCommandLineUtil; + +public class JettyObfuscationConversionCommandLineUtilTest { + + private JettyObfuscationConversionCommandLineUtil createTestSubject() { + return new JettyObfuscationConversionCommandLineUtil(); + } + + + @Test + public void testMain() throws Exception { + String[] args = new String[] { "" }; + + // default test + JettyObfuscationConversionCommandLineUtil.main(args); + } + + +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/aai/util/TestSuite.java b/vid-app-common/src/test/java/org/onap/aai/util/TestSuite.java new file mode 100644 index 000000000..b4faaa279 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/aai/util/TestSuite.java @@ -0,0 +1,11 @@ +package org.onap.aai.util; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ JettyObfuscationConversionCommandLineUtilTest.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/ecomp/vid/selenium/FirstClass.java b/vid-app-common/src/test/java/org/onap/ecomp/vid/selenium/FirstClass.java new file mode 100644 index 000000000..d0da08c58 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/ecomp/vid/selenium/FirstClass.java @@ -0,0 +1,606 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.ecomp.vid.selenium; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.ie.InternetExplorerDriver; +import org.openqa.selenium.support.ui.Select; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; +import java.util.concurrent.TimeUnit; +import org.apache.log4j.Logger; +import org.testng.Assert; +import org.testng.asserts.*; + +/** + * The Class FirstClass. + */ +public class FirstClass { + + /** The login button. */ + WebElement loginButton; + + /** The eg. */ + String eg; + + /** The login. */ + WebElement login; + + /** The pwd. */ + WebElement pwd; + + /** The log. */ + Logger log; + + /** The errormessage. */ + WebElement errormessage; + + + /** The driver. */ + WebDriver driver=new FirefoxDriver(); + + + + /** The config prop. */ + private final Properties configProp = new Properties(); + + + /** + * Instantiates a new first class. + */ + private FirstClass() { + // TODO Auto-generated constructor stub + // + try{ + // InputStream input =this.getClass().getClassLoader().getResourceAsStream("objectmap.properties"); + //FileInputStream input1 = new FileInputStream("objectmap.properties"); + + InputStream input =new FileInputStream("objectconfig.properties"); + System.out.println("Read all properties from file"); + configProp.load(input); + System.out.println("Read all properties from file completed"); + } + catch(IOException e) { + + e.printStackTrace(); + } + } + + + /* + + + @BeforeClass + public void setUp() { + System.out.println("*******************"); + System.out.println("launching IE browser"); + System.setProperty("webdriver.ie.driver", driverPath+"IEDriverServer.exe"); + driver = new InternetExplorerDriver(); + driver.findElement(By.className()); + driver.manage().window().maximize(); + + + login = driver.findElement(By.xpath("//input[@class='fn-ebz-text ng-pristine ng-valid']")); + pwd = driver.findElement(By.xpath("//input[@class='span3 ng-pristine ng-valid']")); + loginButton = driver.findElement(By.id("loginBtn")); + } + + + */ + /** + * Sets the up. + */ + // TODO Auto-generated method stub + @BeforeClass + public void setUp() + { + + + //WebDriver driver=new FirefoxDriver(); + + log = Logger.getLogger(FirstClass.class.getName()); + + + + // Get url + driver.get(configProp.getProperty("baseURL")); + driver.manage().window().maximize(); + + + login = driver.findElement(By.xpath(configProp.getProperty("login"))); + + pwd = driver.findElement(By.xpath(configProp.getProperty("pwd"))); + loginButton = driver.findElement(By.id(configProp.getProperty("loginButton"))); + } + + + /** + * Empty username password. + */ + @Test(priority=1) + public void emptyUsernamePassword() + { + + + //User Name and Password field is empty + log.info("-----VID-11 TC-8----Username and password empty"); + loginButton.click(); + errormessage=driver.findElement(By.xpath("//*[@id='errorInfo']/span")); + String errmsg= errormessage.getText(); + //System.out.println("Error message is"+errmsg); + //String expected = "Invaild username or password, Please try again"; + + //Assert.assertEquals(errmsg,expected); + + Boolean str = driver.getPageSource().contains("Invalid username or password, Please try again"); + System.out.println(driver.getPageSource().contains("Invalid username or password, Please try again")); + + if(str==true) + { + log.info("Error message validated"); + log.info("VID-11 TC-8 PASSED"); + + }else + log.error("Failed validation"); + + } + + + + /** + * Invalid user name. + */ + @Test(priority=2) + public void invalidUserName() + { + + log.info("-----VID-11 TC-6----Invalid Username and Valid Password"); + + + login.sendKeys("xxx"); + pwd.sendKeys("abc123"); + loginButton.click(); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + String errmsg= errormessage.getText(); + String expected = "Invalid username or password, Please try again"; + Assert.assertEquals(errmsg,expected); + //Boolean str1 = driver.getPageSource().contains("Invalid username or password, Please try again"); + //System.out.print(str1); + + log.info("VID-11 TC-6 PASSED"); + + } + + + /** + * Invalid password. + */ + @Test(priority=3) + public void invalidPassword() + { + log.info("-----VID-11 TC-7----Valid Username and Invalid Password"); + // Valid user name and Invalid password. + login.clear(); + pwd.clear(); + login.sendKeys("testuser"); + pwd.sendKeys("xxx"); + loginButton.click(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + + + String errmsg= errormessage.getText(); + String expected = "Invalid username or password, Please try again"; + Assert.assertEquals(errmsg,expected); + + //Boolean str2 = driver.getPageSource().contains("Invaild username or password, Please try again"); + //System.out.print(str2); + + log.info("VID-11 TC-7 PASSED"); + } + + + /** + * Login successful. + */ + @Test(priority=4) + public void loginSuccessful() + { + log.info("-----VID-11 TC-1----Valid Username and Valid Password"); + //Login with valid user name and password. + login.clear(); + login.sendKeys("su"); + pwd.clear(); + pwd.sendKeys("fusion"); + + + loginButton.click(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + + try { + Thread.sleep(6000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances")); + log.info("VID-11 TC-1 PASSED"); + + } + + + /** + * Verify home page elements left pane. + */ + @Test(priority=5) + public void verifyHomePageElementsLeftPane() + + { + + + log.info("VID-10 TC 1 "); + //VID Home + log.info("VID 11 TC-2"); + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[1]/a/span")).isDisplayed(); + //Create New Service Instance + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[2]/a/span")).isDisplayed(); + + //Browse Service Type + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[3]/a/span")).isDisplayed(); + //View Log + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[4]/a/span")).isDisplayed(); + + //Profile + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[5]/a/span")).isDisplayed(); + //Admin + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[6]/a/span")).isDisplayed(); + //Logout + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[7]/a/span")).isDisplayed(); + + //Infrastructure Subscriber Name + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[1]/div/label")).isDisplayed(); + //Infrastructure Subscriber Name Select Drop down + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select")).isDisplayed(); + //Infrastructure Service Type + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[1]/div/label")).isDisplayed(); + //Infrastructure Service Type Select Drop down + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select")).isDisplayed(); + //Submit button + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[3]/td/div/button")).isDisplayed(); + + //Login Snippet Icon + driver.findElement(By.xpath(".//*[@class='icon-user-small login-snippet-icon']")).isDisplayed(); + + + //String bodyText = driver.findElement(By.tagName("body")).getText(); + //Assert.assertTrue("Text not found!", bodyText.contains("Search Existing Service Instances")); + //Assert.IsTrue(driver.getPageSource.Contains("Search Existing Service Instances")); + + log.info("VID-12 TC-1"); + Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances")); + Assert.assertTrue(driver.getPageSource().contains("Please search by the Subscriber name or Service Type from below:")); + log.info("VID-12 TC-1 PASSED"); + log.info("VID-10 TC 1 PASSED"); + log.info("VID-11 TC-2 PASSED"); + } + + + /** + * Disabled submit button. + */ + @Test(priority=6) + public void disabledSubmitButton() + { + log.info("VID-12 TC-13"); + //Assert submit button disabled. + Assert.assertFalse(driver.findElement(By.xpath(configProp.getProperty("submitButton"))).isEnabled()); + log.info("VID-12 TC-13 PASSED"); + + } + + /** + * Default list box value. + */ + @Test(priority=7) + public void defaultListBoxValue() + { + log.info("VID-12 TC-2"); + + + //WebElement subscribername =driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select")); + + Select oSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown")))); + Select iSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown")))); + + + WebElement ielement=iSelect.getFirstSelectedOption(); + WebElement oelement=oSelect.getFirstSelectedOption(); + String defaultsubscribername=oelement.getText(); + String defaultservicetype=ielement.getText(); + + Assert.assertEquals(defaultsubscribername,"Select Subscriber Name"); + Assert.assertEquals(defaultservicetype,"Select Service Type"); + + + + + //Verify Select Subscriber Name isDisplayed. + //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select/option[1]")).isSelected(); + + //Verify Select Service Type isDisplayed. + //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select/option[1]")).isSelected(); + + + log.info("VID-12 TC-2 PASSED"); + + } + + + + /** + * Select subscriber name drop down. + * + * @throws InterruptedException the interrupted exception + */ + @Test(priority=8) + public void selectSubscriberNameDropDown() throws InterruptedException + { + log.info("------------------VID-10 TC-2,VID-12 TC-11, VID-12 TC-9, VID 12 TC-10,VID-12 TC-6, VID 12 TC-5--------------------"); + + + driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown"))); + + driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown"))); + Thread.sleep(5000); + + //Infrastructure Subscriber Name + Select oSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown")))); + + List <WebElement> elementCount = oSelect.getOptions(); + log.info("Select Element Count of Service Name"); + System.out.println(elementCount.size()); + + + //Verifying getInfrastructureSubscribersList + log.info("VID-29 TC-1"); + Assert.assertTrue(elementCount.size()>0); + log.info("VID-29 TC-1 PASSED"); + + oSelect.selectByIndex(2); + String selectedOption = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown")))).getFirstSelectedOption().getText(); + + System.out.println("Service Name selected is " +selectedOption); + log.info("VID-10 TC-2 PASSED"); + + //Submit button is clicked + driver.findElement(By.xpath(configProp.getProperty("submitButton"))).click(); + + + //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:" + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed(); + //Assert.assertTrue(driver.getPageSource().contains("Selected Subscriber's Service Instance Details:")) + + + //Verify whether the page header is displayed "Global Customer ID" + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/thead/tr/th[2]/div")).isDisplayed(); + Assert.assertTrue(driver.getPageSource().contains("Global Customer ID")); + Assert.assertTrue(driver.getPageSource().contains("Subscriber Name")); + Assert.assertTrue(driver.getPageSource().contains("Service Type")); + Assert.assertTrue(driver.getPageSource().contains("Service Instance ID")); + + log.info("VID-12 TC-5 PASSED"); + log.info("VID-12 TC-11 PASSED"); + + WebElement serviceinstancetable =driver.findElement(By.xpath("//table[@class='tablesorter tablesorter-default ng-isolate-scope']")); + + List<WebElement> rows_table = serviceinstancetable.findElements(By.tagName("tr")); + //To calculate no of rows In table. + int rows_count = rows_table.size(); + + //Loop will execute till the last row of table. + for (int row=0; row<rows_count; row++){ + //To locate columns(cells) of that specific row. + List<WebElement> Columns_row = rows_table.get(row).findElements(By.tagName("td")); + //To calculate no of columns(cells) In that specific row. + int columns_count = Columns_row.size(); + //System.out.println("Number of cells In Row "+row+" are "+columns_count); + + //Loop will execute till the last cell of that specific row. + for (int column=0; column<columns_count; column++){ + //To retrieve text from that specific cell. + String celtext = Columns_row.get(column).getText(); + //System.out.println("Cell Value Of row number "+row+" and column number "+column+" Is "+celtext); + + + + //log.info("Testing Get column and row value"); + List <WebElement> exx= rows_table.get(1).findElements(By.tagName("td")); + eg=Columns_row.get(2).getText(); + // System.out.println("Cell value of row 1 and column 2 is" +eg); + } + } + + + + + //Verify View/Edit isDisplayed and Click + + driver.findElement(By.xpath("//a[@alt='View/Edit']")).isDisplayed(); + + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/tbody/tr[1]/td[1]/div/a")).click(); + + log.info("User clicked View/Edit"); + + //Verify the Subscriber Name displayed. + String header= driver.findElement(By.xpath("//h1[@class='heading1 ng-binding']")).getText(); + //System.out.println(header); + + + if(header.contains(eg)) + { + System.out.println("Header contains the subscriber name"); + }else + System.out.println("Header does not contain the subscriber name"); + + + + Assert.assertTrue(driver.getPageSource().contains("PerfTest Subscriber00020021")); + log.info("VID-12 TC-6 PASSED"); + + + + driver.navigate().back(); + //Cancel button isDisplayed + driver.findElement(By.xpath("//button[@class='button button--small button--primary']")).isDisplayed(); + log.info("VID-12 TC-9 PASSED"); + + //Cancel button is clicked + driver.findElement(By.xpath("//button[@class='button button--small button--primary']")).click(); + log.info("Cancel button is clicked"); + + //Verifying VID Home page is displayed + Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances")); + log.info("VID-12 TC-10 PASSED"); + + } + + + /** + * Refresh subscriber name. + */ + @Test(priority=9) + public void refreshSubscriberName() + { + log.info("VID-10 TC-4"); + + + driver.findElement(By.xpath(configProp.getProperty("refreshButtonSubscriberName"))).isDisplayed(); + + log.info("VID-10 TC-4 PASSED"); + + + } + + + /** + * Select subscriber type drop down. + * + * @throws InterruptedException the interrupted exception + */ + @Test(priority=9) + public void selectSubscriberTypeDropDown() throws InterruptedException + { + Thread.sleep(5000); + log.info("------------------VID-10 TC-3, VID-12 TC-12,--------------------"); + //Infrastructure Subscriber Type + Select iSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown")))); + + List <WebElement> ielementCount = iSelect.getOptions(); + log.info("Select Element Count of Service type"); + System.out.println(ielementCount.size()); + iSelect.selectByIndex(1); + + log.info("VID-10 TC-3 PASSED"); + + + //Submit button is clicked + driver.findElement(By.xpath(configProp.getProperty("submitButton"))).click(); + + //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:" + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed(); + //Assert.assertTrue(driver.getPageSource().contains("Selected Subscriber's Service Instance Details:")) + log.info("Page Header: Selected Subscriber's Service Instance Details"); + + + //Verify whether the page header is displayed "Global Customer ID" + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/thead/tr/th[2]/div")).isDisplayed(); + + //Assert.assertTrue(driver.getPageSource().contains("Global Customer ID")); + log.info("Table is displayed"); + + log.info("VID-12 TC-12 PASSED"); + + } + + + + /** + * Logout under profile. + */ + @Test(priority=10) + public void logoutUnderProfile() + { + + log.info("-----------VID-11 TC-5---------------------"); + //driver.findElement(By.partialLinkText("Click here to login")).click(); + //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + + + driver.findElement(By.xpath(".//*[@class='icon-user-small login-snippet-icon']")).click(); + driver.findElement(By.xpath(".//*[@id='reg-logout-div']/a")).click(); + //Validate that the user has logged out of VID. Displays "Portal" + Assert.assertTrue(driver.getPageSource().contains("Portal")); + + log.info("VID-11 TC-5 PASSED"); + + } + + + + /** + * Tear down. + */ + @AfterClass + public void tearDown() + { + driver.close(); + + } + + + + } + + + + diff --git a/vid-app-common/src/test/java/org/onap/ecomp/vid/selenium/LogOutLeftPane.java b/vid-app-common/src/test/java/org/onap/ecomp/vid/selenium/LogOutLeftPane.java new file mode 100644 index 000000000..fdd5ea38d --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/ecomp/vid/selenium/LogOutLeftPane.java @@ -0,0 +1,242 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.ecomp.vid.selenium; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import org.apache.log4j.Logger; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.support.ui.Select; +import org.testng.Assert; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +/** + * The Class LogOutLeftPane. + */ +@Test(enabled=false) +public class LogOutLeftPane { + + /** The login button. */ + WebElement loginButton; + + /** The login. */ + WebElement login; + + /** The pwd. */ + WebElement pwd; + + /** The log. */ + Logger log; + + /** The errormessage. */ + WebElement errormessage; + + /** The driver. */ + WebDriver driver=new FirefoxDriver(); + + + /** The config prop. */ + private final Properties configProp = new Properties(); + + + /** + * Instantiates a new log out left pane. + */ + private LogOutLeftPane() { + // TODO Auto-generated constructor stub + // + try{ + // InputStream input =this.getClass().getClassLoader().getResourceAsStream("objectmap.properties"); + //FileInputStream input1 = new FileInputStream("objectmap.properties"); + + InputStream input =new FileInputStream("objectconfig.properties"); + System.out.println("Read all properties from file"); + configProp.load(input); + System.out.println("Read all properties from file completed"); + } + catch(IOException e) { + + e.printStackTrace(); + } + } + + + + + /** + * Do before test. + */ + // TODO Auto-generated method stub + @BeforeTest + public void doBeforeTest() + { + //WebDriver driver=new FirefoxDriver(); + + log = Logger.getLogger(LogOutLeftPane.class.getName()); + + + + // Get url + driver.get("http://vid.onap.org:9080/vid/login_external.htm"); + driver.manage().window().maximize(); + + + login = driver.findElement(By.xpath("//input[@class='fn-ebz-text ng-pristine ng-valid']")); + pwd = driver.findElement(By.xpath("//input[@class='span3 ng-pristine ng-valid']")); + loginButton = driver.findElement(By.id("loginBtn")); + } + + + /** + * Expand collapse panel. + * + * @throws InterruptedException the interrupted exception + */ + @Test(priority=1) + public void expandCollapsePanel() throws InterruptedException + { + + + + login.clear(); + login.sendKeys("su"); + pwd.clear(); + pwd.sendKeys("fusion"); + //driver.findElement(By.partialLinkText("Click here to login")).click(); + //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + + loginButton.click(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + + + log.info("Clicking Profile link from left pane"); + Thread.sleep(3000); + System.out.println("properties file details --->"+configProp.getProperty("profilelink")); + driver.findElement(By.xpath(configProp.getProperty("profilelink"))).click(); + Thread.sleep(3000); + + //Verify whether the sub panel is displayed + //To verify the following :Search import from webphone and Self + driver.findElement(By.xpath(".//*[@id='panel4']")).isDisplayed(); + log.info("Expand and collapse passed for Profile link"); + + //For Admin + //Verify expand and collapse working for ADMIN + log.info("Clicking Admin link from left pane"); + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[6]/a/span")).click(); + //To verify the following: Roles, Roles Functions, Usages + driver.findElement(By.xpath(".//*[@id='panel5']")).isDisplayed(); + + + log.info("Expand and collapse passed for ADMIN link"); + + log.info("VID-11 TC-3 PASSED"); + + } + + + /** + * Drop down list. + * + * @throws InterruptedException the interrupted exception + */ + @Test(priority=2) + public void dropDownList() throws InterruptedException + { + //VID-12 TC-3 + log.info("VID-12 TC-3"); + //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select")); + + //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select")); + Thread.sleep(5000); + + //Infrastructure Subscriber Name + Select oSelect = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"))); + Select iSelect = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select"))); + + List <WebElement> elementCount = oSelect.getOptions(); + log.info("Subscriber Name Drop Down"); + System.out.println(elementCount.size()); + oSelect.selectByIndex(1); + log.info("Subscriber name selected"); + //String selectedOption = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"))).getFirstSelectedOption().getText(); + + + List <WebElement> count = iSelect.getOptions(); + log.info("Subscriber type drop down"); + System.out.println(count.size()); + oSelect.selectByIndex(1); + log.info("Subscriber type selected"); + + + + //Submit button is clicked + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[3]/td/div/button")).click(); + + + //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:" + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed(); + log.info("VID-12 TC-3 PASSED"); + } + + + + + /** + * Logout left pane. + */ + @Test(priority=3) + public void logoutLeftPane() + { + //To Verify if the logout link redirects to Login page when clicked. + + + /*log.info("----------------VID-11 TC-4----------------"); + login.clear(); + login.sendKeys("testuser"); + pwd.clear(); + pwd.sendKeys("abc123"); + //driver.findElement(By.partialLinkText("Click here to login")).click(); + //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + + loginButton.click(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);*/ + log.info("----------------VID-11 TC-4----------------"); + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[7]/a")).click(); + //Validate that the user has logged out of VID. Displays "Portal" + Assert.assertTrue(driver.getPageSource().contains("Portal")); + + log.info("VID 11 TC-4 PASSED"); + + driver.close(); + + } + +} diff --git a/vid-app-common/src/test/java/org/onap/fusion/core/MockApplicationContextTestSuite.java b/vid-app-common/src/test/java/org/onap/fusion/core/MockApplicationContextTestSuite.java new file mode 100644 index 000000000..bd6854911 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/fusion/core/MockApplicationContextTestSuite.java @@ -0,0 +1,177 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.fusion.core; + +import java.io.IOException; + +import org.junit.Before; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.AnnotationConfigWebContextLoader; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.testng.annotations.Test; +import org.openecomp.portalsdk.core.conf.AppConfig; +import org.openecomp.portalsdk.core.objectcache.AbstractCacheManager; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.portalsdk.core.util.CacheManager; + +/** + * + * + * + * In order to write a unit test, + * 1. inherit this class - See SanityTest.java + * 2. place the "war" folder on your test class's classpath + * 3. run the test with the following VM argument; This is important because when starting the application from Container, the System Properties file (SystemProperties.java) can have the direct path + * but, when running from the Mock Junit container, the path should be prefixed with "classpath" to enable the mock container to search for the file in the classpath + * -Dcontainer.classpath="classpath:" + * + */ + +@RunWith(SpringJUnit4ClassRunner.class) +@WebAppConfiguration +@ContextConfiguration(loader = AnnotationConfigWebContextLoader.class, classes = {MockAppConfig.class}) +@ActiveProfiles(value="test") +@Test(enabled=false) +public class MockApplicationContextTestSuite { + + /** The wac. */ + @Autowired + public WebApplicationContext wac; + + /** The mock mvc. */ + private MockMvc mockMvc; + + /** + * Setup. + */ + @Before + public void setup() { + if(mockMvc == null) { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); + + } + } + + /** + * Gets the bean. + * + * @param name the name + * @return the bean + */ + public Object getBean(String name) { + return this.wac.getBean(name); + } + + + /** + * Gets the mock mvc. + * + * @return the mock mvc + */ + public MockMvc getMockMvc() { + return mockMvc; + } + + /** + * Sets the mock mvc. + * + * @param mockMvc the new mock mvc + */ + public void setMockMvc(MockMvc mockMvc) { + this.mockMvc = mockMvc; + } + + /** + * Gets the web application context. + * + * @return the web application context + */ + public WebApplicationContext getWebApplicationContext() { + return wac; + } + + + + +} + + + @Configuration + @ComponentScan(basePackages = "org.onap", + excludeFilters = { + // the following source configurations should not be scanned; instead of using Exclusion filter, we can use the @Profile annotation to exclude them + // see AppConfig class + //@ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.onap.portalsdk.core.*AppConfig*")//, + //@ComponentScan.Filter(type = FilterType.REGEX, pattern = org.onap.*.*AppConfig*") + } + ) + @Profile("test") + class MockAppConfig extends AppConfig { + + @Bean + public SystemProperties systemProperties(){ + return new MockSystemProperties(); + } + + @Bean + public AbstractCacheManager cacheManager() { + return new CacheManager() { + + public void configure() throws IOException { + + } + }; + } + + protected String[] tileDefinitions() { + return new String[] {"classpath:/WEB-INF/fusion/defs/definitions.xml", "classpath:/WEB-INF/defs/definitions.xml"}; + } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + //registry.addInterceptor(new SessionTimeoutInterceptor()).excludePathPatterns(getExcludeUrlPathsForSessionTimeout()); + //registry.addInterceptor(resourceInterceptor()); + } + + public static class MockSystemProperties extends SystemProperties { + + public MockSystemProperties() { + } + + } + + } + + + + diff --git a/vid-app-common/src/test/java/org/onap/fusionapp/controller/NetMapTest.java b/vid-app-common/src/test/java/org/onap/fusionapp/controller/NetMapTest.java new file mode 100644 index 000000000..7a4c56019 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/fusionapp/controller/NetMapTest.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.fusionapp.controller; + +import org.junit.Assert; +import org.junit.Test; +import org.springframework.test.web.servlet.ResultActions; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import org.onap.fusion.core.MockApplicationContextTestSuite; + +/** + * The Class NetMapTest. + */ + +public class NetMapTest extends MockApplicationContextTestSuite { + + /** + * Test get net map. + * + * @throws Exception the exception + */ +// @Test + public void testGetNetMap() throws Exception { + ResultActions ra =getMockMvc().perform(MockMvcRequestBuilders.get("/net_map")); + //Assert.assertEquals(UrlAccessRestrictedException.class,ra.andReturn().getResolvedException().getClass()); + Assert.assertEquals("net_map_int",ra.andReturn().getModelAndView().getModel().get("frame_int")); + } + + +} diff --git a/vid-app-common/src/test/java/org/onap/fusionapp/service/ProfileServiceTest.java b/vid-app-common/src/test/java/org/onap/fusionapp/service/ProfileServiceTest.java new file mode 100644 index 000000000..212074fcd --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/fusionapp/service/ProfileServiceTest.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.fusionapp.service; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import org.onap.fusion.core.MockApplicationContextTestSuite; +import org.openecomp.portalsdk.core.domain.Profile; +import org.openecomp.portalsdk.core.domain.User; +import org.openecomp.portalsdk.core.service.ProfileService; +import org.openecomp.portalsdk.core.service.UserProfileService; + + +/** + * The Class ProfileServiceTest. + */ + +public class ProfileServiceTest extends MockApplicationContextTestSuite { + + /** The service. */ + @Autowired + ProfileService service; + + /** The user profile service. */ + @Autowired + UserProfileService userProfileService; + + /** + * Test find all. + */ + //@Test + public void testFindAll() { + try { + List<Profile> profiles = service.findAll(); + Assert.assertTrue(profiles.size() > 0); + + } + catch (Exception e) { + // TODO: handle exception + } + } + + /** + * Test find all active. + */ +// @Test + public void testFindAllActive() { + + List<User> users = userProfileService.findAllActive(); + List<User> activeUsers = userProfileService.findAllActive(); + Assert.assertTrue(users.size() - activeUsers.size() >= 0); + } +} diff --git a/vid-app-common/src/test/java/org/onap/src/main/java/org/vid/dao/FnAppDoaImplTest.java b/vid-app-common/src/test/java/org/onap/src/main/java/org/vid/dao/FnAppDoaImplTest.java new file mode 100644 index 000000000..e98e7b205 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/src/main/java/org/vid/dao/FnAppDoaImplTest.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.src.main.java.org.vid.dao; + +import java.io.IOException; +import java.sql.SQLException; + +import org.junit.Test; + +import org.onap.vid.dao.FnAppDoaImpl; + +public class FnAppDoaImplTest { + + //@Test + public void testGetconnection() throws ClassNotFoundException, IOException, SQLException{ + FnAppDoaImpl impl=new FnAppDoaImpl(); + impl.getConnection(null,null,null, null); + + } + + //@Test + public void testProfileCount() throws ClassNotFoundException, IOException, SQLException{ + FnAppDoaImpl impl=new FnAppDoaImpl(); + impl.getProfileCount(null,null,null, null); + } + +} diff --git a/vid-app-common/src/test/java/org/onap/vid/RelatedToTest.java b/vid-app-common/src/test/java/org/onap/vid/RelatedToTest.java new file mode 100644 index 000000000..ca4ac1b81 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/RelatedToTest.java @@ -0,0 +1,37 @@ +package org.onap.vid; + +import java.util.Map; + +import org.junit.Test; +import org.onap.vid.RelatedTo; + + +public class RelatedToTest { + + private RelatedTo createTestSubject() { + return new RelatedTo(); + } + + + @Test + public void testGetAdditionalProperties() throws Exception { + RelatedTo testSubject; + Map<String, Object> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAdditionalProperties(); + } + + + @Test + public void testSetAdditionalProperty() throws Exception { + RelatedTo testSubject; + String name = ""; + Object value = null; + + // default test + testSubject = createTestSubject(); + testSubject.setAdditionalProperty(name, value); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/TestSuite.java new file mode 100644 index 000000000..e70d7fe25 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/TestSuite.java @@ -0,0 +1,11 @@ +package org.onap.vid; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ RelatedToTest.class, org.onap.vid.aai.TestSuite.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiGetVnfResponseTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiGetVnfResponseTest.java new file mode 100644 index 000000000..7889d5148 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiGetVnfResponseTest.java @@ -0,0 +1,33 @@ +package org.onap.vid.aai; + +import java.util.Map; + +import org.junit.Test; + +public class AaiGetVnfResponseTest { + + private AaiGetVnfResponse createTestSubject() { + return new AaiGetVnfResponse(); + } + + @Test + public void testGetAdditionalProperties() throws Exception { + AaiGetVnfResponse testSubject; + Map<String, Object> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAdditionalProperties(); + } + + @Test + public void testSetAdditionalProperty() throws Exception { + AaiGetVnfResponse testSubject; + String name = ""; + Object value = null; + + // default test + testSubject = createTestSubject(); + testSubject.setAdditionalProperty(name, value); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/ServicePropertiesTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/ServicePropertiesTest.java new file mode 100644 index 000000000..577f52820 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/aai/ServicePropertiesTest.java @@ -0,0 +1,34 @@ +package org.onap.vid.aai; + +import java.util.Map; + +import org.junit.Test; +import org.onap.vid.aai.model.ServiceProperties; + +public class ServicePropertiesTest { + + private ServiceProperties createTestSubject() { + return new ServiceProperties(); + } + + @Test + public void testGetAdditionalProperties() throws Exception { + ServiceProperties testSubject; + Map<String, Object> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAdditionalProperties(); + } + + @Test + public void testSetAdditionalProperty() throws Exception { + ServiceProperties testSubject; + String name = ""; + Object value = null; + + // default test + testSubject = createTestSubject(); + testSubject.setAdditionalProperty(name, value); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberAaiResponseTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberAaiResponseTest.java new file mode 100644 index 000000000..c01fe27e6 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberAaiResponseTest.java @@ -0,0 +1,22 @@ +package org.onap.vid.aai; + +import org.junit.Test; +import org.onap.vid.model.SubscriberList; + +public class SubscriberAaiResponseTest { + + private SubscriberAaiResponse createTestSubject() { + return new SubscriberAaiResponse(new SubscriberList(), "", 0); + } + + + @Test + public void testGetSubscriberList() throws Exception { + SubscriberAaiResponse testSubject; + SubscriberList result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getSubscriberList(); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberWithFilterTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberWithFilterTest.java new file mode 100644 index 000000000..c76e5cdc2 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberWithFilterTest.java @@ -0,0 +1,30 @@ +package org.onap.vid.aai; + +import org.junit.Test; + +public class SubscriberWithFilterTest { + + private SubscriberWithFilter createTestSubject() { + return new SubscriberWithFilter(); + } + + @Test + public void testGetIsPermitted() throws Exception { + SubscriberWithFilter testSubject; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getIsPermitted(); + } + + @Test + public void testSetIsPermitted() throws Exception { + SubscriberWithFilter testSubject; + boolean isPermitted = false; + + // default test + testSubject = createTestSubject(); + testSubject.setIsPermitted(isPermitted); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/aai/TestSuite.java new file mode 100644 index 000000000..eac3bdf26 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/aai/TestSuite.java @@ -0,0 +1,12 @@ +package org.onap.vid.aai; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ SubscriberAaiResponseTest.class, AaiGetVnfResponseTest.class, ServicePropertiesTest.class, + SubscriberWithFilterTest.class, VnfResultTest.class, org.onap.vid.aai.model.TestSuite.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java new file mode 100644 index 000000000..2b7a60429 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java @@ -0,0 +1,34 @@ +package org.onap.vid.aai; + +import java.util.Map; + +import org.junit.Test; +import org.onap.vid.aai.model.VnfResult; + +public class VnfResultTest { + + private VnfResult createTestSubject() { + return new VnfResult(); + } + + @Test + public void testGetAdditionalProperties() throws Exception { + VnfResult testSubject; + Map<String, Object> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAdditionalProperties(); + } + + @Test + public void testSetAdditionalProperty() throws Exception { + VnfResult testSubject; + String name = ""; + Object value = null; + + // default test + testSubject = createTestSubject(); + testSubject.setAdditionalProperty(name, value); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/RelatedToPropertyTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelatedToPropertyTest.java new file mode 100644 index 000000000..0d26f5607 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelatedToPropertyTest.java @@ -0,0 +1,55 @@ +package org.onap.vid.aai.model; + +import org.junit.Test; + + +public class RelatedToPropertyTest { + + private RelatedToProperty createTestSubject() { + return new RelatedToProperty(); + } + + + @Test + public void testGetPropertyKey() throws Exception { + RelatedToProperty testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getPropertyKey(); + } + + + @Test + public void testSetPropertyKey() throws Exception { + RelatedToProperty testSubject; + String propertyKey = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setPropertyKey(propertyKey); + } + + + @Test + public void testGetPropertyValue() throws Exception { + RelatedToProperty testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getPropertyValue(); + } + + + @Test + public void testSetPropertyValue() throws Exception { + RelatedToProperty testSubject; + String propertyValue = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setPropertyValue(propertyValue); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipDataTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipDataTest.java new file mode 100644 index 000000000..ae5f7c39a --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipDataTest.java @@ -0,0 +1,55 @@ +package org.onap.vid.aai.model; + +import org.junit.Test; + + +public class RelationshipDataTest { + + private RelationshipData createTestSubject() { + return new RelationshipData(); + } + + + @Test + public void testGetRelationshipKey() throws Exception { + RelationshipData testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelationshipKey(); + } + + + @Test + public void testSetRelationshipKey() throws Exception { + RelationshipData testSubject; + String relationshipKey = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setRelationshipKey(relationshipKey); + } + + + @Test + public void testGetRelationshipValue() throws Exception { + RelationshipData testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelationshipValue(); + } + + + @Test + public void testSetRelationshipValue() throws Exception { + RelationshipData testSubject; + String relationshipValue = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setRelationshipValue(relationshipValue); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipTest.java new file mode 100644 index 000000000..893fc51fc --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipTest.java @@ -0,0 +1,103 @@ +package org.onap.vid.aai.model; + +import java.util.List; + +import org.junit.Test; +import org.onap.vid.aai.model.Relationship; +import org.onap.vid.aai.model.RelationshipData; + + +public class RelationshipTest { + + private Relationship createTestSubject() { + return new Relationship(); + } + + + @Test + public void testGetRelatedTo() throws Exception { + Relationship testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelatedTo(); + } + + + @Test + public void testSetRelatedTo() throws Exception { + Relationship testSubject; + String relatedTo = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setRelatedTo(relatedTo); + } + + + @Test + public void testGetRelatedLink() throws Exception { + Relationship testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelatedLink(); + } + + + @Test + public void testSetRelatedLink() throws Exception { + Relationship testSubject; + String relatedLink = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setRelatedLink(relatedLink); + } + + + @Test + public void testGetRelationDataList() throws Exception { + Relationship testSubject; + List<RelationshipData> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelationDataList(); + } + + + @Test + public void testSetRelationDataList() throws Exception { + Relationship testSubject; + List<RelationshipData> relationDataList = null; + + // default test + testSubject = createTestSubject(); + testSubject.setRelationDataList(relationDataList); + } + + + @Test + public void testGetRelatedToPropertyList() throws Exception { + Relationship testSubject; + List<RelatedToProperty> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelatedToPropertyList(); + } + + + @Test + public void testSetRelatedToPropertyList() throws Exception { + Relationship testSubject; + List<RelatedToProperty> relatedToPropertyList = null; + + // default test + testSubject = createTestSubject(); + testSubject.setRelatedToPropertyList(relatedToPropertyList); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/ServiceRelationshipsTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/ServiceRelationshipsTest.java new file mode 100644 index 000000000..e8bcf5f57 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/ServiceRelationshipsTest.java @@ -0,0 +1,165 @@ +package org.onap.vid.aai.model; + +import org.junit.Test; + + +public class ServiceRelationshipsTest { + + private ServiceRelationships createTestSubject() { + return new ServiceRelationships(); + } + + + @Test + public void testGetServiceInstanceId() throws Exception { + ServiceRelationships testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getServiceInstanceId(); + } + + + @Test + public void testSetServiceInstanceId() throws Exception { + ServiceRelationships testSubject; + String serviceInstanceId = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setServiceInstanceId(serviceInstanceId); + } + + + @Test + public void testGetServiceInstanceName() throws Exception { + ServiceRelationships testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getServiceInstanceName(); + } + + + @Test + public void testSetServiceInstanceName() throws Exception { + ServiceRelationships testSubject; + String serviceInstanceName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setServiceInstanceName(serviceInstanceName); + } + + + @Test + public void testGetModelInvariantId() throws Exception { + ServiceRelationships testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getModelInvariantId(); + } + + + @Test + public void testSetModelInvariantId() throws Exception { + ServiceRelationships testSubject; + String modelInvariantId = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setModelInvariantId(modelInvariantId); + } + + + @Test + public void testGetModelVersionId() throws Exception { + ServiceRelationships testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getModelVersionId(); + } + + + @Test + public void testSetModelVersionId() throws Exception { + ServiceRelationships testSubject; + String modelVersionId = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setModelVersionId(modelVersionId); + } + + + @Test + public void testGetResourceVersion() throws Exception { + ServiceRelationships testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResourceVersion(); + } + + + @Test + public void testSetResourceVersion() throws Exception { + ServiceRelationships testSubject; + String resourceVersion = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setResourceVersion(resourceVersion); + } + + + @Test + public void testGetOrchestrationStatus() throws Exception { + ServiceRelationships testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getOrchestrationStatus(); + } + + + @Test + public void testSetOrchestrationStatus() throws Exception { + ServiceRelationships testSubject; + String orchestrationStatus = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setOrchestrationStatus(orchestrationStatus); + } + + + @Test + public void testGetRelationshipList() throws Exception { + ServiceRelationships testSubject; + RelationshipList result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelationshipList(); + } + + + @Test + public void testSetRelationshipList() throws Exception { + ServiceRelationships testSubject; + RelationshipList relationshipList = null; + + // default test + testSubject = createTestSubject(); + testSubject.setRelationshipList(relationshipList); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/TestSuite.java new file mode 100644 index 000000000..8d5f62e54 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/TestSuite.java @@ -0,0 +1,11 @@ +package org.onap.vid.aai.model; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ ServiceRelationshipsTest.class, RelationshipTest.class, RelatedToPropertyTest.class, RelationshipDataTest.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/ArtifactTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/ArtifactTest.java new file mode 100644 index 000000000..04944120a --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/ArtifactTest.java @@ -0,0 +1,277 @@ +package org.onap.vid.asdc.beans; + +import org.junit.Test; + + +public class ArtifactTest { + + private Artifact createTestSubject() { + return new Artifact(); + } + + + @Test + public void testGetArtifactName() throws Exception { + Artifact testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactName(); + } + + + @Test + public void testGetArtifactType() throws Exception { + Artifact testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactType(); + } + + + @Test + public void testGetArtifactGroupType() throws Exception { + Artifact testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactGroupType(); + } + + + @Test + public void testGetArtifactLabel() throws Exception { + Artifact testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactLabel(); + } + + + @Test + public void testGetArtifactURL() throws Exception { + Artifact testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactURL(); + } + + + @Test + public void testGetArtifactDescription() throws Exception { + Artifact testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactDescription(); + } + + + @Test + public void testGetArtifactTimeout() throws Exception { + Artifact testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactTimeout(); + } + + + @Test + public void testGetArtifactChecksum() throws Exception { + Artifact testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactChecksum(); + } + + + @Test + public void testGetArtifactUUID() throws Exception { + Artifact testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactUUID(); + } + + + @Test + public void testGetArtifactVersion() throws Exception { + Artifact testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifactVersion(); + } + + + @Test + public void testGetGeneratedFromUUID() throws Exception { + Artifact testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getGeneratedFromUUID(); + } + + + @Test + public void testSetArtifactName() throws Exception { + Artifact testSubject; + String artifactName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactName(artifactName); + } + + + @Test + public void testSetArtifactType() throws Exception { + Artifact testSubject; + String artifactType = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactType(artifactType); + } + + + @Test + public void testSetArtifactGroupType() throws Exception { + Artifact testSubject; + String artifactGroupType = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactGroupType(artifactGroupType); + } + + + @Test + public void testSetArtifactLabel() throws Exception { + Artifact testSubject; + String artifactLabel = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactLabel(artifactLabel); + } + + + @Test + public void testSetArtifactURL() throws Exception { + Artifact testSubject; + String artifactURL = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactURL(artifactURL); + } + + + @Test + public void testSetArtifactDescription() throws Exception { + Artifact testSubject; + String artifactDescription = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactDescription(artifactDescription); + } + + + @Test + public void testSetArtifactTimeout() throws Exception { + Artifact testSubject; + int artifactTimeout = 0; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactTimeout(artifactTimeout); + } + + + @Test + public void testSetArtifactChecksum() throws Exception { + Artifact testSubject; + String artifactChecksum = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactChecksum(artifactChecksum); + } + + + @Test + public void testSetArtifactUUID() throws Exception { + Artifact testSubject; + String artifactUUID = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactUUID(artifactUUID); + } + + + @Test + public void testSetArtifactVersion() throws Exception { + Artifact testSubject; + String artifactVersion = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactVersion(artifactVersion); + } + + + @Test + public void testSetGeneratedFromUUID() throws Exception { + Artifact testSubject; + String generatedFromUUID = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setGeneratedFromUUID(generatedFromUUID); + } + + + @Test + public void testHashCode() throws Exception { + Artifact testSubject; + int result; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifactUUID("48a52540-8772-4368-9cdb-1f124ea5c931"); + result = testSubject.hashCode(); + } + + + @Test + public void testEquals() throws Exception { + Artifact testSubject; + Object o = null; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.equals(o); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/ResourceTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/ResourceTest.java new file mode 100644 index 000000000..af42409cd --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/ResourceTest.java @@ -0,0 +1,391 @@ +package org.onap.vid.asdc.beans; + +import java.util.Collection; + +import org.junit.Test; +import org.onap.vid.asdc.beans.Resource.LifecycleState; +import org.onap.vid.asdc.beans.Resource.Type; + + +public class ResourceTest { + + private Resource createTestSubject() { + return new Resource(); + } + + + @Test + public void testGetUuid() throws Exception { + Resource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getUuid(); + } + + + @Test + public void testGetInvariantUUID() throws Exception { + Resource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getInvariantUUID(); + } + + + @Test + public void testGetName() throws Exception { + Resource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getName(); + } + + + @Test + public void testGetDescription() throws Exception { + Resource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDescription(); + } + + + @Test + public void testGetVersion() throws Exception { + Resource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVersion(); + } + + + @Test + public void testGetToscaModelURL() throws Exception { + Resource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getToscaModelURL(); + } + + + @Test + public void testGetCategory() throws Exception { + Resource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getCategory(); + } + + + @Test + public void testGetSubCategory() throws Exception { + Resource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getSubCategory(); + } + + + @Test + public void testGetResourceType() throws Exception { + Resource testSubject; + Type result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResourceType(); + } + + + @Test + public void testGetLifecycleState() throws Exception { + Resource testSubject; + LifecycleState result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLifecycleState(); + } + + + @Test + public void testGetLastUpdaterUserId() throws Exception { + Resource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLastUpdaterUserId(); + } + + + @Test + public void testGetLastUpdaterFullName() throws Exception { + Resource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLastUpdaterFullName(); + } + + + @Test + public void testGetToscaModel() throws Exception { + Resource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getToscaModel(); + } + + + @Test + public void testGetToscaResourceName() throws Exception { + Resource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getToscaResourceName(); + } + + + @Test + public void testGetArtifacts() throws Exception { + Resource testSubject; + Collection<Artifact> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifacts(); + } + + + @Test + public void testGetResources() throws Exception { + Resource testSubject; + Collection<SubResource> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResources(); + } + + + @Test + public void testSetUuid() throws Exception { + Resource testSubject; + String uuid = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setUuid(uuid); + } + + + @Test + public void testSetInvariantUUID() throws Exception { + Resource testSubject; + String invariantUUID = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setInvariantUUID(invariantUUID); + } + + + @Test + public void testSetName() throws Exception { + Resource testSubject; + String name = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setName(name); + } + + + @Test + public void testSetDescription() throws Exception { + Resource testSubject; + String description = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setDescription(description); + } + + + @Test + public void testSetVersion() throws Exception { + Resource testSubject; + String version = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setVersion(version); + } + + + @Test + public void testSetToscaModelURL() throws Exception { + Resource testSubject; + String toscaModelURL = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setToscaModelURL(toscaModelURL); + } + + + @Test + public void testSetCategory() throws Exception { + Resource testSubject; + String category = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setCategory(category); + } + + + @Test + public void testSetSubCategory() throws Exception { + Resource testSubject; + String subCategory = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setSubCategory(subCategory); + } + + + @Test + public void testSetResourceType() throws Exception { + Resource testSubject; + Type resourceType = null; + + // default test + testSubject = createTestSubject(); + testSubject.setResourceType(resourceType); + } + + + @Test + public void testSetLifecycleState() throws Exception { + Resource testSubject; + LifecycleState lifecycleState = null; + + // default test + testSubject = createTestSubject(); + testSubject.setLifecycleState(lifecycleState); + } + + + @Test + public void testSetLastUpdaterUserId() throws Exception { + Resource testSubject; + String lastUpdaterUserId = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setLastUpdaterUserId(lastUpdaterUserId); + } + + + @Test + public void testSetLastUpdaterFullName() throws Exception { + Resource testSubject; + String lastUpdaterFullName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setLastUpdaterFullName(lastUpdaterFullName); + } + + + @Test + public void testSetToscaModel() throws Exception { + Resource testSubject; + String toscaModel = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setToscaModel(toscaModel); + } + + + @Test + public void testSetToscaResourceName() throws Exception { + Resource testSubject; + String toscaResourceName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setToscaResourceName(toscaResourceName); + } + + + @Test + public void testSetArtifacts() throws Exception { + Resource testSubject; + Collection<Artifact> artifacts = null; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifacts(artifacts); + } + + + @Test + public void testSetResources() throws Exception { + Resource testSubject; + Collection<SubResource> resources = null; + + // default test + testSubject = createTestSubject(); + testSubject.setResources(resources); + } + + + @Test + public void testHashCode() throws Exception { + Resource testSubject; + int result; + + // default test + testSubject = createTestSubject(); + testSubject.setUuid("cb49608f-5a24-4789-b0f7-2595473cb997"); + result = testSubject.hashCode(); + } + + + @Test + public void testEquals() throws Exception { + Resource testSubject; + Object o = null; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.equals(o); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/SubResourceTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/SubResourceTest.java new file mode 100644 index 000000000..e1672b71e --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/SubResourceTest.java @@ -0,0 +1,167 @@ +package org.onap.vid.asdc.beans; + +import java.util.Collection; + +import org.junit.Test; + + +public class SubResourceTest { + + private SubResource createTestSubject() { + return new SubResource(); + } + + + @Test + public void testGetResourceInstanceName() throws Exception { + SubResource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResourceInstanceName(); + } + + + @Test + public void testGetResourceName() throws Exception { + SubResource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResourceName(); + } + + + @Test + public void testGetResourceInvariantUUID() throws Exception { + SubResource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResourceInvariantUUID(); + } + + + @Test + public void testGetResourceVersion() throws Exception { + SubResource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResourceVersion(); + } + + + @Test + public void testGetResoucreType() throws Exception { + SubResource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResoucreType(); + } + + + @Test + public void testGetResourceUUID() throws Exception { + SubResource testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResourceUUID(); + } + + + @Test + public void testGetArtifacts() throws Exception { + SubResource testSubject; + Collection<Artifact> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getArtifacts(); + } + + + @Test + public void testSetResourceInstanceName() throws Exception { + SubResource testSubject; + String resourceInstanceName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setResourceInstanceName(resourceInstanceName); + } + + + @Test + public void testSetResourceName() throws Exception { + SubResource testSubject; + String resourceName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setResourceName(resourceName); + } + + + @Test + public void testSetResourceInvariantUUID() throws Exception { + SubResource testSubject; + String resourceInvariantUUID = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setResourceInvariantUUID(resourceInvariantUUID); + } + + + @Test + public void testSetResourceVersion() throws Exception { + SubResource testSubject; + String resourceVersion = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setResourceVersion(resourceVersion); + } + + + @Test + public void testSetResoucreType() throws Exception { + SubResource testSubject; + String resourceType = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setResoucreType(resourceType); + } + + + @Test + public void testSetResourceUUID() throws Exception { + SubResource testSubject; + String resourceUUID = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setResourceUUID(resourceUUID); + } + + + @Test + public void testSetArtifacts() throws Exception { + SubResource testSubject; + Collection<Artifact> artifacts = null; + + // default test + testSubject = createTestSubject(); + testSubject.setArtifacts(artifacts); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/TestSuite.java new file mode 100644 index 000000000..6f0d47a2e --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/TestSuite.java @@ -0,0 +1,11 @@ +package org.onap.vid.asdc.beans; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ ArtifactTest.class, ResourceTest.class, SubResourceTest.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/CapabilityTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/CapabilityTest.java new file mode 100644 index 000000000..7609e36d1 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/CapabilityTest.java @@ -0,0 +1,124 @@ +package org.onap.vid.asdc.beans.tosca; + +import java.util.Collection; +import java.util.Map; + +import org.junit.Test; + + +public class CapabilityTest { + + private Capability createTestSubject() { + return new Capability(); + } + + + @Test + public void testGetType() throws Exception { + Capability testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getType(); + } + + + @Test + public void testGetDescription() throws Exception { + Capability testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDescription(); + } + + + @Test + public void testGetOccurrences() throws Exception { + Capability testSubject; + Collection<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getOccurrences(); + } + + + @Test + public void testGetProperties() throws Exception { + Capability testSubject; + Map<String, Property> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getProperties(); + } + + + @Test + public void testGetValid_source_types() throws Exception { + Capability testSubject; + Collection<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getValid_source_types(); + } + + + @Test + public void testSetType() throws Exception { + Capability testSubject; + String type = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setType(type); + } + + + @Test + public void testSetDescription() throws Exception { + Capability testSubject; + String description = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setDescription(description); + } + + + @Test + public void testSetOccurrences() throws Exception { + Capability testSubject; + Collection<String> occurrences = null; + + // default test + testSubject = createTestSubject(); + testSubject.setOccurrences(occurrences); + } + + + @Test + public void testSetProperties() throws Exception { + Capability testSubject; + Map<String, Property> properties = null; + + // default test + testSubject = createTestSubject(); + testSubject.setProperties(properties); + } + + + @Test + public void testSetValid_source_types() throws Exception { + Capability testSubject; + Collection<String> valid_source_types = null; + + // default test + testSubject = createTestSubject(); + testSubject.setValid_source_types(valid_source_types); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/ConstraintTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/ConstraintTest.java new file mode 100644 index 000000000..ebba7d172 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/ConstraintTest.java @@ -0,0 +1,221 @@ +package org.onap.vid.asdc.beans.tosca; + +import java.util.List; + +import org.junit.Test; + +public class ConstraintTest { + + private Constraint createTestSubject() { + return new Constraint(); + } + + + @Test + public void testGetvalid_values() throws Exception { + Constraint testSubject; + List<Object> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getvalid_values(); + } + + + @Test + public void testGetEqual() throws Exception { + Constraint testSubject; + Object result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getEqual(); + } + + + @Test + public void testGetGreater_than() throws Exception { + Constraint testSubject; + Object result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getGreater_than(); + } + + + @Test + public void testGetGreater_or_equal() throws Exception { + Constraint testSubject; + Object result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getGreater_or_equal(); + } + + + @Test + public void testGetLess_than() throws Exception { + Constraint testSubject; + Object result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLess_than(); + } + + + @Test + public void testGetLess_or_equal() throws Exception { + Constraint testSubject; + Object result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLess_or_equal(); + } + + + @Test + public void testGetIn_range() throws Exception { + Constraint testSubject; + List<Object> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getIn_range(); + } + + + @Test + public void testGetLength() throws Exception { + Constraint testSubject; + Object result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLength(); + } + + + @Test + public void testGetMin_length() throws Exception { + Constraint testSubject; + Object result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getMin_length(); + } + + + @Test + public void testGetMax_length() throws Exception { + Constraint testSubject; + Object result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getMax_length(); + } + + + @Test + public void testSetvalid_values() throws Exception { + Constraint testSubject; + List<Object> vlist = null; + + // default test + testSubject = createTestSubject(); + testSubject.setvalid_values(vlist); + } + + + @Test + public void testSetEqual() throws Exception { + Constraint testSubject; + Object e = null; + + // default test + testSubject = createTestSubject(); + testSubject.setEqual(e); + } + + + @Test + public void testSetGreater_than() throws Exception { + Constraint testSubject; + Object e = null; + + // default test + testSubject = createTestSubject(); + testSubject.setGreater_than(e); + } + + + @Test + public void testSetLess_than() throws Exception { + Constraint testSubject; + Object e = null; + + // default test + testSubject = createTestSubject(); + testSubject.setLess_than(e); + } + + + @Test + public void testSetIn_range() throws Exception { + Constraint testSubject; + List<Object> e = null; + + // default test + testSubject = createTestSubject(); + testSubject.setIn_range(e); + } + + + @Test + public void testSetLength() throws Exception { + Constraint testSubject; + Object e = null; + + // default test + testSubject = createTestSubject(); + testSubject.setLength(e); + } + + + @Test + public void testSetMin_length() throws Exception { + Constraint testSubject; + Object e = null; + + // default test + testSubject = createTestSubject(); + testSubject.setMin_length(e); + } + + + @Test + public void testSetMax_length() throws Exception { + Constraint testSubject; + Object e = null; + + // default test + testSubject = createTestSubject(); + testSubject.setMax_length(e); + } + + + @Test + public void testToString() throws Exception { + Constraint testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.toString(); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/GroupTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/GroupTest.java new file mode 100644 index 000000000..3692a15b9 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/GroupTest.java @@ -0,0 +1,124 @@ +package org.onap.vid.asdc.beans.tosca; + +import java.util.Collection; +import java.util.Map; + +import org.junit.Test; + + +public class GroupTest { + + private Group createTestSubject() { + return new Group(); + } + + + @Test + public void testGetMetadata() throws Exception { + Group testSubject; + ToscaMetadata result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getMetadata(); + } + + + @Test + public void testSetMetadata() throws Exception { + Group testSubject; + ToscaMetadata metadata = null; + + // default test + testSubject = createTestSubject(); + testSubject.setMetadata(metadata); + } + + + @Test + public void testGetMembers() throws Exception { + Group testSubject; + Collection<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getMembers(); + } + + + @Test + public void testSetMembers() throws Exception { + Group testSubject; + Collection<String> members = null; + + // default test + testSubject = createTestSubject(); + testSubject.setMembers(members); + } + + + @Test + public void testGetType() throws Exception { + Group testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getType(); + } + + + @Test + public void testSetType() throws Exception { + Group testSubject; + String type = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setType(type); + } + + + @Test + public void testGetvf_module_type() throws Exception { + Group testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getvf_module_type(); + } + + + @Test + public void testSetvf_module_type() throws Exception { + Group testSubject; + String vf_module_type = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setvf_module_type(vf_module_type); + } + + + @Test + public void testGetProperties() throws Exception { + Group testSubject; + Map<String, Object> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getProperties(); + } + + + @Test + public void testSetProperties() throws Exception { + Group testSubject; + Map<String, Object> properties = null; + + // default test + testSubject = createTestSubject(); + testSubject.setProperties(properties); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/NodeTemplateTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/NodeTemplateTest.java new file mode 100644 index 000000000..678a5102d --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/NodeTemplateTest.java @@ -0,0 +1,92 @@ +package org.onap.vid.asdc.beans.tosca; + +import java.util.Map; + +import org.junit.Test; + +public class NodeTemplateTest { + + private NodeTemplate createTestSubject() { + return new NodeTemplate(); + } + + @Test + public void testGetType() throws Exception { + NodeTemplate testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getType(); + } + + @Test + public void testSetType() throws Exception { + NodeTemplate testSubject; + String type = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setType(type); + } + + @Test + public void testGetMetadata() throws Exception { + NodeTemplate testSubject; + ToscaMetadata result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getMetadata(); + } + + @Test + public void testSetMetadata() throws Exception { + NodeTemplate testSubject; + ToscaMetadata metadata = null; + + // default test + testSubject = createTestSubject(); + testSubject.setMetadata(metadata); + } + + @Test + public void testGetProperties() throws Exception { + NodeTemplate testSubject; + Map<String, Object> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getProperties(); + } + + @Test + public void testSetProperties() throws Exception { + NodeTemplate testSubject; + Map<String, Object> properties = null; + + // default test + testSubject = createTestSubject(); + testSubject.setProperties(properties); + } + + @Test + public void testGetRequirements() throws Exception { + NodeTemplate testSubject; + Object result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRequirements(); + } + + @Test + public void testSetRequirements() throws Exception { + NodeTemplate testSubject; + Object requirements = null; + + // default test + testSubject = createTestSubject(); + testSubject.setRequirements(requirements); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/TestSuite.java new file mode 100644 index 000000000..d94d33920 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/TestSuite.java @@ -0,0 +1,12 @@ +package org.onap.vid.asdc.beans.tosca; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ GroupTest.class, TopologyTemplateTest.class, ToscaModelTest.class, CapabilityTest.class, ToscaMetadataTest.class, + ConstraintTest.class, NodeTemplateTest.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/TopologyTemplateTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/TopologyTemplateTest.java new file mode 100644 index 000000000..8392d926c --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/TopologyTemplateTest.java @@ -0,0 +1,101 @@ +package org.onap.vid.asdc.beans.tosca; + +import java.util.Map; + +import org.junit.Test; + + +public class TopologyTemplateTest { + + private TopologyTemplate createTestSubject() { + return new TopologyTemplate(); + } + + + @Test + public void testGetsubstitution_mappings() throws Exception { + TopologyTemplate testSubject; + SubstitutionMappings result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getsubstitution_mappings(); + } + + + @Test + public void testSetsubstitution_mappings() throws Exception { + TopologyTemplate testSubject; + SubstitutionMappings substitution_mappings = null; + + // default test + testSubject = createTestSubject(); + testSubject.setsubstitution_mappings(substitution_mappings); + } + + + @Test + public void testGetInputs() throws Exception { + TopologyTemplate testSubject; + Map<String, Input> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getInputs(); + } + + + @Test + public void testSetInputs() throws Exception { + TopologyTemplate testSubject; + Map<String, Input> inputs = null; + + // default test + testSubject = createTestSubject(); + testSubject.setInputs(inputs); + } + + + @Test + public void testGetnode_templates() throws Exception { + TopologyTemplate testSubject; + Map<String, NodeTemplate> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getnode_templates(); + } + + + @Test + public void testSetnode_templates() throws Exception { + TopologyTemplate testSubject; + Map<String, NodeTemplate> node_templates = null; + + // default test + testSubject = createTestSubject(); + testSubject.setnode_templates(node_templates); + } + + + @Test + public void testGetGroups() throws Exception { + TopologyTemplate testSubject; + Map<String, Group> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getGroups(); + } + + + @Test + public void testSetGroups() throws Exception { + TopologyTemplate testSubject; + Map<String, Group> groups = null; + + // default test + testSubject = createTestSubject(); + testSubject.setGroups(groups); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/ToscaMetadataTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/ToscaMetadataTest.java new file mode 100644 index 000000000..2c91d9621 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/ToscaMetadataTest.java @@ -0,0 +1,443 @@ +package org.onap.vid.asdc.beans.tosca; + +import org.junit.Test; + +public class ToscaMetadataTest { + + private ToscaMetadata createTestSubject() { + return new ToscaMetadata(); + } + + @Test + public void testGetType() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getType(); + } + + @Test + public void testGetInvariantUUID() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getInvariantUUID(); + } + + @Test + public void testGetCustomizationUUID() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getCustomizationUUID(); + } + + @Test + public void testGetUUID() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getUUID(); + } + + @Test + public void testGetVersion() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVersion(); + } + + @Test + public void testGetName() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getName(); + } + + @Test + public void testGetDescription() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDescription(); + } + + @Test + public void testGetCategory() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getCategory(); + } + + @Test + public void testGetSubcategory() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getSubcategory(); + } + + @Test + public void testGetResourceVendor() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResourceVendor(); + } + + @Test + public void testGetResourceVendorRelease() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResourceVendorRelease(); + } + + @Test + public void testGetServiceEcompNaming() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getServiceEcompNaming(); + } + + @Test + public void testGetNamingPolicy() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getNamingPolicy(); + } + + @Test + public void testIsServiceHoming() throws Exception { + ToscaMetadata testSubject; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isServiceHoming(); + } + + @Test + public void testIsEcompGeneratedNaming() throws Exception { + ToscaMetadata testSubject; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isEcompGeneratedNaming(); + } + + @Test + public void testSetType() throws Exception { + ToscaMetadata testSubject; + String type = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setType(type); + } + + @Test + public void testSetInvariantUUID() throws Exception { + ToscaMetadata testSubject; + String invariantUUID = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setInvariantUUID(invariantUUID); + } + + @Test + public void testSetNamingPolicy() throws Exception { + ToscaMetadata testSubject; + String namingPolicy = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setNamingPolicy(namingPolicy); + } + + @Test + public void testSetUUID() throws Exception { + ToscaMetadata testSubject; + String uuid = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setUUID(uuid); + } + + @Test + public void testSetCustomizationUUID() throws Exception { + ToscaMetadata testSubject; + String u = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setCustomizationUUID(u); + } + + @Test + public void testSetVersion() throws Exception { + ToscaMetadata testSubject; + String version = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setVersion(version); + } + + @Test + public void testSetName() throws Exception { + ToscaMetadata testSubject; + String name = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setName(name); + } + + @Test + public void testSetDescription() throws Exception { + ToscaMetadata testSubject; + String description = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setDescription(description); + } + + @Test + public void testSetCategory() throws Exception { + ToscaMetadata testSubject; + String category = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setCategory(category); + } + + @Test + public void testSetServiceEcompNaming() throws Exception { + ToscaMetadata testSubject; + String serviceEcompNaming = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setServiceEcompNaming(serviceEcompNaming); + } + + @Test + public void testSetServiceHoming() throws Exception { + ToscaMetadata testSubject; + boolean serviceHoming = false; + + // default test + testSubject = createTestSubject(); + testSubject.setServiceHoming(serviceHoming); + } + + @Test + public void testSetEcompGeneratedNaming() throws Exception { + ToscaMetadata testSubject; + boolean ecompGeneratedNaming = false; + + // default test + testSubject = createTestSubject(); + testSubject.setEcompGeneratedNaming(ecompGeneratedNaming); + } + + @Test + public void testGettemplate_name() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.gettemplate_name(); + } + + @Test + public void testSettemplate_name() throws Exception { + ToscaMetadata testSubject; + String template_name = ""; + + // default test + testSubject = createTestSubject(); + testSubject.settemplate_name(template_name); + } + + + @Test + public void testSetSubcategory() throws Exception { + ToscaMetadata testSubject; + String subcategory = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setSubcategory(subcategory); + } + + + @Test + public void testSetResourceVendor() throws Exception { + ToscaMetadata testSubject; + String resourceVendor = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setResourceVendor(resourceVendor); + } + + + @Test + public void testSetResourceVendorRelease() throws Exception { + ToscaMetadata testSubject; + String resourceVendorRelease = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setResourceVendorRelease(resourceVendorRelease); + } + + + @Test + public void testGetVfModuleModelName() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVfModuleModelName(); + } + + + @Test + public void testSetVfModuleModelName() throws Exception { + ToscaMetadata testSubject; + String vfModuleModelName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setVfModuleModelName(vfModuleModelName); + } + + + @Test + public void testGetVfModuleModelInvariantUUID() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVfModuleModelInvariantUUID(); + } + + + @Test + public void testSetVfModuleModelInvariantUUID() throws Exception { + ToscaMetadata testSubject; + String vfModuleModelInvariantUUID = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setVfModuleModelInvariantUUID(vfModuleModelInvariantUUID); + } + + + @Test + public void testGetVfModuleModelUUID() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVfModuleModelUUID(); + } + + + @Test + public void testSetVfModuleModelUUID() throws Exception { + ToscaMetadata testSubject; + String vfModuleModelUUID = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setVfModuleModelUUID(vfModuleModelUUID); + } + + + @Test + public void testGetVfModuleModelVersion() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVfModuleModelVersion(); + } + + + @Test + public void testSetVfModuleModelVersion() throws Exception { + ToscaMetadata testSubject; + String vfModuleModelVersion = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setVfModuleModelVersion(vfModuleModelVersion); + } + + + @Test + public void testSetVfModuleModelCustomizationUUID() throws Exception { + ToscaMetadata testSubject; + String u = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setVfModuleModelCustomizationUUID(u); + } + + + @Test + public void testGetVfModuleModelCustomizationUUID() throws Exception { + ToscaMetadata testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVfModuleModelCustomizationUUID(); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/ToscaModelTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/ToscaModelTest.java new file mode 100644 index 000000000..ee5463744 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/ToscaModelTest.java @@ -0,0 +1,146 @@ +package org.onap.vid.asdc.beans.tosca; + +import java.util.Collection; +import java.util.Map; + +import org.junit.Test; + + +public class ToscaModelTest { + + private ToscaModel createTestSubject() { + return new ToscaModel(); + } + + + @Test + public void testGetMetadata() throws Exception { + ToscaModel testSubject; + ToscaMetadata result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getMetadata(); + } + + + @Test + public void testSetMetadata() throws Exception { + ToscaModel testSubject; + ToscaMetadata metadata = null; + + // default test + testSubject = createTestSubject(); + testSubject.setMetadata(metadata); + } + + + @Test + public void testGettosca_definitions_version() throws Exception { + ToscaModel testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.gettosca_definitions_version(); + } + + + @Test + public void testSettosca_definitions_version() throws Exception { + ToscaModel testSubject; + String tosca_definitions_version = ""; + + // default test + testSubject = createTestSubject(); + testSubject.settosca_definitions_version(tosca_definitions_version); + } + + + @Test + public void testGettopology_template() throws Exception { + ToscaModel testSubject; + TopologyTemplate result; + + // default test + testSubject = createTestSubject(); + result = testSubject.gettopology_template(); + } + + + @Test + public void testSettopology_template() throws Exception { + ToscaModel testSubject; + TopologyTemplate topology_template = null; + + // default test + testSubject = createTestSubject(); + testSubject.settopology_template(topology_template); + } + + + @Test + public void testGetDescription() throws Exception { + ToscaModel testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDescription(); + } + + + @Test + public void testSetDescription() throws Exception { + ToscaModel testSubject; + String description = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setDescription(description); + } + + + @Test + public void testGetImports() throws Exception { + ToscaModel testSubject; + Collection<Map<String, Map<String, String>>> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getImports(); + } + + + @Test + public void testSetImports() throws Exception { + ToscaModel testSubject; + Collection<Map<String, Map<String, String>>> imports = null; + + // default test + testSubject = createTestSubject(); + testSubject.setImports(imports); + } + + + @Test + public void testGetnode_types() throws Exception { + ToscaModel testSubject; + Map<String, Object> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getnode_types(); + } + + + @Test + public void testSetnode_types() throws Exception { + ToscaModel testSubject; + Map<String, Object> node_types = null; + + // default test + testSubject = createTestSubject(); + testSubject.setnode_types(node_types); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java new file mode 100644 index 000000000..99f8ef38a --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java @@ -0,0 +1,154 @@ +package org.onap.vid.asdc.parser; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.google.common.collect.ImmutableList; +import org.apache.log4j.Logger; +import org.junit.Assert; +import org.onap.vid.controller.WebConfig; +import org.onap.vid.model.VfModule; +import org.onap.vid.model.VolumeGroup; +import org.onap.vid.properties.AsdcClientConfiguration; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; +import org.openecomp.sdc.toscaparser.api.Group; +import org.openecomp.sdc.toscaparser.api.NodeTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.web.context.WebApplicationContext; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Map; + +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.*; + +@Test +@ContextConfiguration(classes = { WebConfig.class, AsdcClientConfiguration.class, SystemProperties.class }) +@WebAppConfiguration +public class ToscaParserImpl2Test extends AbstractTestNGSpringContextTests { + + private final String myUUID = "myUUID"; + private static final Logger log = Logger.getLogger(ToscaParserImpl2Test.class); + + @Autowired + private ToscaParserImpl2 toscaParserImpl2; + + @Autowired + private WebApplicationContext wac; + + @BeforeMethod + private void verifyWiring() { + Assert.assertNotNull(wac); + Assert.assertNotNull(toscaParserImpl2); + } + + @Test + public void testGetNFModuleFromVf() throws Exception { + ISdcCsarHelper csarHelper = getMockedSdcCsarHelper(); + + Map<String, VfModule> vfModulesFromVF = toscaParserImpl2.getVfModulesFromVF(csarHelper, myUUID); + + assertThat(vfModulesFromVF, allOf( + aMapWithSize(2), + hasKey("withoutVol"), + hasKey("withVol") + )); + + verify(csarHelper, only()).getVfModulesByVf(anyString()); + } + + @Test + public void testGetVolumeGroupsFromVF() throws Exception { + ISdcCsarHelper csarHelper = getMockedSdcCsarHelper(); + + Map<String, VolumeGroup> volumeGroupsFromVF = toscaParserImpl2.getVolumeGroupsFromVF(csarHelper, myUUID); + + assertThat(volumeGroupsFromVF, allOf( + aMapWithSize(1), + hasKey("withVol") + )); + + verify(csarHelper, only()).getVfModulesByVf(anyString()); + } + + private ISdcCsarHelper getMockedSdcCsarHelper() { + ISdcCsarHelper csarHelper = mock(ISdcCsarHelper.class); + +// ThreadLocalsHolder.setCollector(new ExceptionCollector("c:\\temp\\foo")); + + Group withVol = createMinimalGroup("withVol", true); + Group withoutVol = createMinimalGroup("withoutVol", false); + + when(csarHelper.getVfModulesByVf(myUUID)) + .thenReturn(ImmutableList.of(withVol, withoutVol)); + + return csarHelper; + } + + private static Group createMinimalGroup(String name, boolean isVolumeGroup) { + LinkedHashMap<String, Object> + templates, + properties, + metadata, + customDef, + vfModule, + vfModuleProperties, + volumeGroup; + + templates = new LinkedHashMap<>(); + templates.put("type", "org.onap.groups.VfModule"); + + properties = addNewNamedMap(templates, "properties"); + properties.put("volume_group", isVolumeGroup); + + metadata = addNewNamedMap(templates, "metadata"); + + ArrayList<NodeTemplate> memberNodes = new ArrayList<>(); + + customDef = new LinkedHashMap<>(); + vfModule = addNewNamedMap(customDef, "org.onap.groups.VfModule"); + vfModuleProperties = addNewNamedMap(vfModule, "properties"); +// vfModule.put("derived_from", "tosca.groups.Root"); +// vfModule.put("description", "Grouped all heat resources which are in the same VF Module"); + + volumeGroup = addNewNamedMap(vfModuleProperties, "volume_group"); +// volumeGroup.put("description", "volume_group"); + volumeGroup.put("type", "boolean"); + volumeGroup.put("default", false); + volumeGroup.put("required", true); + + + Group group = new Group( + name, + templates, + memberNodes, + customDef + ); + + try { + log.info(String.format("Built a group: %s", + (new com.fasterxml.jackson.databind.ObjectMapper()) + .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false) + .writeValueAsString(group) + )); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + + return group; + } + + private static LinkedHashMap<String, Object> addNewNamedMap(LinkedHashMap<String, Object> root, String key) { + LinkedHashMap<String, Object> properties = new LinkedHashMap<>(); + root.put(key, properties); + return properties; + } + +} diff --git a/vid-app-common/src/test/java/org/onap/vid/bl/AaiServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/bl/AaiServiceTest.java new file mode 100644 index 000000000..b64f5e50e --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/bl/AaiServiceTest.java @@ -0,0 +1,143 @@ +package org.onap.vid.bl; + +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.vid.aai.AaiClientInterface; +import org.onap.vid.aai.AaiResponse; +import org.onap.vid.aai.model.*; +import org.onap.vid.aai.model.AaiGetPnfs.Pnf; +import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse; +import org.onap.vid.roles.Role; +import org.onap.vid.roles.RoleValidator; +import org.onap.vid.services.AaiServiceImpl; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.hamcrest.Matchers.arrayWithSize; +import static org.hamcrest.Matchers.equalTo; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.hamcrest.MatcherAssert.assertThat; + +public class AaiServiceTest { + + @InjectMocks + private AaiServiceImpl aaiService; + + @Mock + private AaiClientInterface aaiClientInterface; + + + + @BeforeMethod + public void initMocks(){ + MockitoAnnotations.initMocks(this); + } + + @Test + public void testGetSpecificPnf(){ + Pnf pnf = new Pnf(); + pnf.setPnfId("11111"); + AaiResponse<Pnf> aaiResponse = new AaiResponse<>(pnf, "aaaa", 200); + Mockito.doReturn(aaiResponse).when(aaiClientInterface).getSpecificPnf(Mockito.anyString()); + AaiResponse<Pnf> specificPnf = aaiService.getSpecificPnf("1345667"); + assertNotNull(specificPnf); + pnf = specificPnf.getT(); + assertNotNull(pnf); + assertEquals("11111",pnf.getPnfId()); + assertEquals("aaaa",specificPnf.getErrorMessage()); + assertEquals(200,specificPnf.getHttpCode()); + } + + @Test + public void testGetAssociatedPnfs(){ + ServiceRelationships serviceRelationships = createServiceRelationships(); + AaiResponse<ServiceRelationships> aaiResponse = new AaiResponse<>(serviceRelationships, null, 200); + Mockito.doReturn(aaiResponse).when(aaiClientInterface).getServiceInstance(Mockito.anyString(), Mockito.anyString(), Mockito.anyString()); + + LogicalLinkResponse logicalLinkResponse = createLogicalLinkResponse(); + AaiResponse<LogicalLinkResponse> aaiResponse1 = new AaiResponse<>(logicalLinkResponse, null, 200); + Mockito.doReturn(aaiResponse1).when(aaiClientInterface).getLogicalLink("SANITY6758cce9%3ALAG1992%7CSANITY6785cce9%3ALAG1961"); + + List<String> pnfList = aaiService.getServiceInstanceAssociatedPnfs("123", "456", "789"); + assertNotNull(pnfList); + assertEquals(1, pnfList.size()); + assertEquals("SANITY6785cce9", pnfList.get(0)); + } + + private ServiceRelationships createServiceRelationships() { + ServiceRelationships serviceRelationships = new ServiceRelationships(); + serviceRelationships.setServiceInstanceName("test service"); + + RelationshipData logicalLinksRelationshipData = new RelationshipData(); + logicalLinksRelationshipData.setRelationshipKey("logical-link.link-name"); + logicalLinksRelationshipData.setRelationshipValue("SANITY6758cce9:LAG1992|SANITY6785cce9:LAG1961"); + + Relationship logicalLinksRelationship = new Relationship(); + logicalLinksRelationship.setRelatedTo("logical-link"); + logicalLinksRelationship.setRelationDataList(Arrays.asList(logicalLinksRelationshipData)); + + RelationshipList logicalLinksRelationshipsList = new RelationshipList(); + logicalLinksRelationshipsList.setRelationship(Arrays.asList(logicalLinksRelationship)); + + serviceRelationships.setRelationshipList(logicalLinksRelationshipsList); + return serviceRelationships; + } + + private LogicalLinkResponse createLogicalLinkResponse() { + LogicalLinkResponse logicalLinkResponse = new LogicalLinkResponse(); + logicalLinkResponse.setLinkName("SANITY6758cce9:LAG1992|SANITY6785cce9:LAG1961"); + + RelationshipData lagInterfaceRelationshipData = new RelationshipData(); + lagInterfaceRelationshipData.setRelationshipKey("pnf.pnf-name"); + lagInterfaceRelationshipData.setRelationshipValue("SANITY6785cce9"); + + Relationship lagInterfaceRelationship = new Relationship(); + lagInterfaceRelationship.setRelatedTo("lag-interface"); + lagInterfaceRelationship.setRelationDataList(Arrays.asList(lagInterfaceRelationshipData)); + + RelationshipList lagInterfaceRelationshipsList = new RelationshipList(); + lagInterfaceRelationshipsList.setRelationship(Arrays.asList(lagInterfaceRelationship)); + + logicalLinkResponse.setRelationshipList(lagInterfaceRelationshipsList); + + return logicalLinkResponse; + } + + @DataProvider + public static Object[][] getTenantsData() { + return new Object[][] { + {"customer1", "serviceType1", "tenant1", "customer1", "serviceType1", "tenant1", "id-1", true}, + {"customer1", "serviceType1", "TeNant1", "customer1", "serviceType1", "tenant1", "id-1", true}, + {"customer1", "serviceType1", "TENANT1", "customer1", "serviceType1", "tenant1", "id-1", true}, + {"customer1", "serviceType1", "tenant2", "customer1", "serviceType1", "tenant1", "tenant2", false}, + {"customer1", "serviceType1", null, "customer1", "serviceType1", "tenant1", "tenant2", true}, + {"customer2", "serviceType1", "tenant1", "customer1", "serviceType1", "tenant1", "id-1", false}, + {"customer1", "serviceType2", "tenant1", "customer1", "serviceType1", "tenant1", "id-1", false}, + {"customer2", "serviceType1", null, "customer1", "serviceType1", "tenant1", "id-1", false}, + {"customer1", "serviceType2", null, "customer1", "serviceType1", "tenant1", "id-1", false}, + }; + } + + @Test(dataProvider = "getTenantsData") + public void testGetTenants(String userGlobalCustomerId, String userServiceType, String userTenantName, String serviceGlobalCustomerId, + String serviceServiceType, String serviceTenantName, String serviceTenantId, boolean expectedIsPermitted) { + GetTenantsResponse[] getTenantsResponses = new GetTenantsResponse[] {new GetTenantsResponse(null, serviceTenantName, serviceTenantId, false)}; + AaiResponse<GetTenantsResponse[]> aaiResponse = new AaiResponse<>(getTenantsResponses, null, 200); + Mockito.doReturn(aaiResponse).when(aaiClientInterface).getTenants(serviceGlobalCustomerId, serviceServiceType); + Role role = new Role(null, userGlobalCustomerId, userServiceType, userTenantName); + RoleValidator roleValidator = new RoleValidator(Collections.singletonList(role)); + AaiResponse<GetTenantsResponse[]> actualTenants = aaiService.getTenants(serviceGlobalCustomerId, serviceServiceType, roleValidator); + + assertThat(actualTenants.getT(), arrayWithSize(1)); + assertThat(actualTenants.getT()[0].tenantName, equalTo(serviceTenantName)); + assertThat(actualTenants.getT()[0].isPermitted, equalTo(expectedIsPermitted)); + } +} diff --git a/vid-app-common/src/test/java/org/onap/vid/client/FakeHttpSessionTest.java b/vid-app-common/src/test/java/org/onap/vid/client/FakeHttpSessionTest.java new file mode 100644 index 000000000..74cfbcfc7 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/client/FakeHttpSessionTest.java @@ -0,0 +1,206 @@ +package org.onap.vid.client; + +import java.util.Enumeration; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpSessionContext; + +import org.junit.Test; + + +public class FakeHttpSessionTest { + + private FakeHttpSession createTestSubject() { + return new FakeHttpSession(); + } + + + @Test + public void testGetCreationTime() throws Exception { + FakeHttpSession testSubject; + long result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getCreationTime(); + } + + + @Test + public void testGetId() throws Exception { + FakeHttpSession testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getId(); + } + + + @Test + public void testGetLastAccessedTime() throws Exception { + FakeHttpSession testSubject; + long result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getLastAccessedTime(); + } + + + @Test + public void testGetServletContext() throws Exception { + FakeHttpSession testSubject; + ServletContext result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getServletContext(); + } + + + @Test + public void testSetMaxInactiveInterval() throws Exception { + FakeHttpSession testSubject; + int maxInactiveInterval = 0; + + // default test + testSubject = createTestSubject(); + testSubject.setMaxInactiveInterval(maxInactiveInterval); + } + + + @Test + public void testGetMaxInactiveInterval() throws Exception { + FakeHttpSession testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getMaxInactiveInterval(); + } + + + @Test + public void testGetSessionContext() throws Exception { + FakeHttpSession testSubject; + HttpSessionContext result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getSessionContext(); + } + + + @Test + public void testGetAttribute() throws Exception { + FakeHttpSession testSubject; + String name = ""; + Object result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAttribute(name); + } + + + @Test + public void testGetValue() throws Exception { + FakeHttpSession testSubject; + String name = ""; + Object result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getValue(name); + } + + + @Test + public void testGetAttributeNames() throws Exception { + FakeHttpSession testSubject; + Enumeration<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAttributeNames(); + } + + + @Test + public void testGetValueNames() throws Exception { + FakeHttpSession testSubject; + String[] result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getValueNames(); + } + + + @Test + public void testSetAttribute() throws Exception { + FakeHttpSession testSubject; + String name = ""; + Object value = null; + + // default test + testSubject = createTestSubject(); + testSubject.setAttribute(name, value); + } + + + @Test + public void testPutValue() throws Exception { + FakeHttpSession testSubject; + String name = ""; + Object value = null; + + // default test + testSubject = createTestSubject(); + testSubject.putValue(name, value); + } + + + @Test + public void testRemoveAttribute() throws Exception { + FakeHttpSession testSubject; + String name = ""; + + // default test + testSubject = createTestSubject(); + testSubject.removeAttribute(name); + } + + + @Test + public void testRemoveValue() throws Exception { + FakeHttpSession testSubject; + String name = ""; + + // default test + testSubject = createTestSubject(); + testSubject.removeValue(name); + } + + + @Test + public void testInvalidate() throws Exception { + FakeHttpSession testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.invalidate(); + } + + + @Test + public void testIsNew() throws Exception { + FakeHttpSession testSubject; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isNew(); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/client/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/client/TestSuite.java new file mode 100644 index 000000000..434dd5cc0 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/client/TestSuite.java @@ -0,0 +1,11 @@ +package org.onap.vid.client; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ FakeHttpSessionTest.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java new file mode 100644 index 000000000..548c48043 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java @@ -0,0 +1,51 @@ +package org.onap.vid.controller; + +import javax.servlet.http.HttpServletRequest; + +import org.json.simple.JSONObject; +import org.junit.Test; +import org.springframework.http.ResponseEntity; +import org.springframework.web.servlet.ModelAndView; + +public class AaiControllerTest { + + private AaiController createTestSubject() { + return new AaiController(); + } + + @Test + public void testWelcome() throws Exception { + AaiController testSubject; + HttpServletRequest request = null; + ModelAndView result; + + // default test + testSubject = createTestSubject(); + result = testSubject.welcome(request); + } + + + @Test + public void testGetTargetProvStatus() throws Exception { + AaiController testSubject; + ResponseEntity<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getTargetProvStatus(); + } + + @Test + public void testViewEditGetTenantsFromServiceType() throws Exception { + AaiController testSubject; + HttpServletRequest request = null; + String globalCustomerId = ""; + String serviceType = ""; + ResponseEntity<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.viewEditGetTenantsFromServiceType(request, globalCustomerId, serviceType); + } + +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/HealthCheckControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/HealthCheckControllerTest.java new file mode 100644 index 000000000..ddbe4e888 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/controller/HealthCheckControllerTest.java @@ -0,0 +1,47 @@ +package org.onap.vid.controller; + +import org.junit.Test; +import org.onap.vid.controller.HealthCheckController.HealthStatus; + +public class HealthCheckControllerTest { + + private HealthCheckController createTestSubject() { + return new HealthCheckController(); + } + + @Test + public void testGetProfileCount() throws Exception { + HealthCheckController testSubject; + String driver = ""; + String URL = ""; + String username = ""; + String password = ""; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getProfileCount(driver, URL, username, password); + } + + @Test + public void testGethealthCheckStatusforIDNS() throws Exception { + HealthCheckController testSubject; + HealthStatus result; + + // default test + testSubject = createTestSubject(); + result = testSubject.gethealthCheckStatusforIDNS(); + } + + @Test + public void testGetHealthCheck() throws Exception { + HealthCheckController testSubject; + String UserAgent = ""; + String ECOMPRequestID = ""; + HealthStatus result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getHealthCheck(UserAgent, ECOMPRequestID); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java b/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java new file mode 100644 index 000000000..9b6a3e7b4 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java @@ -0,0 +1,70 @@ +package org.onap.vid.controller; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.io.IOUtils; +import org.json.JSONObject; +import org.json.JSONTokener; +import org.onap.vid.aai.AaiClient; +import org.onap.vid.aai.AaiClientInterface; +import org.onap.vid.asdc.AsdcClient; +import org.onap.vid.asdc.local.LocalAsdcClient; +import org.onap.vid.asdc.parser.ToscaParserImpl2; +import org.onap.vid.controller.VidController; +import org.onap.vid.services.AaiService; +import org.onap.vid.services.AaiServiceImpl; +import org.onap.vid.services.VidService; +import org.onap.vid.services.VidServiceImpl; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.io.IOException; +import java.io.InputStream; + +@Configuration +public class LocalWebConfig { + + /** + * Gets the object mapper. + * + * @return the object mapper + */ + @Bean + public ObjectMapper getObjectMapper() { + return new ObjectMapper(); + } + + + @Bean + public VidService vidService(AsdcClient asdcClient) { + return new VidServiceImpl(asdcClient); + } + + @Bean + public AaiService getAaiService() { + return new AaiServiceImpl(); + } + + @Bean + public AaiClientInterface getAaiClientInterface() { + return new AaiClient(); + } + + @Bean + public AsdcClient asdcClient() throws IOException { + + + final InputStream asdcServicesFile = VidController.class.getClassLoader().getResourceAsStream("sdcservices.json"); + + final JSONTokener jsonTokener = new JSONTokener(IOUtils.toString(asdcServicesFile)); + final JSONObject sdcServicesCatalog = new JSONObject(jsonTokener); + + return new LocalAsdcClient.Builder().catalog(sdcServicesCatalog).build(); + + } + + @Bean + public ToscaParserImpl2 getToscaParser() { + return new ToscaParserImpl2(); + } + +} diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java new file mode 100644 index 000000000..6ca6a9f01 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java @@ -0,0 +1,109 @@ +package org.onap.vid.controller; + +import org.apache.commons.lang.StringEscapeUtils; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.onap.vid.controller.MsoConfig; +import org.onap.vid.controller.MsoController; +import org.onap.vid.domain.mso.RequestInfo; +import org.onap.vid.factories.MsoRequestFactory; +import org.onap.vid.mso.rest.Request; +import org.onap.vid.mso.rest.RequestDetails; +import org.onap.vid.mso.rest.Task; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.springframework.test.context.web.WebAppConfiguration; +import org.testng.Assert; +import org.testng.Assert.*; +import org.testng.annotations.Test; + +import java.util.List; + + +@WebAppConfiguration +@ContextConfiguration(classes = {SystemProperties.class, MsoConfig.class}) +public class MsoControllerTest extends AbstractTestNGSpringContextTests { + + @Autowired + MsoRequestFactory msoRequestFactory; + + @Test(enabled = false) + public void testInstanceCreationNew() throws Exception { + + RequestDetails requestDetails = msoRequestFactory.createMsoRequest("msoRequest.json"); + MsoController msoController = new MsoController(null); + //TODO: make ths test to really test something + //ResponseEntity<String> responseEntityNew = msoController.createSvcInstanceNew(null, requestDetails); + ResponseEntity<String> responseEntity = msoController.createSvcInstance(null, requestDetails); + //Assert.assertEquals(responseEntityNew, responseEntity); + + } + + @Test(enabled = false) + public void testInstanceCreationLocalWithRest() throws Exception { + + RequestDetails requestDetails = msoRequestFactory.createMsoRequest("msoRequest.json"); + MsoController msoController = new MsoController(null); + ResponseEntity<String> responseEntityNew = msoController.createSvcInstance(null, requestDetails); + //TODO: make ths test to really test something +// ResponseEntity<String> responseEntityRest = msoController.createSvcInstanceNewRest(null, requestDetails); +// +// Assert.assertEquals(responseEntityNew.getBody(), responseEntityRest.getBody()); + + } + + @Test(enabled = false) + public void testInstanceCreation() throws Exception { + + RequestDetails requestDetails = msoRequestFactory.createMsoRequest("msoRequest.json"); + MsoController msoController = new MsoController(null); + ResponseEntity<String> responseEntity = msoController.createSvcInstance(null, requestDetails); + + + Assert.assertEquals(responseEntity.getBody(), "{ \"status\": 200, \"entity\": {\n" + + " \"requestReferences\": {\n" + + " \"instanceId\": \"ba00de9b-3c3e-4b0a-a1ad-0c5489e711fb\",\n" + + " \"requestId\": \"311cc766-b673-4a50-b9c5-471f68914586\"\n" + + " }\n" + + "}}"); + + } + + @Test(enabled = false) + public void testGetOrchestrationRequestsForDashboard() throws Exception { + MsoController msoController = new MsoController(null); + List<Request> orchestrationRequestsForDashboard = msoController.getOrchestrationRequestsForDashboard(); + + Assert.assertEquals(orchestrationRequestsForDashboard.size(), 2); + } + + @Test(enabled = false) + public void testGetManualTasksByRequestId() throws Exception { + MsoController msoController = new MsoController(null); + List<Task> orchestrationRequestsForDashboard = msoController.getManualTasksByRequestId("za1234d1-5a33-55df-13ab-12abad84e335"); + + Assert. assertEquals(orchestrationRequestsForDashboard.get(0).getTaskId(), "daf4dd84-b77a-42da-a051-3239b7a9392c"); + } + + + public void testCompleteManualTask() throws Exception { // TODO not done yet + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setResponseValue("rollback"); + requestInfo.setRequestorId("abc"); + requestInfo.setSource("VID"); + RequestDetails requestDetails = new RequestDetails(); + requestDetails.setRequestInfo(requestInfo); + MsoController msoController = new MsoController(null); + ResponseEntity<String> responseEntity = msoController.manualTaskComplete("daf4dd84-b77a-42da-a051-3239b7a9392c", requestDetails); + String assertString = "{ \\\"status\\\": 200, \\\"entity\\\": {\\n\" +\n" + + " \" \\\"taskRequestReference\\\": {\\n\" +\n" + + " \" \\\"taskId\\\": \\\"daf4dd84-b77a-42da-a051-3239b7a9392c\\\"\\n\" +\n" + + " \" }\\n\" +\n" + + " \"}\\n\" +\n" + + " \"}"; + Assert.assertEquals(responseEntity.getBody(), StringEscapeUtils.unescapeJava(assertString)); + } + + +} diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/PromiseEcompRequestIdFilterTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/PromiseEcompRequestIdFilterTest.java new file mode 100644 index 000000000..245d8bbd5 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/controller/PromiseEcompRequestIdFilterTest.java @@ -0,0 +1,168 @@ +package org.onap.vid.controller; + +import com.google.common.collect.ImmutableMap; +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; +import org.mockito.stubbing.Answer; +import org.openecomp.portalsdk.core.web.support.UserUtils; +import org.onap.vid.controller.filter.PromiseEcompRequestIdFilter; +import org.springframework.mock.web.MockHttpServletResponse; +import org.testng.annotations.Test; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.*; +import java.util.function.Function; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.argThat; +import static org.openecomp.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID; + +@Test +public class PromiseEcompRequestIdFilterTest { + + private final String anotherHeader = "ANDREI_RUBLEV"; + private final String anotherValue = "foo value"; + private final String mixedCaseHeader = "x-ecomp-REQUESTID"; + + @Test + public void givenRequestIdHeader_headerValueNotChanged() throws IOException, ServletException { + + final String someTxId = "863850e2-8545-4efd-94b8-afba5f52b3d5"; + + final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of( + anotherHeader, anotherValue, + ECOMP_REQUEST_ID, someTxId + ); + + buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, specificTxId(someTxId)); + } + + @Test + public void givenMixedCaseRequestIdHeader_headerValueNotChanged() throws IOException, ServletException { + + final String someTxId = "729bbd8d-b0c2-4809-a794-dcccd9cda2c0"; + + final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of( + mixedCaseHeader, someTxId, + anotherHeader, anotherValue + ); + + buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, specificTxId(someTxId)); + } + + @Test + public void givenNoRequestIdHeader_headerValueWasGenerated() throws IOException, ServletException { + + final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of( + anotherHeader, anotherValue + ); + + buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, UserUtils::getRequestId); + } + + + private void buildRequestThenRunThroughFilterAndAssertResultRequestHeaders( + ImmutableMap<String, String> originalRequestHeaders, + Function<HttpServletRequest, String> txIdExtractor + ) throws IOException, ServletException { + HttpServletRequest servletRequest = createMockedHttpServletRequest(originalRequestHeaders); + HttpServletResponse servletResponse = createMockedHttpServletResponse(); + + final FilterChain capturingFilterChain = Mockito.mock(FilterChain.class); + + ////////////////// + // + // doFilter() is the function under test + // + new PromiseEcompRequestIdFilter().doFilter(servletRequest, servletResponse, capturingFilterChain); + // + ////////////////// + + final ServletRequest capturedServletRequest = extractCapturedServletRequest(capturingFilterChain); + final ServletResponse capturedServletResponse = extractCapturedServletResponse(capturingFilterChain); + final String expectedTxId = txIdExtractor.apply((HttpServletRequest) capturedServletRequest); + + assertRequestObjectHeaders(capturedServletRequest, expectedTxId); + assertResponseObjectHeaders(capturedServletResponse, expectedTxId); + } + + + private void assertRequestObjectHeaders(ServletRequest request, String expectedTxId) { + /* + Assert that: + - Two headers are in place + - Direct value extraction is as expected + - UserUtils.getRequestId() returns correct and valid value + */ + final HttpServletRequest httpServletRequest = (HttpServletRequest) request; + + assertThat(Collections.list(httpServletRequest.getHeaderNames()), + containsInAnyOrder(equalToIgnoringCase(ECOMP_REQUEST_ID), equalToIgnoringCase(anotherHeader))); + + assertThat(httpServletRequest.getHeader(anotherHeader), is(anotherValue)); + + assertThat(httpServletRequest.getHeader(ECOMP_REQUEST_ID), is(expectedTxId)); + assertThat(httpServletRequest.getHeader(mixedCaseHeader), is(expectedTxId)); + + assertThat(UserUtils.getRequestId(httpServletRequest), is(expectedTxId)); + assertThat(UserUtils.getRequestId(httpServletRequest), is(not(emptyOrNullString()))); + } + + private void assertResponseObjectHeaders(ServletResponse response, String txId) { + final String REQUEST_ID_HEADER_NAME_IN_RESPONSE = mixedCaseHeader + "-echo"; + final HttpServletResponse httpServletResponse = (HttpServletResponse) response; + + assertThat("header " + REQUEST_ID_HEADER_NAME_IN_RESPONSE.toLowerCase() + " in response must be provided", + httpServletResponse.getHeader(REQUEST_ID_HEADER_NAME_IN_RESPONSE), is(txId)); + } + + + + private HttpServletRequest createMockedHttpServletRequest(Map<String, String> requestHeaders) { + HttpServletRequest servletRequest = Mockito.mock(HttpServletRequest.class); + requestHeaders.forEach((k, v) -> { + Mockito.when(servletRequest.getHeader(argThat(equalToIgnoringCase(k)))).thenReturn(v); + Mockito.when(servletRequest.getHeaders(argThat(equalToIgnoringCase(k)))).then(returnEnumerationAnswer(v)); + }); + Mockito.when(servletRequest.getHeaderNames()).then(returnEnumerationAnswer(requestHeaders.keySet())); + return servletRequest; + } + + private HttpServletResponse createMockedHttpServletResponse() { + return new MockHttpServletResponse(); + } + + private static Answer<Enumeration<String>> returnEnumerationAnswer(String ... items) { + return returnEnumerationAnswer(Arrays.asList(items)); + } + + private static Answer<Enumeration<String>> returnEnumerationAnswer(Collection<String> items) { + return invocation -> Collections.enumeration(items); + } + + private Function<HttpServletRequest, String> specificTxId(String someTxId) { + return r -> someTxId; + } + + private ServletRequest extractCapturedServletRequest(FilterChain capturingFilterChain) throws IOException, ServletException { + ArgumentCaptor<ServletRequest> captor = ArgumentCaptor.forClass(ServletRequest.class); + Mockito.verify(capturingFilterChain).doFilter(captor.capture(), any()); + return captor.getValue(); + } + + private ServletResponse extractCapturedServletResponse(FilterChain capturingFilterChain) throws IOException, ServletException { + ArgumentCaptor<ServletResponse> captor = ArgumentCaptor.forClass(ServletResponse.class); + Mockito.verify(capturingFilterChain).doFilter(any(), captor.capture()); + return captor.getValue(); + } + +} diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/PropertyControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/PropertyControllerTest.java new file mode 100644 index 000000000..e9c2e61be --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/controller/PropertyControllerTest.java @@ -0,0 +1,39 @@ +package org.onap.vid.controller; + +import javax.servlet.http.HttpServletRequest; + +import org.junit.Test; +import org.springframework.http.ResponseEntity; +import org.springframework.web.servlet.ModelAndView; + +public class PropertyControllerTest { + + private PropertyController createTestSubject() { + return new PropertyController(); + } + + @Test + public void testWelcome() throws Exception { + PropertyController testSubject; + HttpServletRequest request = null; + ModelAndView result; + + // default test + testSubject = createTestSubject(); + result = testSubject.welcome(request); + } + + + @Test + public void testGetProperty() throws Exception { + PropertyController testSubject; + String name = ""; + String defaultvalue = ""; + HttpServletRequest request = null; + ResponseEntity<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getProperty(name, defaultvalue, request); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/ToscaParserMockHelper.java b/vid-app-common/src/test/java/org/onap/vid/controller/ToscaParserMockHelper.java new file mode 100644 index 000000000..36a179109 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/controller/ToscaParserMockHelper.java @@ -0,0 +1,42 @@ +package org.onap.vid.controller; + +import org.onap.vid.model.NewServiceModel; + +/** + * Created by moriya1 on 04/07/2017. + */ +public class ToscaParserMockHelper { + + private String uuid; + private String filePath; + private NewServiceModel newServiceModel; + + public ToscaParserMockHelper(String uuid, String filePath) { + this.uuid = uuid; + this.filePath = filePath; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public NewServiceModel getNewServiceModel() { + return newServiceModel; + } + + public void setNewServiceModel(NewServiceModel newServiceModel) { + this.newServiceModel = newServiceModel; + } +} diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/VidControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/VidControllerTest.java new file mode 100644 index 000000000..b443e1f05 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/controller/VidControllerTest.java @@ -0,0 +1,187 @@ +package org.onap.vid.controller; + +import com.fasterxml.jackson.databind.ObjectMapper; +import net.javacrumbs.jsonunit.JsonAssert; +import org.apache.commons.io.IOUtils; +import org.onap.vid.asdc.AsdcCatalogException; +import org.onap.vid.asdc.AsdcClient; +import org.onap.vid.asdc.parser.ToscaParserImpl2; +import org.onap.vid.model.*; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.mock.web.MockServletContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.springframework.test.context.web.WebAppConfiguration; +import org.testng.Assert; +import org.testng.annotations.Test; + +import static org.onap.vid.testUtils.TestUtils.assertJsonStringEqualsIgnoreNulls; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Path; +import java.util.Map; +import java.util.UUID; + +//import org.junit.Assert; +//import org.junit.Ignore; +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@ContextConfiguration(classes = {LocalWebConfig.class, SystemProperties.class}) +//@RunWith(SpringJUnit4ClassRunner.class) +@WebAppConfiguration + +public class VidControllerTest extends AbstractTestNGSpringContextTests { + + @Autowired + MockServletContext context; + @Autowired + private AsdcClient asdcClient; + private ToscaParserImpl2 p2 = new ToscaParserImpl2(); + private ObjectMapper om = new ObjectMapper(); + + + @Test + public void assertEqualsBetweenServices() throws Exception { + for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { + Service expectedService = mockHelper.getNewServiceModel().getService(); + Service actualService = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getService(); + assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(expectedService), om.writeValueAsString(actualService)); + } + } + +// @Test +// public void assertEqualBetweenObjects() throws Exception { +// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { +// final Path csarPath = getCsarPath(mockHelper.getUuid()); +// System.out.println("Comparing for csar " + csarPath); +// ServiceModel actualServiceModel = p2.makeServiceModel(csarPath, getServiceByUuid(mockHelper.getUuid())); +// assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(mockHelper.getNewServiceModel()), om.writeValueAsString(actualServiceModel)); +// } +// } + +// @Test +// public void assertEqualsBetweenNetworkNodes() throws Exception { +// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { +// Map<String, Network> expectedNetworksMap = mockHelper.getNewServiceModel().getNetworks(); +// Map<String, Network> actualNetworksMap = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getNetworks(); +// for (Map.Entry<String, Network> entry : expectedNetworksMap.entrySet()) { +// Network expectedNetwork = entry.getValue(); +// Network actualNetwork = actualNetworksMap.get(entry.getKey()); +// Assert.assertEquals(expectedNetwork.getModelCustomizationName(), actualNetwork.getModelCustomizationName()); +// verifyBaseNodeProperties(expectedNetwork, actualNetwork); +// compareProperties(expectedNetwork.getProperties(), actualNetwork.getProperties()); +// } +// } +// } + + //Because we are not supporting the old flow, the JSON are different by definition. + @Test + public void assertEqualsBetweenVnfsOfTosca() throws Exception { + for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { + Map<String, VNF> expectedVnfsMap = mockHelper.getNewServiceModel().getVnfs(); + Map<String, VNF> actualVnfsMap = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getVnfs(); + for (Map.Entry<String, VNF> entry : expectedVnfsMap.entrySet()) { + VNF expectedVnf = entry.getValue(); + VNF actualVnf = actualVnfsMap.get(entry.getKey()); + verifyBaseNodeProperties(expectedVnf, actualVnf); + Assert.assertEquals(expectedVnf.getModelCustomizationName(), actualVnf.getModelCustomizationName()); + compareProperties(expectedVnf.getProperties(), actualVnf.getProperties()); + assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(expectedVnf), om.writeValueAsString(actualVnf)); + } + } + } + + @Test + public void assertEqualsBetweenVolumeGroups() throws Exception { + for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { + Map<String, VolumeGroup> actualVolumeGroups = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getVolumeGroups(); + Map<String, VolumeGroup> expectedVolumeGroups = mockHelper.getNewServiceModel().getVolumeGroups(); + JsonAssert.assertJsonEquals(actualVolumeGroups, expectedVolumeGroups); + } + } + + @Test + public void assertEqualsBetweenVfModules() throws Exception { + for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { + Map<String, VfModule> actualVfModules = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getVfModules(); + Map<String, VfModule> expectedVfModules = mockHelper.getNewServiceModel().getVfModules(); + JsonAssert.assertJsonEquals(actualVfModules, expectedVfModules); + } + } + + @Test + public void assertEqualsBetweenPolicyConfigurationNodes() throws Exception { + for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { + Map<String, PortMirroringConfig> actualConfigurations = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getConfigurations(); + Map<String, PortMirroringConfig> expectedConfigurations = mockHelper.getNewServiceModel().getConfigurations(); + JsonAssert.assertJsonEquals(actualConfigurations, expectedConfigurations); + } + } + + @Test + public void assertEqualsBetweenServiceProxyNodes() throws Exception { + for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) { + Map<String, ServiceProxy> actualServiceProxies = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getServiceProxies(); + Map<String, ServiceProxy> expectedServiceProxies = mockHelper.getNewServiceModel().getServiceProxies(); + JsonAssert.assertJsonEquals(actualServiceProxies, expectedServiceProxies); + } + } + + private void verifyBaseNodeProperties(Node expectedNode, Node actualNode) { + Assert.assertEquals(expectedNode.getName(), actualNode.getName()); + Assert.assertEquals(expectedNode.getCustomizationUuid(), actualNode.getCustomizationUuid()); + Assert.assertEquals(expectedNode.getDescription(), actualNode.getDescription()); + Assert.assertEquals(expectedNode.getInvariantUuid(), actualNode.getInvariantUuid()); + Assert.assertEquals(expectedNode.getUuid(), actualNode.getUuid()); + Assert.assertEquals(expectedNode.getVersion(), actualNode.getVersion()); + } + + private void compareProperties(Map<String, String> expectedProperties, Map<String, String> actualProperties) { + for (Map.Entry<String, String> property : expectedProperties.entrySet()) { + String expectedValue = property.getValue(); + String key = property.getKey(); + String actualValue = actualProperties.get(key); + Assert.assertEquals(expectedValue, actualValue); + } + } + + private ToscaParserMockHelper[] getExpectedServiceModel() throws IOException { + ToscaParserMockHelper[] mockHelpers = { + new ToscaParserMockHelper(Constants.vlUuid, Constants.vlFilePath), + new ToscaParserMockHelper(Constants.vfUuid, Constants.vfFilePath), + new ToscaParserMockHelper(Constants.configurationUuid, Constants.configurationFilePath), + }; + for (ToscaParserMockHelper mockHelper : mockHelpers) { + InputStream jsonFile = VidControllerTest.class.getClassLoader().getResourceAsStream(mockHelper.getFilePath()); + String expectedJsonAsString = IOUtils.toString(jsonFile); + NewServiceModel newServiceModel1 = om.readValue(expectedJsonAsString, NewServiceModel.class); + mockHelper.setNewServiceModel(newServiceModel1); + } + return mockHelpers; + } + + private Path getCsarPath(String uuid) throws AsdcCatalogException { + return asdcClient.getServiceToscaModel(UUID.fromString(uuid)); + } + + private org.onap.vid.asdc.beans.Service getServiceByUuid(String uuid) throws AsdcCatalogException { + return asdcClient.getService(UUID.fromString(uuid)); + } + + public class Constants { + public static final String configurationUuid = "ee6d61be-4841-4f98-8f23-5de9da846ca7"; + public static final String configurationFilePath = "policy-configuration-csar.JSON"; + static final String vfUuid = "48a52540-8772-4368-9cdb-1f124ea5c931"; + static final String vlUuid = "cb49608f-5a24-4789-b0f7-2595473cb997"; + // public static final String PNFUuid = "68101369-6f08-4e99-9a28-fa6327d344f3"; + static final String vfFilePath = "vf-csar.JSON"; + static final String vlFilePath = "vl-csar.JSON"; +// public static final String PNFFilePath = "/Users/Oren/Git/Att/vid_internal/vid-app-common/src/main/resources/pnf.csar"; + + } + +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/ViewEditSubControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/ViewEditSubControllerTest.java new file mode 100644 index 000000000..061b359c7 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/controller/ViewEditSubControllerTest.java @@ -0,0 +1,45 @@ +//package org.onap.vid.controller; +// +//import javax.servlet.http.HttpServletRequest; +// +//import org.junit.Test; +//import org.springframework.web.servlet.ModelAndView; +// +//public class ViewEditSubControllerTest { +// +// private ViewEditSubController createTestSubject() { +// return new ViewEditSubController(); +// } +// +// @Test +// public void testWelcome() throws Exception { +// ViewEditSubController testSubject; +// HttpServletRequest request = null; +// ModelAndView result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.welcome(request); +// } +// +// +// @Test +// public void testGetViewName() throws Exception { +// ViewEditSubController testSubject; +// String result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.getViewName(); +// } +// +// @Test +// public void testSetViewName() throws Exception { +// ViewEditSubController testSubject; +// String viewName = ""; +// +// // default test +// testSubject = createTestSubject(); +// testSubject.setViewName(viewName); +// } +//}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/integrationTest/AaiIntegrationTest.java b/vid-app-common/src/test/java/org/onap/vid/integrationTest/AaiIntegrationTest.java new file mode 100644 index 000000000..eaad6ccc6 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/integrationTest/AaiIntegrationTest.java @@ -0,0 +1,43 @@ +package org.onap.vid.integrationTest; + +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.onap.vid.aai.AaiClient; +import org.onap.vid.aai.AaiClientInterface; +import org.onap.vid.aai.AaiResponse; +import org.onap.vid.aai.model.GetServiceModelsByDistributionStatusResponse; +import org.onap.vid.aai.model.Result; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.mock.web.MockServletContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.springframework.test.context.web.WebAppConfiguration; +import org.testng.Assert; +import org.testng.annotations.Test; + + +@ContextConfiguration(classes = {SystemProperties.class}) + + +@WebAppConfiguration +public class AaiIntegrationTest extends AbstractTestNGSpringContextTests { + + + @Autowired + MockServletContext servletContext; + + + @Test + public void testGetServiceModelsFromAai() throws Exception { + AaiClientInterface aaiClient = new AaiClient(servletContext); + AaiResponse<GetServiceModelsByDistributionStatusResponse> serviceModelsByDistributionStatusResponse = aaiClient.getServiceModelsByDistributionStatus(); + GetServiceModelsByDistributionStatusResponse response = serviceModelsByDistributionStatusResponse.getT(); + for(Result result: response.getResults()){ + Assert.assertNotNull(result.getModel().getModelInvariantId()); + Assert.assertNotNull(result.getModel().getModelVers().getModelVer().get(0).getModelVersionId()); + Assert.assertNotNull(result.getModel().getModelVers().getModelVer().get(0).getModelName()); + Assert.assertNotNull(result.getModel().getModelVers().getModelVer().get(0).getModelVersion()); + } + } + + +} diff --git a/vid-app-common/src/test/java/org/onap/vid/model/ModelUtilTest.java b/vid-app-common/src/test/java/org/onap/vid/model/ModelUtilTest.java new file mode 100644 index 000000000..af69b5342 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/model/ModelUtilTest.java @@ -0,0 +1,48 @@ +package org.onap.vid.model; + +import org.junit.Assert; +import org.junit.Test; + + +public class ModelUtilTest { + + private ModelUtil createTestSubject() { + return new ModelUtil(); + } + + + @Test + public void testGetTags() throws Exception { + String[] namespaces; + String constantValue = "test"; + String[] result; + + // test 1 + namespaces = null; + result = ModelUtil.getTags(namespaces, constantValue); + Assert.assertNull(result); + + // test 2 + namespaces = new String[] { "" }; + result = ModelUtil.getTags(namespaces, constantValue); + Assert.assertArrayEquals(new String[] { constantValue }, result); + } + + + @Test + public void testIsType() throws Exception { + String type = "a"; + String[] tags; + boolean result; + + // test 1 + tags = null; + result = ModelUtil.isType(type, tags); + Assert.assertEquals(false, result); + + // test 2 + tags = new String[] { "a" }; + result = ModelUtil.isType(type, tags); + Assert.assertEquals(true, result); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/model/NewNodeTest.java b/vid-app-common/src/test/java/org/onap/vid/model/NewNodeTest.java new file mode 100644 index 000000000..853ad738d --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/model/NewNodeTest.java @@ -0,0 +1,212 @@ +package org.onap.vid.model; + +import java.util.Map; + +import org.junit.Test; +import org.onap.vid.asdc.beans.tosca.Input; + + +public class NewNodeTest { + + private NewNode createTestSubject() { + return new NewNode(); + } + + + @Test + public void testGetUuid() throws Exception { + NewNode testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getUuid(); + } + + + @Test + public void testGetInvariantUuid() throws Exception { + NewNode testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getInvariantUuid(); + } + + + @Test + public void testGetDescription() throws Exception { + NewNode testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDescription(); + } + + + @Test + public void testGetName() throws Exception { + NewNode testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getName(); + } + + + @Test + public void testGetVersion() throws Exception { + NewNode testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVersion(); + } + + + @Test + public void testGetCustomizationUuid() throws Exception { + NewNode testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getCustomizationUuid(); + } + + + @Test + public void testGetInputs() throws Exception { + NewNode testSubject; + Map<String, Input> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getInputs(); + } + + + @Test + public void testGetCommands() throws Exception { + NewNode testSubject; + Map<String, CommandProperty> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getCommands(); + } + + + @Test + public void testGetProperties() throws Exception { + NewNode testSubject; + Map<String, String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getProperties(); + } + + + @Test + public void testSetUuid() throws Exception { + NewNode testSubject; + String uuid = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setUuid(uuid); + } + + + @Test + public void testSetInvariantUuid() throws Exception { + NewNode testSubject; + String invariantUuid = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setInvariantUuid(invariantUuid); + } + + + @Test + public void testSetDescription() throws Exception { + NewNode testSubject; + String description = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setDescription(description); + } + + + @Test + public void testSetName() throws Exception { + NewNode testSubject; + String name = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setName(name); + } + + + @Test + public void testSetVersion() throws Exception { + NewNode testSubject; + String version = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setVersion(version); + } + + + @Test + public void testSetCustomizationUuid() throws Exception { + NewNode testSubject; + String u = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setCustomizationUuid(u); + } + + + @Test + public void testSetInputs() throws Exception { + NewNode testSubject; + Map<String, Input> inputs = null; + + // default test + testSubject = createTestSubject(); + testSubject.setInputs(inputs); + } + + + @Test + public void testSetCommands() throws Exception { + NewNode testSubject; + Map<String, CommandProperty> m = null; + + // default test + testSubject = createTestSubject(); + testSubject.setCommands(m); + } + + + @Test + public void testSetProperties() throws Exception { + NewNode testSubject; + Map<String, String> p = null; + + // default test + testSubject = createTestSubject(); + testSubject.setProperties(p); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/model/NewServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/model/NewServiceTest.java new file mode 100644 index 000000000..ec688bdf3 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/model/NewServiceTest.java @@ -0,0 +1,235 @@ +package org.onap.vid.model; + +import java.util.Map; + +import org.junit.Test; +import org.onap.vid.asdc.beans.tosca.Input; + +public class NewServiceTest { + + private NewService createTestSubject() { + return new NewService(); + } + + + @Test + public void testGetUuid() throws Exception { + NewService testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getUuid(); + } + + + @Test + public void testGetInvariantUuid() throws Exception { + NewService testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getInvariantUuid(); + } + + + @Test + public void testGetName() throws Exception { + NewService testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getName(); + } + + + @Test + public void testGetVersion() throws Exception { + NewService testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVersion(); + } + + + @Test + public void testGetToscaModelURL() throws Exception { + NewService testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getToscaModelURL(); + } + + + @Test + public void testGetCategory() throws Exception { + NewService testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getCategory(); + } + + + @Test + public void testGetDescription() throws Exception { + NewService testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDescription(); + } + + + @Test + public void testGetInputs() throws Exception { + NewService testSubject; + Map<String, Input> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getInputs(); + } + + + @Test + public void testGetServiceEcompNaming() throws Exception { + NewService testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getServiceEcompNaming(); + } + + + @Test + public void testSetUuid() throws Exception { + NewService testSubject; + String uuid = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setUuid(uuid); + } + + + @Test + public void testSetInvariantUuid() throws Exception { + NewService testSubject; + String invariantUuid = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setInvariantUuid(invariantUuid); + } + + + @Test + public void testSetName() throws Exception { + NewService testSubject; + String name = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setName(name); + } + + + @Test + public void testSetVersion() throws Exception { + NewService testSubject; + String version = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setVersion(version); + } + + + @Test + public void testSetToscaModelURL() throws Exception { + NewService testSubject; + String toscaModelURL = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setToscaModelURL(toscaModelURL); + } + + + @Test + public void testSetCategory() throws Exception { + NewService testSubject; + String category = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setCategory(category); + } + + + @Test + public void testSetDescription() throws Exception { + NewService testSubject; + String description = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setDescription(description); + } + + + @Test + public void testSetInputs() throws Exception { + NewService testSubject; + Map<String, Input> inputs = null; + + // default test + testSubject = createTestSubject(); + testSubject.setInputs(inputs); + } + + + @Test + public void testSetServiceEcompNaming() throws Exception { + NewService testSubject; + String serviceEcompNaming = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setServiceEcompNaming(serviceEcompNaming); + } + + + @Test + public void testHashCode() throws Exception { + NewService testSubject; + int result; + + // default test + testSubject = createTestSubject(); + testSubject.setUuid("cb49608f-5a24-4789-b0f7-2595473cb997"); + result = testSubject.hashCode(); + } + + + @Test + public void testEquals() throws Exception { + NewService testSubject; + Object o = null; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.equals(o); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/model/NewVNFTest.java b/vid-app-common/src/test/java/org/onap/vid/model/NewVNFTest.java new file mode 100644 index 000000000..6546e0888 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/model/NewVNFTest.java @@ -0,0 +1,88 @@ +package org.onap.vid.model; + +import java.util.Map; + +import org.junit.Test; + +public class NewVNFTest { + + private NewVNF createTestSubject() { + return new NewVNF(); + } + + + @Test + public void testGetModelCustomizationName() throws Exception { + NewVNF testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getModelCustomizationName(); + } + + + @Test + public void testGetVfModules() throws Exception { + NewVNF testSubject; + Map<String, VfModule> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVfModules(); + } + + + @Test + public void testSetVfModules() throws Exception { + NewVNF testSubject; + Map<String, VfModule> vfModules = null; + + // default test + testSubject = createTestSubject(); + testSubject.setVfModules(vfModules); + } + + + @Test + public void testGetVolumeGroups() throws Exception { + NewVNF testSubject; + Map<String, VolumeGroup> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVolumeGroups(); + } + + + @Test + public void testSetVolumeGroups() throws Exception { + NewVNF testSubject; + Map<String, VolumeGroup> volumeGroups = null; + + // default test + testSubject = createTestSubject(); + testSubject.setVolumeGroups(volumeGroups); + } + + + @Test + public void testSetModelCustomizationName() throws Exception { + NewVNF testSubject; + String modelCustomizationName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setModelCustomizationName(modelCustomizationName); + } + + + @Test + public void testNormalizeName() throws Exception { + String originalName = ""; + String result; + + // default test + result = NewVNF.normalizeName(originalName); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/model/ServiceModelTest.java b/vid-app-common/src/test/java/org/onap/vid/model/ServiceModelTest.java new file mode 100644 index 000000000..27aa468c1 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/model/ServiceModelTest.java @@ -0,0 +1,123 @@ +package org.onap.vid.model; + +import java.util.Map; + +import org.junit.Test; +import org.onap.vid.asdc.beans.tosca.ToscaModel; +import org.onap.vid.model.Service; + +public class ServiceModelTest { + + private ServiceModel createTestSubject() { + return new ServiceModel(); + } + + @Test + public void testGetService() throws Exception { + ServiceModel testSubject; + Service result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getService(); + } + + @Test + public void testGetVnfs() throws Exception { + ServiceModel testSubject; + Map<String, VNF> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVnfs(); + } + + @Test + public void testGetNetworks() throws Exception { + ServiceModel testSubject; + Map<String, Network> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getNetworks(); + } + + @Test + public void testSetService() throws Exception { + ServiceModel testSubject; + Service service = null; + + // default test + testSubject = createTestSubject(); + testSubject.setService(service); + } + + @Test + public void testSetVnfs() throws Exception { + ServiceModel testSubject; + Map<String, VNF> vnfs = null; + + // default test + testSubject = createTestSubject(); + testSubject.setVnfs(vnfs); + } + + @Test + public void testSetNetworks() throws Exception { + ServiceModel testSubject; + Map<String, Network> networks = null; + + // default test + testSubject = createTestSubject(); + testSubject.setNetworks(networks); + } + + @Test + public void testGetVfModules() throws Exception { + ServiceModel testSubject; + Map<String, VfModule> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVfModules(); + } + + @Test + public void testGetVolumeGroups() throws Exception { + ServiceModel testSubject; + Map<String, VolumeGroup> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVolumeGroups(); + } + + @Test + public void testSetVfModules() throws Exception { + ServiceModel testSubject; + Map<String, VfModule> vfModules = null; + + // default test + testSubject = createTestSubject(); + testSubject.setVfModules(vfModules); + } + + @Test + public void testSetVolumeGroups() throws Exception { + ServiceModel testSubject; + Map<String, VolumeGroup> volumeGroups = null; + + // default test + testSubject = createTestSubject(); + testSubject.setVolumeGroups(volumeGroups); + } + + @Test + public void testAssociateGroups() throws Exception { + ServiceModel testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.associateGroups(); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/model/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/model/TestSuite.java new file mode 100644 index 000000000..f634fbc95 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/model/TestSuite.java @@ -0,0 +1,12 @@ +package org.onap.vid.model; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ ModelUtilTest.class, NewServiceTest.class, VolumeGroupTest.class, NewNodeTest.class, ServiceModelTest.class, + WorkflowTest.class, NewVNFTest.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/model/VolumeGroupTest.java b/vid-app-common/src/test/java/org/onap/vid/model/VolumeGroupTest.java new file mode 100644 index 000000000..05e517ec3 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/model/VolumeGroupTest.java @@ -0,0 +1,169 @@ +package org.onap.vid.model; + +import org.junit.Test; +import org.onap.vid.asdc.beans.tosca.Group; + + +public class VolumeGroupTest { + + private VolumeGroup createTestSubject() { + return new VolumeGroup(); + } + + + @Test + public void testGetUuid() throws Exception { + VolumeGroup testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getUuid(); + } + + + @Test + public void testGetCustomizationUuid() throws Exception { + VolumeGroup testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getCustomizationUuid(); + } + + + @Test + public void testGetModelCustomizationName() throws Exception { + VolumeGroup testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getModelCustomizationName(); + } + + + @Test + public void testGetInvariantUuid() throws Exception { + VolumeGroup testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getInvariantUuid(); + } + + + @Test + public void testGetDescription() throws Exception { + VolumeGroup testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDescription(); + } + + + @Test + public void testGetName() throws Exception { + VolumeGroup testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getName(); + } + + + @Test + public void testGetVersion() throws Exception { + VolumeGroup testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVersion(); + } + + + @Test + public void testSetUuid() throws Exception { + VolumeGroup testSubject; + String uuid = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setUuid(uuid); + } + + + @Test + public void testSetInvariantUuid() throws Exception { + VolumeGroup testSubject; + String invariantUuid = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setInvariantUuid(invariantUuid); + } + + + @Test + public void testSetDescription() throws Exception { + VolumeGroup testSubject; + String description = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setDescription(description); + } + + + @Test + public void testSetName() throws Exception { + VolumeGroup testSubject; + String name = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setName(name); + } + + + @Test + public void testSetVersion() throws Exception { + VolumeGroup testSubject; + String version = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setVersion(version); + } + + + @Test + public void testSetCustomizationUuid() throws Exception { + VolumeGroup testSubject; + String u = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setCustomizationUuid(u); + } + + + @Test + public void testSetModelCustomizationName() throws Exception { + VolumeGroup testSubject; + String u = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setModelCustomizationName(u); + } + + + +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/model/WorkflowTest.java b/vid-app-common/src/test/java/org/onap/vid/model/WorkflowTest.java new file mode 100644 index 000000000..8cfc65a73 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/model/WorkflowTest.java @@ -0,0 +1,72 @@ +package org.onap.vid.model; + +import java.util.Collection; + +import org.junit.Test; + +public class WorkflowTest { + + private Workflow createTestSubject() { + return new Workflow(); + } + + @Test + public void testGetId() throws Exception { + Workflow testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getId(); + } + + @Test + public void testGetWorkflowName() throws Exception { + Workflow testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getWorkflowName(); + } + + @Test + public void testGetVnfNames() throws Exception { + Workflow testSubject; + Collection<String> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getVnfNames(); + } + + @Test + public void testSetId() throws Exception { + Workflow testSubject; + int id = 0; + + // default test + testSubject = createTestSubject(); + testSubject.setId(id); + } + + @Test + public void testSetWorkflowName() throws Exception { + Workflow testSubject; + String workflowName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setWorkflowName(workflowName); + } + + @Test + public void testSetVnfName() throws Exception { + Workflow testSubject; + Collection<String> vnfNames = null; + + // default test + testSubject = createTestSubject(); + testSubject.setVnfName(vnfNames); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/model/oeModel.java b/vid-app-common/src/test/java/org/onap/vid/model/oeModel.java new file mode 100644 index 000000000..9d350cb72 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/model/oeModel.java @@ -0,0 +1,10 @@ +package org.onap.vid.model; + +import java.util.List; +import java.util.Map; + +public class oeModel { + public Map<String,List<Map<String,String>>> categoryParameters; +} + + diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java new file mode 100644 index 000000000..4a0685786 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicTest.java @@ -0,0 +1,71 @@ +package org.onap.vid.mso; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.onap.vid.controller.MsoConfig; +import org.onap.vid.mso.MsoBusinessLogicImpl; +import org.onap.vid.mso.MsoInterface; +import org.onap.vid.mso.MsoResponseWrapper; +import org.onap.vid.mso.rest.RequestDetails; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.springframework.test.context.web.WebAppConfiguration; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.net.URL; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +@Test +@ContextConfiguration(classes = { SystemProperties.class, MsoConfig.class }) +@WebAppConfiguration +public class MsoBusinessLogicTest extends AbstractTestNGSpringContextTests { + + @InjectMocks + private MsoBusinessLogicImpl msoBusinessLogic; + + @Mock + private MsoInterface msoClient; + + @BeforeMethod + public void initMocks(){ + MockitoAnnotations.initMocks(this); + } + + @Test + public void testCreateInstance() throws Exception { + String instanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d"; + final RequestDetails requestDetails = setRequestDetails("mso_request_create_configuration.json"); + Mockito.doReturn(getOkResponse(instanceId)).when(msoClient).createConfigurationInstance(requestDetails, "/serviceInstances/v6/3f93c7cb-2fd0-4557-9514-e189b7b04f9d/configurations"); + final MsoResponseWrapper msoResponseWrapper = msoBusinessLogic.createConfigurationInstance(requestDetails, instanceId); + + assertNotNull(msoResponseWrapper); + assertEquals(202, msoResponseWrapper.getStatus()); + } + + private MsoResponseWrapper getOkResponse(String instanceId){ + MsoResponseWrapper responseWrapper = new MsoResponseWrapper(); + String entity = " \"body\": {\n" + + " \"requestReferences\": {\n" + + " \"instanceId\": \""+instanceId+"\",\n" + + " \"requestId\": \"b6dc9806-b094-42f7-9386-a48de8218ce8\"\n" + + " }"; + responseWrapper.setEntity(entity); + responseWrapper.setStatus(202); + return responseWrapper; + } + + private RequestDetails setRequestDetails(String bodyFileName)throws Exception { + final URL resource = this.getClass().getResource("/payload_jsons/" + bodyFileName); + ObjectMapper mapper = new ObjectMapper(); + RequestDetails requestDetails = mapper.readValue(resource, RequestDetails.class); + return requestDetails; + + } +} diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java new file mode 100644 index 000000000..fcf246c99 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java @@ -0,0 +1,215 @@ +package org.onap.vid.mso; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableListMultimap; +import org.apache.commons.io.IOUtils; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.onap.vid.changeManagement.RequestDetailsWrapper; +import org.onap.vid.controller.MsoConfig; +import org.onap.vid.controller.OperationalEnvironmentController; +import org.onap.vid.controller.OperationalEnvironmentController.*; +import org.onap.vid.controller.WebConfig; +import org.onap.vid.mso.MsoBusinessLogic; +import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo; +import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo; +import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails; +import org.onap.vid.mso.rest.RequestDetails; +import org.onap.vid.properties.AsdcClientConfiguration; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.springframework.test.context.web.WebAppConfiguration; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import javax.inject.Inject; +import java.io.IOException; +import java.net.URL; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Test +@ContextConfiguration(classes = { WebConfig.class, AsdcClientConfiguration.class, SystemProperties.class, MsoConfig.class }) +@WebAppConfiguration +public class MsoOperationalEnvironmentTest extends AbstractTestNGSpringContextTests { + + @Inject + private MsoBusinessLogic msoBusinessLogic; + + @Test(dataProvider = "getOperationalEnvironmentActivationPermutations") + public void testJsonResultOfOperationalEnvironmentActivationRequestDetails(HashMap<String, String> permutation) throws IOException { + + // Convert 'manifest' to model + final OperationalEnvironmentManifest manifest = new ObjectMapper().readerFor(OperationalEnvironmentManifest.class).readValue(permutation.get("<manifest>")); + + // build OperationalEnvironmentActivateInfo + OperationalEnvironmentActivateInfo inputUnderTest = createOperationalEnvironmentActivateInfo("<instanceId>", permutation.get("<userId>"), manifest, permutation.get("<relatedInstanceId>"), permutation.get("<relatedInstanceName>"), permutation.get("<workloadContext>")); + + // transform to RequestDetails, and serialize to json + // -> actually, the function "msoBusinessLogic.createOperationalEnvironmentActivationRequestDetails" + // is the code under test here + final RequestDetailsWrapper<RequestDetails> operationalEnvironmentActivationRequestDetails = msoBusinessLogic.createOperationalEnvironmentActivationRequestDetails(inputUnderTest); + + String expected = buildExpectation("payload_jsons/activateOperationalEnvironmentsPayloadToMso.json", permutation); + + assertThatExpectationIsLikeObject(expected, operationalEnvironmentActivationRequestDetails); + } + + @DataProvider + private Object[][] getOperationalEnvironmentActivationPermutations() throws IOException { + final String manifest = "" + + "{" + + " \"serviceModelList\": [" + + " {" + + " \"serviceModelVersionId\": \"uuid2\"," + + " \"recoveryAction\": \"retry\"" + + " }" + + " ]" + + "}"; + + + final ImmutableListMultimap<String, String> options = ImmutableListMultimap.<String, String>builder() + .putAll("<instanceId>", "instanceId") + .putAll("<userId>", "1", "0198adb8-87fd-46ef-94ae-258816629c8b") + .putAll("<relatedInstanceId>", "relatedInstanceId", "2744cf56-4f00-4e48-917b-c3bd3b1f8984") + .putAll("<relatedInstanceName>", "relatedInstanceName", "Brooklynn Puanani") + .putAll("<workloadContext>", "workloadContext", "VNF_E2E-extreme") + .putAll("<manifest>", manifest) + .build(); + + List<HashMap<String, String>> permutations = permuteOptions(options); + + return permutations.stream().map(m -> new Object[] { m }).collect(Collectors.toList()).toArray(new Object[0][0]); + } + + @Test(dataProvider = "getOperationalEnvironmentCreationPermutations") + public void testJsonResultOfOperationalEnvironmentCreationRequestDetails(HashMap<String, String> permutation) throws IOException { + + // build OperationalEnvironmentCreateBody + OperationalEnvironmentController.OperationalEnvironmentCreateBody inputUnderTest = createOperationalEnvironmentCreateBody(permutation.get("<instanceName>"), permutation.get("<ecompInstanceId>"), permutation.get("<ecompInstanceName>"), permutation.get("<operationalEnvType>"), permutation.get("<tenantContext>"), permutation.get("<workloadContext>")); + + // transform to RequestDetails, and serialize to json + // -> actually, the function "msoBusinessLogic.createOperationalEnvironmentActivationRequestDetails" + // is the code under test here + final RequestDetailsWrapper<OperationEnvironmentRequestDetails> operationalEnvironmentCreationRequestDetails = msoBusinessLogic.convertParametersToRequestDetails(inputUnderTest, permutation.get("<userId>")); + + String expected = buildExpectation("payload_jsons/createOperationalEnvironmentsPayloadToMso.json", permutation); + + assertThatExpectationIsLikeObject(expected, operationalEnvironmentCreationRequestDetails); + } + + @DataProvider + private Object[][] getOperationalEnvironmentCreationPermutations() throws IOException { + + final ImmutableListMultimap<String, String> options = ImmutableListMultimap.<String, String>builder() + // instanceName, ecompInstanceId, ecompInstanceName, operationalEnvType, tenantContext, workloadContext + .putAll("<userId>", "1", "ceb60bba-7c18-49cd-a8f6-83ff2e1430b0", "Storm Landebert") + .putAll("<instanceName>", "instanceName", "Slavica Hadrien") + .putAll("<ecompInstanceId>", "ecompInstanceId", "58ec6753-957f-4124-8f92-c1c0bd2464a4") + .putAll("<ecompInstanceName>", "ecompInstanceName", "Bente Keelin") + .putAll("<operationalEnvType>", "operationalEnvType", "VNF") + .putAll("<tenantContext>", "tenantContext", "Production") + .putAll("<workloadContext>", "workloadContext", "E2E-extreme") + .build(); + + List<HashMap<String, String>> permutations = permuteOptions(options); + + return permutations.stream().map(m -> new Object[] { m }).collect(Collectors.toList()).toArray(new Object[0][0]); + } + + @Test(dataProvider = "getOperationalEnvironmentDeactivationPermutations") + public void testJsonResultOfOperationalEnvironmentDeactivationRequestDetails(HashMap<String, String> permutation) throws IOException { + + OperationalEnvironmentDeactivateInfo inputUnderTest = createOperationalEnvironmentDeactivateInfo("operationalEnvId>", permutation.get("<userId>")); + + final RequestDetailsWrapper<RequestDetails> operationalEnvironmentDeactivationRequestDetails = msoBusinessLogic.createOperationalEnvironmentDeactivationRequestDetails(inputUnderTest); + + String expected = buildExpectation("payload_jsons/deactivateOperationalEnvironmentsPayloadToMso.json", permutation); + + assertThatExpectationIsLikeObject(expected, operationalEnvironmentDeactivationRequestDetails); + } + + @DataProvider + private Object[][] getOperationalEnvironmentDeactivationPermutations() throws IOException { + + final ImmutableListMultimap<String, String> options = ImmutableListMultimap.<String, String>builder() + .putAll("<userId>", "instanceName", "Slavica Hadrien") + .build(); + + List<HashMap<String, String>> permutations = permuteOptions(options); + + return permutations.stream().map(m -> new Object[] { m }).collect(Collectors.toList()).toArray(new Object[0][0]); + } + + private List<HashMap<String, String>> permuteOptions(ImmutableListMultimap<String, String> options) { + // try any value, where the other keys are on the default one (index zero) + // result it's not the whole world of permutations, but rather a skim set, which its + // size is as the number of unique values in "options" + + HashMap<String, String> baseMutation = new HashMap<>(); + for (String key : options.keySet()) { + baseMutation.put(key, options.get(key).get(0)); + } + + List<HashMap<String, String>> res = new LinkedList<>(); + res.add(baseMutation); + + for (String key : options.keySet()) { + final ImmutableList<String> entry = options.get(key); + for (String value : entry.subList(1, entry.size())) { // skip the first option at index zero + HashMap<String, String> mutation = new HashMap<>(); + mutation.putAll(baseMutation); + mutation.put(key, value); + res.add(mutation); + } + } + return res; + } + + private void assertThatExpectationIsLikeObject(String expected, Object requestDetails) throws JsonProcessingException { + final String requestDetailsAsString = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(requestDetails); + + // assert for exact match + try { + JSONAssert.assertEquals("built mso request is not ok", expected, requestDetailsAsString, JSONCompareMode.STRICT); + } catch (AssertionError | Exception e) { + System.out.println("requestDetailsAsString: \n" + requestDetailsAsString); + System.out.println("expected: \n" + expected); + throw e; + } + } + + private String buildExpectation(String modelFileName, HashMap<String, String> permutation) throws IOException { + // load expected result, and populate it with current input 'permutation' values + final URL resource = this.getClass().getResource("/" + modelFileName); + String expected = IOUtils.toString(resource, "UTF-8"); + + for (Map.Entry<String, String> stringStringEntry : permutation.entrySet()) { + expected = expected.replaceAll(stringStringEntry.getKey(), stringStringEntry.getValue()); + } + return expected; + } + + + + private OperationalEnvironmentActivateInfo createOperationalEnvironmentActivateInfo(String operationalEnvId, String userId, OperationalEnvironmentManifest manifest, String relatedInstanceId, String relatedInstanceName, String workloadContext) { + OperationalEnvironmentController.OperationalEnvironmentActivateBody body = new OperationalEnvironmentController.OperationalEnvironmentActivateBody(relatedInstanceId, relatedInstanceName, workloadContext, manifest); + return new OperationalEnvironmentActivateInfo(body, userId, operationalEnvId); + } + + private OperationalEnvironmentDeactivateInfo createOperationalEnvironmentDeactivateInfo(String operationalEnvId, String userId) { + return new OperationalEnvironmentDeactivateInfo(userId, operationalEnvId); + } + + private OperationalEnvironmentController.OperationalEnvironmentCreateBody createOperationalEnvironmentCreateBody(String instanceName, String ecompInstanceId, String ecompInstanceName, String operationalEnvType, String tenantContext, String workloadContext) { + return new OperationalEnvironmentController.OperationalEnvironmentCreateBody(instanceName, ecompInstanceId, ecompInstanceName, operationalEnvType, tenantContext, workloadContext); + } + +} diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoUtilTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoUtilTest.java new file mode 100644 index 000000000..3356fddfc --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoUtilTest.java @@ -0,0 +1,53 @@ +package org.onap.vid.mso; + +import org.apache.poi.hssf.record.formula.functions.T; +import org.glassfish.jersey.client.ClientResponse; +import org.junit.Assert; +import org.junit.Test; + +public class MsoUtilTest { + + private MsoUtil createTestSubject() { + return new MsoUtil(); + } + + @Test + public void testWrapResponse() throws Exception { + String body = ""; + int statusCode = 0; + MsoResponseWrapper result; + + // default test + result = MsoUtil.wrapResponse(body, statusCode); + } + + + @Test + public void testWrapResponse_2() throws Exception { + RestObject<String> rs = null; + MsoResponseWrapper result; + + // test 1 + result = MsoUtil.wrapResponse(rs); + Assert.assertNotNull(result); + } + + @Test + public void testConvertPojoToString() throws Exception { + T t = null; + String result; + + // test 1 + t = null; + result = MsoUtil.convertPojoToString(t); + Assert.assertEquals("", result); + } + + @Test + public void testMain() throws Exception { + String[] args = new String[] { "" }; + + // default test + MsoUtil.main(args); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java new file mode 100644 index 000000000..a3fa7bca3 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java @@ -0,0 +1,20 @@ +package org.onap.vid.mso; + +import org.junit.Test; + +public class RestMsoImplementationTest { + + private RestMsoImplementation createTestSubject() { + return new RestMsoImplementation(); + } + +// @Test +// public void testInitMsoClient() throws Exception { +// RestMsoImplementation testSubject; +// +// // default test +// testSubject = createTestSubject(); +// testSubject.initMsoClient(); +// } + +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/AsyncRequestStatusTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/AsyncRequestStatusTest.java new file mode 100644 index 000000000..ba939580a --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/AsyncRequestStatusTest.java @@ -0,0 +1,91 @@ +package org.onap.vid.mso.rest; + +import org.junit.Test; +import org.onap.vid.domain.mso.InstanceIds; +import org.onap.vid.domain.mso.RequestStatus; + + +public class AsyncRequestStatusTest { + + private AsyncRequestStatus createTestSubject() { + return new AsyncRequestStatus(); + } + + + @Test + public void testGetInstanceIds() throws Exception { + AsyncRequestStatus testSubject; + InstanceIds result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getInstanceIds(); + } + + + @Test + public void testSetInstanceIds() throws Exception { + AsyncRequestStatus testSubject; + InstanceIds instanceIds = null; + + // default test + testSubject = createTestSubject(); + testSubject.setInstanceIds(instanceIds); + } + + + @Test + public void testGetRequestStatus() throws Exception { + AsyncRequestStatus testSubject; + RequestStatus result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRequestStatus(); + } + + + @Test + public void testSetRequestStatus() throws Exception { + AsyncRequestStatus testSubject; + RequestStatus requestStatus = null; + + // default test + testSubject = createTestSubject(); + testSubject.setRequestStatus(requestStatus); + } + + + @Test + public void testToString() throws Exception { + AsyncRequestStatus testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.toString(); + } + + + @Test + public void testHashCode() throws Exception { + AsyncRequestStatus testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.hashCode(); + } + + + @Test + public void testEquals() throws Exception { + AsyncRequestStatus testSubject; + Object other = null; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.equals(other); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java new file mode 100644 index 000000000..ef261055a --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java @@ -0,0 +1,78 @@ +//package org.onap.vid.mso.rest; +// +//import com.fasterxml.jackson.databind.ObjectMapper; +//import org.json.JSONObject; +//import org.junit.Assert; +//import org.openecomp.portalsdk.core.util.SystemProperties; +//import org.onap.vid.changeManagement.RequestDetails; +//import org.onap.vid.controller.LocalWebConfig; +//import org.onap.vid.domain.mso.CloudConfiguration; +//import org.onap.vid.domain.mso.ModelInfo; +//import org.onap.vid.domain.mso.RequestInfo; +//import org.onap.vid.domain.mso.RequestParameters; +//import org.onap.vid.mso.MsoBusinessLogic; +//import org.onap.vid.mso.MsoBusinessLogicImpl; +//import org.onap.vid.mso.rest.MsoRestClientNew; +//import org.springframework.test.context.ContextConfiguration; +//import org.springframework.test.context.web.WebAppConfiguration; +//import org.testng.annotations.Test; +// +// +//@ContextConfiguration(classes = {LocalWebConfig.class, SystemProperties.class}) +//@WebAppConfiguration +//public class MsoRestClientTest { +// +// +// private MsoBusinessLogic msoBusinessLogic = new MsoBusinessLogicImpl(new MsoRestClientNew()); +// private ObjectMapper om = new ObjectMapper(); +// +// @Test +// public void createInPlaceMsoRequest() { +// String result = null; +// try { +// RequestDetails requestDetails = generateMockMsoRequest(); +// result = om.writeValueAsString(msoBusinessLogic.generateInPlaceMsoRequest(requestDetails)); +// +// } catch (Exception e) { +// e.printStackTrace(); +// +// } +// if (result == null) { +// Assert.fail("Failed to create mso request"); +// } +// JSONObject jsonObj = new JSONObject(result); +// Assert.assertNotNull(jsonObj.getJSONObject("requestDetails")); +// +// +// } +// +// private RequestDetails generateMockMsoRequest() { +// RequestDetails requestDetails = new RequestDetails(); +// requestDetails.setVnfInstanceId("vnf-instance-id"); +// requestDetails.setVnfName("vnf-name"); +// CloudConfiguration cloudConfiguration = new CloudConfiguration(); +// cloudConfiguration.setTenantId("tenant-id"); +// cloudConfiguration.setLcpCloudRegionId("lcp-region"); +// requestDetails.setCloudConfiguration(cloudConfiguration); +// ModelInfo modelInfo = new ModelInfo(); +// modelInfo.setModelInvariantId("model-invarient-id"); +// modelInfo.setModelCustomizationName("modelCustomizationName"); +// requestDetails.setModelInfo(modelInfo); +// RequestInfo requestInfo = new RequestInfo(); +// requestInfo.setRequestorId("ok883e"); +// requestInfo.setSource("VID"); +// requestDetails.setRequestInfo(requestInfo); +// RequestParameters requestParameters = new RequestParameters(); +// requestParameters.setSubscriptionServiceType("subscriber-service-type"); +// requestParameters.setAdditionalProperty("a", 1); +// requestParameters.setAdditionalProperty("b", 2); +// requestParameters.setAdditionalProperty("c", 3); +// requestParameters.setAdditionalProperty("d", 4); +// String payload = "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}"; +// requestParameters.setAdditionalProperty("payload", payload); +// +// requestDetails.setRequestParameters(requestParameters); +// return requestDetails; +// } +// +//} diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestId.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestId.java new file mode 100644 index 000000000..51071a859 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestId.java @@ -0,0 +1,280 @@ +package org.onap.vid.mso.rest; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.mockito.*; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.onap.vid.aai.util.AAIRestInterface; +import org.onap.vid.asdc.rest.RestfulAsdcClient; +import org.onap.vid.changeManagement.RequestDetailsWrapper; +import org.onap.vid.controller.filter.PromiseEcompRequestIdFilter; +import org.onap.vid.mso.RestMsoImplementation; +import org.onap.vid.mso.RestObject; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.Serializable; +import java.util.List; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static java.util.UUID.randomUUID; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.*; + + +public class OutgoingRequestId { + + + @InjectMocks + private RestMsoImplementation restMsoImplementation; + + @InjectMocks + private AAIRestInterface aaiRestInterface; + + private RestfulAsdcClient restfulAsdcClient = new RestfulAsdcClient.Builder(mock(Client.class), null).build(); + + @Captor + private ArgumentCaptor<MultivaluedMap<String, Object>> multivaluedMapArgumentCaptor; + + @BeforeClass + public void initMocks() { + MockitoAnnotations.initMocks(this); + } + + @BeforeMethod + private void putRequestInSpringContext() { + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes((HttpServletRequest) PromiseEcompRequestIdFilter.wrapIfNeeded(new MockHttpServletRequest()))); + } + + @DataProvider + public Object[][] sdcMethods() { + return Stream.<ThrowingConsumer<RestfulAsdcClient>>of( + + client -> client.getResource(randomUUID()), + client -> client.getResourceArtifact(randomUUID(), randomUUID()), + RestfulAsdcClient::getResources, + client -> client.getResources(ImmutableMap.of()), + client -> client.getResourceToscaModel(randomUUID()), + client -> client.getService(randomUUID()), + client -> client.getServiceArtifact(randomUUID(), randomUUID()), + RestfulAsdcClient::getServices, + client -> client.getServices(ImmutableMap.of()), + client -> client.getServiceToscaModel(randomUUID()) + + ).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{}); + } + + @Test(dataProvider = "sdcMethods") + public void sdc(Consumer<RestfulAsdcClient> f) throws Exception { + final Mocks mocks = setAndGetMocksInsideRestImpl(restfulAsdcClient); + + f.accept(restfulAsdcClient); + + verifyRequestIdHeaderWasAdded(mocks.getFakeBuilder()); + } + + @DataProvider + public Object[][] msoMethods() { + return Stream.<ThrowingConsumer<RestMsoImplementation>>of( + + client -> client.Get(new Object(), "whatever source id", "/any path", new RestObject<>()), + client -> client.GetForObject("whatever source id", "/any path", Object.class), + client -> client.Post(new Object(), "some payload", "whatever source id", "/any path", new RestObject<>()), + client -> client.PostForObject("some payload", "whatever source id", "/any path", Object.class), + client -> client.Put(Object.class, new RequestDetailsWrapper(), "whatever source id", "/any path", new RestObject<>()) + + ).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{}); + } + + @Test(dataProvider = "msoMethods") + public void mso(Consumer<RestMsoImplementation> f) throws Exception { + final Mocks mocks = setAndGetMocksInsideRestImpl(restMsoImplementation.getClass()); + + f.accept(restMsoImplementation); + + verifyRequestIdHeaderWasAdded(mocks.getFakeBuilder()); + } + + @DataProvider + public Object[][] aaiMethods() { + return Stream.<ThrowingConsumer<AAIRestInterface>>of( + + client -> client.RestGet("from app id", "some transId", "/any path", false), + client -> client.Delete("whatever source id", "some transId", "/any path"), + client -> client.RestPost("from app id", "some transId", "/any path", "some payload", false), + client -> client.RestPut("from app id", "some transId", "/any path", "some payload", false) + + ).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{}); + } + + @Test(dataProvider = "aaiMethods") + public void aai(Consumer<AAIRestInterface> f) throws Exception { + final Mocks mocks = setAndGetMocksInsideRestImpl(aaiRestInterface.getClass()); + + f.accept(aaiRestInterface); + + verifyRequestIdHeaderWasAdded(mocks.getFakeBuilder()); + } + +// @Test(dataProvider = "schedulerMethods") +// public void scheduler(Consumer<AAIRestInterface> f) throws Exception { +// +// This test os not feasible in the wat acheduler is implemented today, +// as Scheduler's client is rewritten in every call. +// +// :-( +// +// } + + private void verifyRequestIdHeaderWasAdded(Invocation.Builder fakeBuilder) { + final String requestIdHeader = "x-ecomp-requestid"; + final String uuidRegex = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"; + + // Checks that the builder was called with either one of header("x-ecomp-requestid", uuid) + // or the plural brother: headers(Map.of("x-ecomp-requestid", Set.of(uuid)) + + Object requestId; + // The 'verify()' will capture the request id. If no match -- AssertionError will + // catch for a second chance -- another 'verify()'. + try { + ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class); + Mockito.verify(fakeBuilder) + .header( + Matchers.argThat(equalToIgnoringCase(requestIdHeader)), + argumentCaptor.capture() + ); + requestId = argumentCaptor.getValue(); + + } catch (AssertionError e) { + Mockito.verify(fakeBuilder).headers(multivaluedMapArgumentCaptor.capture()); + + final MultivaluedMap<String, Object> headersMap = multivaluedMapArgumentCaptor.getValue(); + final String thisRequestIdHeader = getFromSetCaseInsensitive(headersMap.keySet(), requestIdHeader); + + assertThat(headersMap.keySet(), hasItem(thisRequestIdHeader)); + requestId = headersMap.getFirst(thisRequestIdHeader); + } + + assertThat("header '" + requestIdHeader + "' should be a uuid", requestId, + allOf(instanceOf(String.class), hasToString(matchesPattern(uuidRegex)))); + } + + private String getFromSetCaseInsensitive(Set<String> set, String key) { + return set.stream() + .filter(anotherString -> anotherString.equalsIgnoreCase(key)) + .findFirst() + .orElse(key); + } + + private Mocks setAndGetMocksInsideRestImpl(Class<?> clazz) throws IllegalAccessException { + Mocks mocks = new Mocks(); + Client fakeClient = mocks.getFakeClient(); + + FieldUtils.writeStaticField(clazz, "client", fakeClient, true); + + return mocks; + } + + private Mocks setAndGetMocksInsideRestImpl(Object instance) throws IllegalAccessException { + Mocks mocks = new Mocks(); + Client fakeClient = mocks.getFakeClient(); + + FieldUtils.writeField(instance, "client", fakeClient, true); + + return mocks; + } + + private static class Mocks { + private final Client fakeClient; + private final Invocation.Builder fakeBuilder; + + Client getFakeClient() { + return fakeClient; + } + + Invocation.Builder getFakeBuilder() { + return fakeBuilder; + } + + Mocks() { + final MockSettings mockSettings = withSettings().defaultAnswer(new TriesToReturnMockByType()); + + fakeClient = mock(Client.class, mockSettings); + fakeBuilder = mock(Invocation.Builder.class, mockSettings); + final WebTarget fakeWebTarget = mock(WebTarget.class, mockSettings); + final Response fakeResponse = mock(Response.class, mockSettings); + + TriesToReturnMockByType.setAvailableMocks( + fakeClient, + fakeWebTarget, + fakeBuilder, + fakeResponse + ); + + Mockito.when(fakeBuilder.get(any(Class.class))).thenReturn(null); + Mockito.when(fakeBuilder.get(eq(InputStream.class))).thenReturn(new ByteArrayInputStream(new byte[]{})); + Mockito.when(fakeBuilder.get(any(GenericType.class))).thenReturn(null); + + Mockito.when(fakeResponse.getStatus()).thenReturn(200); + } + } + + @FunctionalInterface + public interface ThrowingConsumer<T> extends Consumer<T> { + @Override + default void accept(T t) { + try { + acceptThrows(t); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + void acceptThrows(T t) throws Exception; + } + + /* + inspired out from newer Mockito version + returns a mock from given list if it's a matching return-type + */ + public static class TriesToReturnMockByType implements Answer<Object>, Serializable { + private final Answer<Object> defaultReturn = RETURNS_DEFAULTS; + private static List<Object> availableMocks = ImmutableList.of(); + + static void setAvailableMocks(Object... mocks) { + availableMocks = ImmutableList.copyOf(mocks); + } + + public Object answer(InvocationOnMock invocation) throws Throwable { + Class<?> methodReturnType = invocation.getMethod().getReturnType(); + + return availableMocks.stream() + .filter(mock -> methodReturnType.isAssignableFrom(mock.getClass())) + //.peek(m -> System.out.println("found a mock: " + m.getClass().getName())) + .findFirst() + .orElse(defaultReturn.answer(invocation)); + } + } + +} diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java new file mode 100644 index 000000000..4b35430e0 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java @@ -0,0 +1,93 @@ +package org.onap.vid.mso.rest; + +import java.util.Map; + +import org.junit.Test; +import org.onap.vid.domain.mso.ModelInfo; + + +public class RelatedInstanceTest { + + private RelatedInstance createTestSubject() { + return new RelatedInstance(); + } + + + @Test + public void testGetModelInfo() throws Exception { + RelatedInstance testSubject; + ModelInfo result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getModelInfo(); + } + + + @Test + public void testSetModelInfo() throws Exception { + RelatedInstance testSubject; + ModelInfo modelInfo = null; + + // default test + testSubject = createTestSubject(); + testSubject.setModelInfo(modelInfo); + } + + + @Test + public void testToString() throws Exception { + RelatedInstance testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.toString(); + } + + + @Test + public void testGetAdditionalProperties() throws Exception { + RelatedInstance testSubject; + Map<String, Object> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAdditionalProperties(); + } + + + @Test + public void testSetAdditionalProperty() throws Exception { + RelatedInstance testSubject; + String name = ""; + Object value = null; + + // default test + testSubject = createTestSubject(); + testSubject.setAdditionalProperty(name, value); + } + + + @Test + public void testHashCode() throws Exception { + RelatedInstance testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.hashCode(); + } + + + @Test + public void testEquals() throws Exception { + RelatedInstance testSubject; + Object other = null; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.equals(other); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedModelTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedModelTest.java new file mode 100644 index 000000000..91d61bd9f --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedModelTest.java @@ -0,0 +1,93 @@ +package org.onap.vid.mso.rest; + +import java.util.Map; + +import org.junit.Test; +import org.onap.vid.domain.mso.ModelInfo; + + +public class RelatedModelTest { + + private RelatedModel createTestSubject() { + return new RelatedModel(); + } + + + @Test + public void testGetModelInfo() throws Exception { + RelatedModel testSubject; + ModelInfo result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getModelInfo(); + } + + + @Test + public void testSetModelInfo() throws Exception { + RelatedModel testSubject; + ModelInfo modelInfo = null; + + // default test + testSubject = createTestSubject(); + testSubject.setModelInfo(modelInfo); + } + + + @Test + public void testToString() throws Exception { + RelatedModel testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.toString(); + } + + + @Test + public void testGetAdditionalProperties() throws Exception { + RelatedModel testSubject; + Map<String, Object> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAdditionalProperties(); + } + + + @Test + public void testSetAdditionalProperty() throws Exception { + RelatedModel testSubject; + String name = ""; + Object value = null; + + // default test + testSubject = createTestSubject(); + testSubject.setAdditionalProperty(name, value); + } + + + @Test + public void testHashCode() throws Exception { + RelatedModel testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.hashCode(); + } + + + @Test + public void testEquals() throws Exception { + RelatedModel testSubject; + Object other = null; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.equals(other); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java new file mode 100644 index 000000000..153e16561 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java @@ -0,0 +1,182 @@ +package org.onap.vid.mso.rest; + +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.onap.vid.domain.mso.*; + + +public class RequestDetailsTest { + + private RequestDetails createTestSubject() { + return new RequestDetails(); + } + + + @Test + public void testGetCloudConfiguration() throws Exception { + RequestDetails testSubject; + CloudConfiguration result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getCloudConfiguration(); + } + + + @Test + public void testSetCloudConfiguration() throws Exception { + RequestDetails testSubject; + CloudConfiguration cloudConfiguration = null; + + // default test + testSubject = createTestSubject(); + testSubject.setCloudConfiguration(cloudConfiguration); + } + + + @Test + public void testGetModelInfo() throws Exception { + RequestDetails testSubject; + ModelInfo result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getModelInfo(); + } + + + @Test + public void testSetModelInfo() throws Exception { + RequestDetails testSubject; + ModelInfo modelInfo = null; + + // default test + testSubject = createTestSubject(); + testSubject.setModelInfo(modelInfo); + } + + + @Test + public void testGetRelatedInstanceList() throws Exception { + RequestDetails testSubject; + List<RelatedModel> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRelatedInstanceList(); + } + + + @Test + public void testSetRelatedInstanceList() throws Exception { + RequestDetails testSubject; + List<RelatedModel> relatedInstanceList = null; + + // default test + testSubject = createTestSubject(); + testSubject.setRelatedInstanceList(relatedInstanceList); + } + + + @Test + public void testGetRequestInfo() throws Exception { + RequestDetails testSubject; + RequestInfo result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRequestInfo(); + } + + + @Test + public void testSetRequestInfo() throws Exception { + RequestDetails testSubject; + RequestInfo requestInfo = null; + + // default test + testSubject = createTestSubject(); + testSubject.setRequestInfo(requestInfo); + } + + + @Test + public void testGetSubscriberInfo() throws Exception { + RequestDetails testSubject; + SubscriberInfo result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getSubscriberInfo(); + } + + + @Test + public void testSetSubscriberInfo() throws Exception { + RequestDetails testSubject; + SubscriberInfo subscriberInfo = null; + + // default test + testSubject = createTestSubject(); + testSubject.setSubscriberInfo(subscriberInfo); + } + + + @Test + public void testToString() throws Exception { + RequestDetails testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.toString(); + } + + + @Test + public void testGetAdditionalProperties() throws Exception { + RequestDetails testSubject; + Map<String, Object> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getAdditionalProperties(); + } + + + @Test + public void testSetAdditionalProperty() throws Exception { + RequestDetails testSubject; + String name = ""; + Object value = null; + + // default test + testSubject = createTestSubject(); + testSubject.setAdditionalProperty(name, value); + } + + + @Test + public void testHashCode() throws Exception { + RequestDetails testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.hashCode(); + } + + + @Test + public void testEquals() throws Exception { + RequestDetails testSubject; + Object other = null; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.equals(other); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/TestSuite.java new file mode 100644 index 000000000..72633daef --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/TestSuite.java @@ -0,0 +1,12 @@ +package org.onap.vid.mso.rest; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ RelatedModelTest.class, AsyncRequestStatusTest.class, RequestDetailsTest.class, + RelatedInstanceTest.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/policy/PolicyResponseWrapperTest.java b/vid-app-common/src/test/java/org/onap/vid/policy/PolicyResponseWrapperTest.java new file mode 100644 index 000000000..4e2676c6a --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/policy/PolicyResponseWrapperTest.java @@ -0,0 +1,70 @@ +package org.onap.vid.policy; + +import org.junit.Test; + +public class PolicyResponseWrapperTest { + + private PolicyResponseWrapper createTestSubject() { + return new PolicyResponseWrapper(); + } + + @Test + public void testGetEntity() throws Exception { + PolicyResponseWrapper testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getEntity(); + } + + @Test + public void testGetStatus() throws Exception { + PolicyResponseWrapper testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getStatus(); + } + + @Test + public void testSetStatus() throws Exception { + PolicyResponseWrapper testSubject; + int v = 0; + + // default test + testSubject = createTestSubject(); + testSubject.setStatus(v); + } + + @Test + public void testSetEntity() throws Exception { + PolicyResponseWrapper testSubject; + String v = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setEntity(v); + } + + @Test + public void testToString() throws Exception { + PolicyResponseWrapper testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.toString(); + } + + @Test + public void testGetResponse() throws Exception { + PolicyResponseWrapper testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getResponse(); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/policy/PolicyRestIntTest.java b/vid-app-common/src/test/java/org/onap/vid/policy/PolicyRestIntTest.java new file mode 100644 index 000000000..b94d21b91 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/policy/PolicyRestIntTest.java @@ -0,0 +1,22 @@ +package org.onap.vid.policy; + +import org.junit.Test; +import org.onap.vid.policy.rest.RequestDetails; + +public class PolicyRestIntTest { + + private PolicyRestInt createTestSubject() { + return new PolicyRestInt(); + } + + @Test + public void testLogRequest() throws Exception { + PolicyRestInt testSubject; + RequestDetails r = null; + + // test 1 + testSubject = createTestSubject(); + r = null; + testSubject.logRequest(r); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/policy/PolicyRestInterfaceTest.java b/vid-app-common/src/test/java/org/onap/vid/policy/PolicyRestInterfaceTest.java new file mode 100644 index 000000000..04f6890e2 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/policy/PolicyRestInterfaceTest.java @@ -0,0 +1,24 @@ +package org.onap.vid.policy; + +import org.apache.poi.hssf.record.formula.functions.T; +import org.json.simple.JSONObject; +import org.junit.Test; +import org.onap.vid.policy.rest.RequestDetails; + +public class PolicyRestInterfaceTest { + + private PolicyRestInterface createTestSubject() { + return new PolicyRestInterface(); + } + + + @Test + public void testLogRequest() throws Exception { + PolicyRestInterface testSubject; + RequestDetails r = null; + + // default test + testSubject = createTestSubject(); + testSubject.logRequest(r); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/policy/PolicyUtilTest.java b/vid-app-common/src/test/java/org/onap/vid/policy/PolicyUtilTest.java new file mode 100644 index 000000000..566d17c11 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/policy/PolicyUtilTest.java @@ -0,0 +1,54 @@ +package org.onap.vid.policy; + +import org.apache.poi.hssf.record.formula.functions.T; +import org.glassfish.jersey.client.ClientResponse; +import org.junit.Assert; +import org.junit.Test; + +public class PolicyUtilTest { + + private PolicyUtil createTestSubject() { + return new PolicyUtil(); + } + + @Test + public void testWrapResponse() throws Exception { + String body = ""; + int statusCode = 0; + PolicyResponseWrapper result; + + // default test + result = PolicyUtil.wrapResponse(body, statusCode); + } + + + @Test + public void testWrapResponse_2() throws Exception { + RestObject<String> rs = null; + PolicyResponseWrapper result; + + // test 1 + rs = null; + result = PolicyUtil.wrapResponse(rs); + Assert.assertNotNull(result); + } + + @Test + public void testConvertPojoToString() throws Exception { + T t = null; + String result; + + // test 1 + t = null; + result = PolicyUtil.convertPojoToString(t); + Assert.assertEquals("", result); + } + + @Test + public void testMain() throws Exception { + String[] args = new String[] { "" }; + + // default test + PolicyUtil.main(args); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/policy/RestObjectTest.java b/vid-app-common/src/test/java/org/onap/vid/policy/RestObjectTest.java new file mode 100644 index 000000000..7665d99a2 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/policy/RestObjectTest.java @@ -0,0 +1,50 @@ +package org.onap.vid.policy; + +import org.apache.poi.hssf.record.formula.functions.T; +import org.junit.Test; + +public class RestObjectTest { + + private RestObject createTestSubject() { + return new RestObject(); + } + + @Test + public void testSet() throws Exception { + RestObject testSubject; + T t = null; + + // default test + testSubject = createTestSubject(); + testSubject.set(t); + } + + @Test + public void testGet() throws Exception { + RestObject testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.get(); + } + + @Test + public void testSetStatusCode() throws Exception { + RestObject testSubject; + int v = 0; + + // default test + testSubject = createTestSubject(); + testSubject.setStatusCode(v); + } + + @Test + public void testGetStatusCode() throws Exception { + RestObject testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getStatusCode(); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/policy/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/policy/TestSuite.java new file mode 100644 index 000000000..6d2a790be --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/policy/TestSuite.java @@ -0,0 +1,12 @@ +package org.onap.vid.policy; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ RestObjectTest.class, PolicyResponseWrapperTest.class, PolicyRestIntTest.class, PolicyUtilTest.class, + PolicyRestInterfaceTest.class, org.onap.vid.policy.rest.TestSuite.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/policy/rest/RequestDetailsTest.java b/vid-app-common/src/test/java/org/onap/vid/policy/rest/RequestDetailsTest.java new file mode 100644 index 000000000..3c17a66a0 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/policy/rest/RequestDetailsTest.java @@ -0,0 +1,33 @@ +package org.onap.vid.policy.rest; + +import org.junit.Test; + + +public class RequestDetailsTest { + + private RequestDetails createTestSubject() { + return new RequestDetails(); + } + + + @Test + public void testGetPolicyName() throws Exception { + RequestDetails testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getPolicyName(); + } + + + @Test + public void testSetPolicyName() throws Exception { + RequestDetails testSubject; + String policyName = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setPolicyName(policyName); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/policy/rest/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/policy/rest/TestSuite.java new file mode 100644 index 000000000..0a8dfff91 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/policy/rest/TestSuite.java @@ -0,0 +1,11 @@ +package org.onap.vid.policy.rest; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ RequestDetailsTest.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/properties/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/properties/TestSuite.java new file mode 100644 index 000000000..747c1edbd --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/properties/TestSuite.java @@ -0,0 +1,11 @@ +package org.onap.vid.properties; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ VidPropertiesTest.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/properties/VidPropertiesTest.java b/vid-app-common/src/test/java/org/onap/vid/properties/VidPropertiesTest.java new file mode 100644 index 000000000..f256ba027 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/properties/VidPropertiesTest.java @@ -0,0 +1,31 @@ +package org.onap.vid.properties; + +import org.junit.Test; + + +public class VidPropertiesTest { + + private VidProperties createTestSubject() { + return new VidProperties(); + } + + + @Test + public void testGetAsdcModelNamespace() throws Exception { + String result; + + // default test + result = VidProperties.getAsdcModelNamespace(); + } + + + @Test + public void testGetPropertyWithDefault() throws Exception { + String propName = ""; + String defaultValue = ""; + String result; + + // default test + result = VidProperties.getPropertyWithDefault(propName, defaultValue); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java b/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java new file mode 100644 index 000000000..b023bc265 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java @@ -0,0 +1,50 @@ +package org.onap.vid.roles; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.junit.Test; + + +public class RoleProviderTest { + + private RoleProvider createTestSubject() { + return new RoleProvider(); + } + + + @Test + public void testExtractRoleFromSession() throws Exception { + HttpServletRequest request = null; + List<String> result; + + // default test + result = RoleProvider.extractRoleFromSession(request); + } + + +// @Test +// public void testGetUserRoles() throws Exception { +// RoleProvider testSubject; +// HttpServletRequest request = null; +// List<Role> result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.getUserRoles(request); +// } + + + @Test + public void testSplitRole() throws Exception { + RoleProvider testSubject; + String roleAsString = ""; + String[] result; + + // default test + testSubject = createTestSubject(); + //TODO:fix result = testSubject.splitRole(roleAsString); + } + +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/roles/RoleValidatorTest.java b/vid-app-common/src/test/java/org/onap/vid/roles/RoleValidatorTest.java new file mode 100644 index 000000000..7a1b09ac5 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/roles/RoleValidatorTest.java @@ -0,0 +1,58 @@ +package org.onap.vid.roles; + +import org.junit.Test; +import org.onap.vid.mso.rest.RequestDetails; + +public class RoleValidatorTest { + + private RoleValidator createTestSubject() { + return new RoleValidator(null); + } + +// @Test +// public void testIsSubscriberPermitted() throws Exception { +// RoleValidator testSubject; +// String subscriberName = ""; +// boolean result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.isSubscriberPermitted(subscriberName); +// } +// +// @Test +// public void testIsServicePermitted() throws Exception { +// RoleValidator testSubject; +// String subscriberName = ""; +// String serviceType = ""; +// boolean result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.isServicePermitted(subscriberName, serviceType); +// } + + @Test + public void testIsMsoRequestValid() throws Exception { + RoleValidator testSubject; + RequestDetails mso_request = null; + boolean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.isMsoRequestValid(mso_request); + } + +// @Test +// public void testIsTenantPermitted() throws Exception { +// RoleValidator testSubject; +// String globalCustomerId = ""; +// String serviceType = ""; +// String tenant = ""; +// boolean result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.isTenantPermitted(globalCustomerId, serviceType, tenant); +// } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/roles/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/roles/TestSuite.java new file mode 100644 index 000000000..7966eaa1f --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/roles/TestSuite.java @@ -0,0 +1,11 @@ +package org.onap.vid.roles; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ RoleValidatorTest.class, RoleProviderTest.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjects/GetTimeSlotsRestObjectTest.java b/vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjects/GetTimeSlotsRestObjectTest.java new file mode 100644 index 000000000..5bb525ebf --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjects/GetTimeSlotsRestObjectTest.java @@ -0,0 +1,33 @@ +//package org.onap.vid.scheduler.RestObjects; +// +//import org.junit.Test; +// +// +//public class GetTimeSlotsRestObjectTest { +// +// private GetTimeSlotsRestObject createTestSubject() { +// return new GetTimeSlotsRestObject(); +// } +// +// +// @Test +// public void testSetUUID() throws Exception { +// GetTimeSlotsRestObject testSubject; +// String uuid = ""; +// +// // default test +// testSubject = createTestSubject(); +// testSubject.setUUID(uuid); +// } +// +// +// @Test +// public void testGetUUID() throws Exception { +// GetTimeSlotsRestObject testSubject; +// String result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.getUUID(); +// } +//}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjects/PostCreateNewVnfRestObjectTest.java b/vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjects/PostCreateNewVnfRestObjectTest.java new file mode 100644 index 000000000..8750d5847 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjects/PostCreateNewVnfRestObjectTest.java @@ -0,0 +1,33 @@ +//package org.onap.vid.scheduler.RestObjects; +// +//import org.junit.Test; +// +// +//public class PostCreateNewVnfRestObjectTest { +// +// private PostCreateNewVnfRestObject createTestSubject() { +// return new PostCreateNewVnfRestObject(); +// } +// +// +// @Test +// public void testSetUUID() throws Exception { +// PostCreateNewVnfRestObject testSubject; +// String uuid = ""; +// +// // default test +// testSubject = createTestSubject(); +// testSubject.setUUID(uuid); +// } +// +// +// @Test +// public void testGetUUID() throws Exception { +// PostCreateNewVnfRestObject testSubject; +// String result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.getUUID(); +// } +//}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjects/PostSubmitVnfChangeRestObjectTest.java b/vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjects/PostSubmitVnfChangeRestObjectTest.java new file mode 100644 index 000000000..9c78d2365 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjects/PostSubmitVnfChangeRestObjectTest.java @@ -0,0 +1,33 @@ +//package org.onap.vid.scheduler.RestObjects; +// +//import org.junit.Test; +// +// +//public class PostSubmitVnfChangeRestObjectTest { +// +// private PostSubmitVnfChangeRestObject createTestSubject() { +// return new PostSubmitVnfChangeRestObject(); +// } +// +// +// @Test +// public void testSetUUID() throws Exception { +// PostSubmitVnfChangeRestObject testSubject; +// String uuid = ""; +// +// // default test +// testSubject = createTestSubject(); +// testSubject.setUUID(uuid); +// } +// +// +// @Test +// public void testGetUUID() throws Exception { +// PostSubmitVnfChangeRestObject testSubject; +// String result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.getUUID(); +// } +//}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjects/RestObjectTest.java b/vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjects/RestObjectTest.java new file mode 100644 index 000000000..b8924d84b --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjects/RestObjectTest.java @@ -0,0 +1,55 @@ +package org.onap.vid.scheduler.RestObjects; + +import org.apache.poi.hssf.record.formula.functions.T; +import org.junit.Test; + + +public class RestObjectTest { + + private RestObject createTestSubject() { + return new RestObject(); + } + + + @Test + public void testSet() throws Exception { + RestObject testSubject; + T t = null; + + // default test + testSubject = createTestSubject(); + testSubject.set(t); + } + + + @Test + public void testGet() throws Exception { + RestObject testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.get(); + } + + + @Test + public void testSetStatusCode() throws Exception { + RestObject testSubject; + int v = 0; + + // default test + testSubject = createTestSubject(); + testSubject.setStatusCode(v); + } + + + @Test + public void testGetStatusCode() throws Exception { + RestObject testSubject; + int result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getStatusCode(); + } +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerResponseWrappers/PostCreateNewVnfWrapperTest.java b/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerResponseWrappers/PostCreateNewVnfWrapperTest.java new file mode 100644 index 000000000..b0b051aff --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerResponseWrappers/PostCreateNewVnfWrapperTest.java @@ -0,0 +1,55 @@ +//package org.onap.vid.scheduler.SchedulerResponseWrappers; +// +//import org.junit.Test; +// +// +//public class PostCreateNewVnfWrapperTest { +// +// private PostCreateNewVnfWrapper createTestSubject() { +// return new PostCreateNewVnfWrapper(); +// } +// +// +// @Test +// public void testGetUuid() throws Exception { +// PostCreateNewVnfWrapper testSubject; +// String result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.getUuid(); +// } +// +// +// @Test +// public void testSetUuid() throws Exception { +// PostCreateNewVnfWrapper testSubject; +// String v = ""; +// +// // default test +// testSubject = createTestSubject(); +// testSubject.setUuid(v); +// } +// +// +// @Test +// public void testToString() throws Exception { +// PostCreateNewVnfWrapper testSubject; +// String result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.toString(); +// } +// +// +// @Test +// public void testGetResponse() throws Exception { +// PostCreateNewVnfWrapper testSubject; +// String result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.getResponse(); +// } +//}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerResponseWrappers/PostSubmitVnfChangeTimeSlotsWrapperTest.java b/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerResponseWrappers/PostSubmitVnfChangeTimeSlotsWrapperTest.java new file mode 100644 index 000000000..871d8997e --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerResponseWrappers/PostSubmitVnfChangeTimeSlotsWrapperTest.java @@ -0,0 +1,55 @@ +//package org.onap.vid.scheduler.SchedulerResponseWrappers; +// +//import org.junit.Test; +// +// +//public class PostSubmitVnfChangeTimeSlotsWrapperTest { +// +// private PostSubmitVnfChangeTimeSlotsWrapper createTestSubject() { +// return new PostSubmitVnfChangeTimeSlotsWrapper(); +// } +// +// +// @Test +// public void testGetUuid() throws Exception { +// PostSubmitVnfChangeTimeSlotsWrapper testSubject; +// String result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.getUuid(); +// } +// +// +// @Test +// public void testSetUuid() throws Exception { +// PostSubmitVnfChangeTimeSlotsWrapper testSubject; +// String v = ""; +// +// // default test +// testSubject = createTestSubject(); +// testSubject.setUuid(v); +// } +// +// +// @Test +// public void testToString() throws Exception { +// PostSubmitVnfChangeTimeSlotsWrapper testSubject; +// String result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.toString(); +// } +// +// +// @Test +// public void testGetResponse() throws Exception { +// PostSubmitVnfChangeTimeSlotsWrapper testSubject; +// String result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.getResponse(); +// } +//}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerResponseWrappers/SchedulerResponseWrapperTest.java b/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerResponseWrappers/SchedulerResponseWrapperTest.java new file mode 100644 index 000000000..495fb8abe --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerResponseWrappers/SchedulerResponseWrapperTest.java @@ -0,0 +1,77 @@ +//package org.onap.vid.scheduler.SchedulerResponseWrappers; +// +//import org.junit.Test; +// +// +//public class SchedulerResponseWrapperTest { +// +// private SchedulerResponseWrapper createTestSubject() { +// return new SchedulerResponseWrapper(); +// } +// +// +// @Test +// public void testGetEntity() throws Exception { +// SchedulerResponseWrapper testSubject; +// String result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.getEntity(); +// } +// +// +// @Test +// public void testGetStatus() throws Exception { +// SchedulerResponseWrapper testSubject; +// int result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.getStatus(); +// } +// +// +// @Test +// public void testSetStatus() throws Exception { +// SchedulerResponseWrapper testSubject; +// int v = 0; +// +// // default test +// testSubject = createTestSubject(); +// testSubject.setStatus(v); +// } +// +// +// @Test +// public void testSetEntity() throws Exception { +// SchedulerResponseWrapper testSubject; +// String v = ""; +// +// // default test +// testSubject = createTestSubject(); +// testSubject.setEntity(v); +// } +// +// +// @Test +// public void testToString() throws Exception { +// SchedulerResponseWrapper testSubject; +// String result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.toString(); +// } +// +// +// @Test +// public void testGetResponse() throws Exception { +// SchedulerResponseWrapper testSubject; +// String result; +// +// // default test +// testSubject = createTestSubject(); +// result = testSubject.getResponse(); +// } +//}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerRestInterfaceTest.java b/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerRestInterfaceTest.java new file mode 100644 index 000000000..5f861dfe4 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerRestInterfaceTest.java @@ -0,0 +1,26 @@ +package org.onap.vid.scheduler; + +import org.apache.poi.hssf.record.formula.functions.T; +import org.json.simple.JSONObject; +import org.junit.Test; + +public class SchedulerRestInterfaceTest { + + private SchedulerRestInterface createTestSubject() { + return new SchedulerRestInterface(); + } + + + + @Test + public void testLogRequest() throws Exception { + SchedulerRestInterface testSubject; + JSONObject requestDetails = null; + + // default test + testSubject = createTestSubject(); + testSubject.logRequest(requestDetails); + } + + +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/scheduler/rest/RequestDetailsTest.java b/vid-app-common/src/test/java/org/onap/vid/scheduler/rest/RequestDetailsTest.java new file mode 100644 index 000000000..aa634f93c --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/scheduler/rest/RequestDetailsTest.java @@ -0,0 +1,34 @@ +package org.onap.vid.scheduler.rest; + +import org.junit.Test; +import org.onap.vid.mso.rest.RequestDetails; + + +public class RequestDetailsTest { + + private RequestDetails createTestSubject() { + return new RequestDetails(); + } + + + /*@Test + public void testGetDomain() throws Exception { + RequestDetails testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getDomain(); + } + + + @Test + public void testSetDomain() throws Exception { + RequestDetails testSubject; + String domain = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setDomain(domain); + }*/ +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/scheduler/rest/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/scheduler/rest/TestSuite.java new file mode 100644 index 000000000..2bdeeb307 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/scheduler/rest/TestSuite.java @@ -0,0 +1,11 @@ +package org.onap.vid.scheduler.rest; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ RequestDetailsTest.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/selenium/FirstClass.java b/vid-app-common/src/test/java/org/onap/vid/selenium/FirstClass.java new file mode 100644 index 000000000..e3ccdd965 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/selenium/FirstClass.java @@ -0,0 +1,605 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.selenium; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.support.ui.Select; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; +import java.util.concurrent.TimeUnit; +import org.apache.log4j.Logger; +import org.testng.Assert; +import org.testng.asserts.*; + +/** + * The Class FirstClass. + */ +public class FirstClass { + + /** The login button. */ + WebElement loginButton; + + /** The eg. */ + String eg; + + /** The login. */ + WebElement login; + + /** The pwd. */ + WebElement pwd; + + /** The log. */ + Logger log; + + /** The errormessage. */ + WebElement errormessage; + + + /** The driver. */ + WebDriver driver=new FirefoxDriver(); + + + + /** The config prop. */ + private final Properties configProp = new Properties(); + + + /** + * Instantiates a new first class. + */ + private FirstClass() { + // TODO Auto-generated constructor stub + // + try{ + // InputStream input =this.getClass().getClassLoader().getResourceAsStream("objectmap.properties"); + //FileInputStream input1 = new FileInputStream("objectmap.properties"); + + InputStream input =new FileInputStream("objectconfig.properties"); + System.out.println("Read all properties from file"); + configProp.load(input); + System.out.println("Read all properties from file completed"); + } + catch(IOException e) { + + e.printStackTrace(); + } + } + + + /* + + + @BeforeClass + public void setUp() { + System.out.println("*******************"); + System.out.println("launching IE browser"); + System.setProperty("webdriver.ie.driver", driverPath+"IEDriverServer.exe"); + driver = new InternetExplorerDriver(); + driver.findElement(By.className()); + driver.manage().window().maximize(); + + + login = driver.findElement(By.xpath("//input[@class='fn-ebz-text ng-pristine ng-valid']")); + pwd = driver.findElement(By.xpath("//input[@class='span3 ng-pristine ng-valid']")); + loginButton = driver.findElement(By.id("loginBtn")); + } + + + */ + /** + * Sets the up. + */ + // TODO Auto-generated method stub + @BeforeClass + public void setUp() + { + + + //WebDriver driver=new FirefoxDriver(); + + log = Logger.getLogger(FirstClass.class.getName()); + + + + // Get url + driver.get(configProp.getProperty("baseURL")); + driver.manage().window().maximize(); + + + login = driver.findElement(By.xpath(configProp.getProperty("login"))); + + pwd = driver.findElement(By.xpath(configProp.getProperty("pwd"))); + loginButton = driver.findElement(By.id(configProp.getProperty("loginButton"))); + } + + + /** + * Empty username password. + */ + @Test(priority=1) + public void emptyUsernamePassword() + { + + + //User Name and Password field is empty + log.info("-----VID-11 TC-8----Username and password empty"); + loginButton.click(); + errormessage=driver.findElement(By.xpath("//*[@id='errorInfo']/span")); + String errmsg= errormessage.getText(); + //System.out.println("Error message is"+errmsg); + //String expected = "Invaild username or password, Please try again"; + + //Assert.assertEquals(errmsg,expected); + + Boolean str = driver.getPageSource().contains("Invalid username or password, Please try again"); + System.out.println(driver.getPageSource().contains("Invalid username or password, Please try again")); + + if(str==true) + { + log.info("Error message validated"); + log.info("VID-11 TC-8 PASSED"); + + }else + log.error("Failed validation"); + + } + + + + /** + * Invalid user name. + */ + @Test(priority=2) + public void invalidUserName() + { + + log.info("-----VID-11 TC-6----Invalid Username and Valid Password"); + + + login.sendKeys("xxx"); + pwd.sendKeys("abc123"); + loginButton.click(); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + String errmsg= errormessage.getText(); + String expected = "Invalid username or password, Please try again"; + Assert.assertEquals(errmsg,expected); + //Boolean str1 = driver.getPageSource().contains("Invalid username or password, Please try again"); + //System.out.print(str1); + + log.info("VID-11 TC-6 PASSED"); + + } + + + /** + * Invalid password. + */ + @Test(priority=3) + public void invalidPassword() + { + log.info("-----VID-11 TC-7----Valid Username and Invalid Password"); + // Valid user name and Invalid password. + login.clear(); + pwd.clear(); + login.sendKeys("testuser"); + pwd.sendKeys("xxx"); + loginButton.click(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + + + String errmsg= errormessage.getText(); + String expected = "Invalid username or password, Please try again"; + Assert.assertEquals(errmsg,expected); + + //Boolean str2 = driver.getPageSource().contains("Invaild username or password, Please try again"); + //System.out.print(str2); + + log.info("VID-11 TC-7 PASSED"); + } + + + /** + * Login successful. + */ + @Test(priority=4) + public void loginSuccessful() + { + log.info("-----VID-11 TC-1----Valid Username and Valid Password"); + //Login with valid user name and password. + login.clear(); + login.sendKeys("su"); + pwd.clear(); + pwd.sendKeys("fusion"); + + + loginButton.click(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + + try { + Thread.sleep(6000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances")); + log.info("VID-11 TC-1 PASSED"); + + } + + + /** + * Verify home page elements left pane. + */ + @Test(priority=5) + public void verifyHomePageElementsLeftPane() + + { + + + log.info("VID-10 TC 1 "); + //VID Home + log.info("VID 11 TC-2"); + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[1]/a/span")).isDisplayed(); + //Create New Service Instance + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[2]/a/span")).isDisplayed(); + + //Browse Service Type + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[3]/a/span")).isDisplayed(); + //View Log + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[4]/a/span")).isDisplayed(); + + //Profile + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[5]/a/span")).isDisplayed(); + //Admin + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[6]/a/span")).isDisplayed(); + //Logout + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[7]/a/span")).isDisplayed(); + + //Infrastructure Subscriber Name + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[1]/div/label")).isDisplayed(); + //Infrastructure Subscriber Name Select Drop down + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select")).isDisplayed(); + //Infrastructure Service Type + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[1]/div/label")).isDisplayed(); + //Infrastructure Service Type Select Drop down + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select")).isDisplayed(); + //Submit button + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[3]/td/div/button")).isDisplayed(); + + //Login Snippet Icon + driver.findElement(By.xpath(".//*[@class='icon-user-small login-snippet-icon']")).isDisplayed(); + + + //String bodyText = driver.findElement(By.tagName("body")).getText(); + //Assert.assertTrue("Text not found!", bodyText.contains("Search Existing Service Instances")); + //Assert.IsTrue(driver.getPageSource.Contains("Search Existing Service Instances")); + + log.info("VID-12 TC-1"); + Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances")); + Assert.assertTrue(driver.getPageSource().contains("Please search by the Subscriber name or Service Type from below:")); + log.info("VID-12 TC-1 PASSED"); + log.info("VID-10 TC 1 PASSED"); + log.info("VID-11 TC-2 PASSED"); + } + + + /** + * Disabled submit button. + */ + @Test(priority=6) + public void disabledSubmitButton() + { + log.info("VID-12 TC-13"); + //Assert submit button disabled. + Assert.assertFalse(driver.findElement(By.xpath(configProp.getProperty("submitButton"))).isEnabled()); + log.info("VID-12 TC-13 PASSED"); + + } + + /** + * Default list box value. + */ + @Test(priority=7) + public void defaultListBoxValue() + { + log.info("VID-12 TC-2"); + + + //WebElement subscribername =driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select")); + + Select oSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown")))); + Select iSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown")))); + + + WebElement ielement=iSelect.getFirstSelectedOption(); + WebElement oelement=oSelect.getFirstSelectedOption(); + String defaultsubscribername=oelement.getText(); + String defaultservicetype=ielement.getText(); + + Assert.assertEquals(defaultsubscribername,"Select Subscriber Name"); + Assert.assertEquals(defaultservicetype,"Select Service Type"); + + + + + //Verify Select Subscriber Name isDisplayed. + //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select/option[1]")).isSelected(); + + //Verify Select Service Type isDisplayed. + //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select/option[1]")).isSelected(); + + + log.info("VID-12 TC-2 PASSED"); + + } + + + + /** + * Select subscriber name drop down. + * + * @throws InterruptedException the interrupted exception + */ + @Test(priority=8) + public void selectSubscriberNameDropDown() throws InterruptedException + { + log.info("------------------VID-10 TC-2,VID-12 TC-11, VID-12 TC-9, VID 12 TC-10,VID-12 TC-6, VID 12 TC-5--------------------"); + + + driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown"))); + + driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown"))); + Thread.sleep(5000); + + //Infrastructure Subscriber Name + Select oSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown")))); + + List <WebElement> elementCount = oSelect.getOptions(); + log.info("Select Element Count of Service Name"); + System.out.println(elementCount.size()); + + + //Verifying getInfrastructureSubscribersList + log.info("VID-29 TC-1"); + Assert.assertTrue(elementCount.size()>0); + log.info("VID-29 TC-1 PASSED"); + + oSelect.selectByIndex(2); + String selectedOption = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown")))).getFirstSelectedOption().getText(); + + System.out.println("Service Name selected is " +selectedOption); + log.info("VID-10 TC-2 PASSED"); + + //Submit button is clicked + driver.findElement(By.xpath(configProp.getProperty("submitButton"))).click(); + + + //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:" + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed(); + //Assert.assertTrue(driver.getPageSource().contains("Selected Subscriber's Service Instance Details:")) + + + //Verify whether the page header is displayed "Global Customer ID" + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/thead/tr/th[2]/div")).isDisplayed(); + Assert.assertTrue(driver.getPageSource().contains("Global Customer ID")); + Assert.assertTrue(driver.getPageSource().contains("Subscriber Name")); + Assert.assertTrue(driver.getPageSource().contains("Service Type")); + Assert.assertTrue(driver.getPageSource().contains("Service Instance ID")); + + log.info("VID-12 TC-5 PASSED"); + log.info("VID-12 TC-11 PASSED"); + + WebElement serviceinstancetable =driver.findElement(By.xpath("//table[@class='tablesorter tablesorter-default ng-isolate-scope']")); + + List<WebElement> rows_table = serviceinstancetable.findElements(By.tagName("tr")); + //To calculate no of rows In table. + int rows_count = rows_table.size(); + + //Loop will execute till the last row of table. + for (int row=0; row<rows_count; row++){ + //To locate columns(cells) of that specific row. + List<WebElement> Columns_row = rows_table.get(row).findElements(By.tagName("td")); + //To calculate no of columns(cells) In that specific row. + int columns_count = Columns_row.size(); + //System.out.println("Number of cells In Row "+row+" are "+columns_count); + + //Loop will execute till the last cell of that specific row. + for (int column=0; column<columns_count; column++){ + //To retrieve text from that specific cell. + String celtext = Columns_row.get(column).getText(); + //System.out.println("Cell Value Of row number "+row+" and column number "+column+" Is "+celtext); + + + + //log.info("Testing Get column and row value"); + List <WebElement> exx= rows_table.get(1).findElements(By.tagName("td")); + eg=Columns_row.get(2).getText(); + // System.out.println("Cell value of row 1 and column 2 is" +eg); + } + } + + + + + //Verify View/Edit isDisplayed and Click + + driver.findElement(By.xpath("//a[@alt='View/Edit']")).isDisplayed(); + + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/tbody/tr[1]/td[1]/div/a")).click(); + + log.info("User clicked View/Edit"); + + //Verify the Subscriber Name displayed. + String header= driver.findElement(By.xpath("//h1[@class='heading1 ng-binding']")).getText(); + //System.out.println(header); + + + if(header.contains(eg)) + { + System.out.println("Header contains the subscriber name"); + }else + System.out.println("Header does not contain the subscriber name"); + + + + Assert.assertTrue(driver.getPageSource().contains("PerfTest Subscriber00020021")); + log.info("VID-12 TC-6 PASSED"); + + + + driver.navigate().back(); + //Cancel button isDisplayed + driver.findElement(By.xpath("//button[@class='button button--small button--primary']")).isDisplayed(); + log.info("VID-12 TC-9 PASSED"); + + //Cancel button is clicked + driver.findElement(By.xpath("//button[@class='button button--small button--primary']")).click(); + log.info("Cancel button is clicked"); + + //Verifying VID Home page is displayed + Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances")); + log.info("VID-12 TC-10 PASSED"); + + } + + + /** + * Refresh subscriber name. + */ + @Test(priority=9) + public void refreshSubscriberName() + { + log.info("VID-10 TC-4"); + + + driver.findElement(By.xpath(configProp.getProperty("refreshButtonSubscriberName"))).isDisplayed(); + + log.info("VID-10 TC-4 PASSED"); + + + } + + + /** + * Select subscriber type drop down. + * + * @throws InterruptedException the interrupted exception + */ + @Test(priority=9) + public void selectSubscriberTypeDropDown() throws InterruptedException + { + Thread.sleep(5000); + log.info("------------------VID-10 TC-3, VID-12 TC-12,--------------------"); + //Infrastructure Subscriber Type + Select iSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown")))); + + List <WebElement> ielementCount = iSelect.getOptions(); + log.info("Select Element Count of Service type"); + System.out.println(ielementCount.size()); + iSelect.selectByIndex(1); + + log.info("VID-10 TC-3 PASSED"); + + + //Submit button is clicked + driver.findElement(By.xpath(configProp.getProperty("submitButton"))).click(); + + //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:" + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed(); + //Assert.assertTrue(driver.getPageSource().contains("Selected Subscriber's Service Instance Details:")) + log.info("Page Header: Selected Subscriber's Service Instance Details"); + + + //Verify whether the page header is displayed "Global Customer ID" + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/thead/tr/th[2]/div")).isDisplayed(); + + //Assert.assertTrue(driver.getPageSource().contains("Global Customer ID")); + log.info("Table is displayed"); + + log.info("VID-12 TC-12 PASSED"); + + } + + + + /** + * Logout under profile. + */ + @Test(priority=10) + public void logoutUnderProfile() + { + + log.info("-----------VID-11 TC-5---------------------"); + //driver.findElement(By.partialLinkText("Click here to login")).click(); + //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + + + driver.findElement(By.xpath(".//*[@class='icon-user-small login-snippet-icon']")).click(); + driver.findElement(By.xpath(".//*[@id='reg-logout-div']/a")).click(); + //Validate that the user has logged out of VID. Displays "Portal" + Assert.assertTrue(driver.getPageSource().contains("Portal")); + + log.info("VID-11 TC-5 PASSED"); + + } + + + + /** + * Tear down. + */ + @AfterClass + public void tearDown() + { + driver.close(); + + } + + + + } + + + + diff --git a/vid-app-common/src/test/java/org/onap/vid/selenium/LogOutLeftPane.java b/vid-app-common/src/test/java/org/onap/vid/selenium/LogOutLeftPane.java new file mode 100644 index 000000000..19c6b1996 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/selenium/LogOutLeftPane.java @@ -0,0 +1,242 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.selenium; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import org.apache.log4j.Logger; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.support.ui.Select; +import org.testng.Assert; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +/** + * The Class LogOutLeftPane. + */ +@Test(enabled=false) +public class LogOutLeftPane { + + /** The login button. */ + WebElement loginButton; + + /** The login. */ + WebElement login; + + /** The pwd. */ + WebElement pwd; + + /** The log. */ + Logger log; + + /** The errormessage. */ + WebElement errormessage; + + /** The driver. */ + WebDriver driver=new FirefoxDriver(); + + + /** The config prop. */ + private final Properties configProp = new Properties(); + + + /** + * Instantiates a new log out left pane. + */ + private LogOutLeftPane() { + // TODO Auto-generated constructor stub + // + try{ + // InputStream input =this.getClass().getClassLoader().getResourceAsStream("objectmap.properties"); + //FileInputStream input1 = new FileInputStream("objectmap.properties"); + + InputStream input =new FileInputStream("objectconfig.properties"); + System.out.println("Read all properties from file"); + configProp.load(input); + System.out.println("Read all properties from file completed"); + } + catch(IOException e) { + + e.printStackTrace(); + } + } + + + + + /** + * Do before test. + */ + // TODO Auto-generated method stub + @BeforeTest + public void doBeforeTest() + { + //WebDriver driver=new FirefoxDriver(); + + log = Logger.getLogger(LogOutLeftPane.class.getName()); + + + + // Get url + driver.get("http://vid.onap.org:9080/vid/login_external.htm"); + driver.manage().window().maximize(); + + + login = driver.findElement(By.xpath("//input[@class='fn-ebz-text ng-pristine ng-valid']")); + pwd = driver.findElement(By.xpath("//input[@class='span3 ng-pristine ng-valid']")); + loginButton = driver.findElement(By.id("loginBtn")); + } + + + /** + * Expand collapse panel. + * + * @throws InterruptedException the interrupted exception + */ + @Test(priority=1) + public void expandCollapsePanel() throws InterruptedException + { + + + + login.clear(); + login.sendKeys("su"); + pwd.clear(); + pwd.sendKeys("fusion"); + //driver.findElement(By.partialLinkText("Click here to login")).click(); + //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + + loginButton.click(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + + + log.info("Clicking Profile link from left pane"); + Thread.sleep(3000); + System.out.println("properties file details --->"+configProp.getProperty("profilelink")); + driver.findElement(By.xpath(configProp.getProperty("profilelink"))).click(); + Thread.sleep(3000); + + //Verify whether the sub panel is displayed + //To verify the following :Search import from webphone and Self + driver.findElement(By.xpath(".//*[@id='panel4']")).isDisplayed(); + log.info("Expand and collapse passed for Profile link"); + + //For Admin + //Verify expand and collapse working for ADMIN + log.info("Clicking Admin link from left pane"); + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[6]/a/span")).click(); + //To verify the following: Roles, Roles Functions, Usages + driver.findElement(By.xpath(".//*[@id='panel5']")).isDisplayed(); + + + log.info("Expand and collapse passed for ADMIN link"); + + log.info("VID-11 TC-3 PASSED"); + + } + + + /** + * Drop down list. + * + * @throws InterruptedException the interrupted exception + */ + @Test(priority=2) + public void dropDownList() throws InterruptedException + { + //VID-12 TC-3 + log.info("VID-12 TC-3"); + //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select")); + + //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select")); + Thread.sleep(5000); + + //Infrastructure Subscriber Name + Select oSelect = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"))); + Select iSelect = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select"))); + + List <WebElement> elementCount = oSelect.getOptions(); + log.info("Subscriber Name Drop Down"); + System.out.println(elementCount.size()); + oSelect.selectByIndex(1); + log.info("Subscriber name selected"); + //String selectedOption = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"))).getFirstSelectedOption().getText(); + + + List <WebElement> count = iSelect.getOptions(); + log.info("Subscriber type drop down"); + System.out.println(count.size()); + oSelect.selectByIndex(1); + log.info("Subscriber type selected"); + + + + //Submit button is clicked + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[3]/td/div/button")).click(); + + + //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:" + driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed(); + log.info("VID-12 TC-3 PASSED"); + } + + + + + /** + * Logout left pane. + */ + @Test(priority=3) + public void logoutLeftPane() + { + //To Verify if the logout link redirects to Login page when clicked. + + + /*log.info("----------------VID-11 TC-4----------------"); + login.clear(); + login.sendKeys("testuser"); + pwd.clear(); + pwd.sendKeys("abc123"); + //driver.findElement(By.partialLinkText("Click here to login")).click(); + //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + + loginButton.click(); + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);*/ + log.info("----------------VID-11 TC-4----------------"); + driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[7]/a")).click(); + //Validate that the user has logged out of VID. Displays "Portal" + Assert.assertTrue(driver.getPageSource().contains("Portal")); + + log.info("VID 11 TC-4 PASSED"); + + driver.close(); + + } + +} diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java new file mode 100644 index 000000000..e73838c92 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java @@ -0,0 +1,69 @@ +package org.onap.vid.services; + +import static org.junit.Assert.*; +import java.util.*; + +import org.json.simple.JSONArray; +import org.junit.Assert; +import org.junit.Test; +import org.onap.vid.changeManagement.ChangeManagementRequest; +import org.onap.vid.changeManagement.RequestDetails; +import org.onap.vid.mso.rest.Request; +import org.springframework.http.ResponseEntity; + +public class ChangeManagementServiceImplTest { + + /*TODO: fix private ChangeManagementServiceImpl createTestSubject() { + return new ChangeManagementServiceImpl(); + }*/ + + + /*@Test + public void testGetMSOChangeManagements() throws Exception { + ChangeManagementServiceImpl testSubject; + Collection<Request> result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getMSOChangeManagements(); + } + + + @Test + public void testFindRequestByVnfName() throws Exception { + ChangeManagementServiceImpl testSubject;List<RequestDetails> requests = null; + String vnfName = ""; + RequestDetails result; + + // test 1 + testSubject=createTestSubject();requests = null; + result=Deencapsulation.invoke(testSubject, "findRequestByVnfName", new Object[]{List<RequestDetails>.class, vnfName}); + Assert.assertEquals(null, result); + }*/ +/* + + @Test + public void testDoChangeManagement() throws Exception { + ChangeManagementServiceImpl testSubject; + ChangeManagementRequest request = null; + String vnfName = ""; + ResponseEntity<String> result; + + // test 1 + testSubject = createTestSubject(); + request = null; + result = testSubject.doChangeManagement(request, vnfName); + Assert.assertEquals(null, result); + } + + + @Test + public void testGetSchedulerChangeManagements() throws Exception { + ChangeManagementServiceImpl testSubject; + JSONArray result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getSchedulerChangeManagements(); + }*/ +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceTest.java new file mode 100644 index 000000000..f3df4c6a9 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceTest.java @@ -0,0 +1,29 @@ +package org.onap.vid.services; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.vid.changeManagement.ChangeManagementRequest; +import org.onap.vid.changeManagement.ChangeManagementResponse; +import org.springframework.http.ResponseEntity; + +import junit.framework.Assert; + +import static org.junit.Assert.*; + + +public class ChangeManagementServiceTest { + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void doChangeManagement_requestTypeIsUpdateVnfNotFound_doUpdateAndReturnNull() throws Exception { + + } + +}
\ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java new file mode 100644 index 000000000..f692bdc6d --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java @@ -0,0 +1,107 @@ +package org.onap.vid.services; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.io.IOUtils; +import org.mockito.ArgumentCaptor; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.onap.vid.changeManagement.ChangeManagementRequest; +import org.onap.vid.controller.MsoConfig; +import org.onap.vid.controller.WebConfig; +import org.onap.vid.model.RequestReferencesContainer; +import org.onap.vid.mso.RestObject; +import org.onap.vid.mso.rest.MsoRestClientNew; +import org.onap.vid.mso.rest.RequestDetails; +import org.onap.vid.properties.AsdcClientConfiguration; +import org.onap.vid.services.ChangeManagementService; +import org.onap.vid.services.ChangeManagementServiceImpl; +import org.onap.vid.testUtils.RegExMatcher; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.springframework.test.context.web.WebAppConfiguration; +import org.testng.annotations.Test; + +import javax.inject.Inject; +import java.net.URL; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsEqual.equalTo; +import static org.hamcrest.core.IsInstanceOf.instanceOf; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.*; + + +@Test +@ContextConfiguration(classes = {WebConfig.class, AsdcClientConfiguration.class, SystemProperties.class, ChangeManagementServiceUnitTest.TestMsoConfig.class}) +@WebAppConfiguration +public class ChangeManagementServiceUnitTest extends AbstractTestNGSpringContextTests { + + private ObjectMapper objectMapper = new ObjectMapper(); + @Inject + private ChangeManagementService changeManagementService; + @Inject + private MsoRestClientNew restClientUnderTest; + + // @Test + void testInPlaceSoftwareUpdateRequest() throws Exception { + + + doReturn(new RestObject<RequestReferencesContainer>()).when(restClientUnderTest).PostForObject(anyObject(), anyString(), anyString(), anyObject()); + + URL requestJsonUrl = this.getClass().getResource("/services/change_management_software_update_request.json"); + ChangeManagementRequest changeManagementRequest = objectMapper.readValue(requestJsonUrl, ChangeManagementRequest.class); + changeManagementService.doChangeManagement(changeManagementRequest, "vidVnf"); + + ArgumentCaptor<String> endpointCaptor = ArgumentCaptor.forClass(String.class); + ArgumentCaptor<String> sourceIdCaptor = ArgumentCaptor.forClass(String.class); + ArgumentCaptor<Object> requestCaptor = ArgumentCaptor.forClass(Object.class); + ArgumentCaptor<Class> responseTypeCaptor = ArgumentCaptor.forClass(Class.class); + verify(restClientUnderTest).PostForObject(requestCaptor.capture(), sourceIdCaptor.capture(), endpointCaptor.capture(), responseTypeCaptor.capture()); + + org.onap.vid.changeManagement.RequestDetails expectedRequest = changeManagementRequest.getRequestDetails().get(0); + + String serviceInstanceId = expectedRequest.getRelatedInstList().get(0).getRelatedInstance().instanceId; + ; + String vnfInstanceId = expectedRequest.getVnfInstanceId(); + String regEx = String.format("/serviceInstances/v[0-9]+/%s/vnfs/%s/inPlaceSoftwareUpdate", serviceInstanceId, vnfInstanceId); + assertThat(endpointCaptor.getValue(), RegExMatcher.matchesRegEx(regEx)); + assertThat(requestCaptor.getValue(), instanceOf(RequestDetails.class)); + RequestDetails actualRequest = ((RequestDetails) requestCaptor.getValue()); + + assertThat(actualRequest.getCloudConfiguration().getTenantId(), equalTo(expectedRequest.getCloudConfiguration().getTenantId())); + assertThat(actualRequest.getCloudConfiguration().getLcpCloudRegionId(), equalTo(expectedRequest.getCloudConfiguration().getLcpCloudRegionId())); + assertThat(actualRequest.getRequestInfo(), equalTo(expectedRequest.getRequestInfo())); + assertThat(actualRequest.getRequestParameters(), equalTo(expectedRequest.getRequestParameters())); + + URL expectedMsoRequestUrl = this.getClass().getResource("/services/change_management_software_update_expected_mso_request.json"); + String expectedMsoRequestString = IOUtils.toString(expectedMsoRequestUrl, "UTF-8"); + String actualRequestString = objectMapper.writeValueAsString(actualRequest); + try { + JSONAssert.assertEquals("built mso request is not ok", expectedMsoRequestString, actualRequestString, JSONCompareMode.NON_EXTENSIBLE); + } catch (AssertionError | Exception e) { + System.out.println("requestDetailsAsString: \n" + actualRequestString); + System.out.println("expected: \n" + expectedMsoRequestString); + throw e; + } + + } + + @Configuration + public static class TestMsoConfig extends MsoConfig { + + @Override + public MsoRestClientNew getMsoClient() { + MsoRestClientNew spyClient = spy(new MsoRestClientNew()); + return spyClient; + } + + @Bean + public ChangeManagementService getChangeManagementService() { + return new ChangeManagementServiceImpl(null, getMsoBusinessLogic()); + } + } +} diff --git a/vid-app-common/src/test/java/org/onap/vid/services/CsvServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/services/CsvServiceTest.java new file mode 100644 index 000000000..051a1cf45 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/services/CsvServiceTest.java @@ -0,0 +1,80 @@ +//package org.onap.vid.services; +//import org.apache.commons.io.IOUtils; +//import org.onap.vid.services.CsvServiceImpl; +//import org.skyscreamer.jsonassert.JSONAssert; +//import org.skyscreamer.jsonassert.JSONCompareMode; +//import org.testng.Assert; +//import org.testng.annotations.DataProvider; +//import org.testng.annotations.Test; +//import org.json.JSONObject; +// +//import javax.ws.rs.BadRequestException; +//import java.io.IOException; +//import java.lang.reflect.Method; +//import java.net.URL; +//import java.util.List; +// +//@Test +//public class CsvServiceTest { +// +// private CsvServiceImpl csvService = new CsvServiceImpl(); +// private final static String CSV_FOLDER = "csv_files/{CSV_FILE}"; +// private final static String VALID_CSV = "csv_to_json.csv"; +// private final static String ONE_LINE_CSV = "one_line.csv"; +// private final static String EMPTY_CSV = "empty_file.csv"; +// private final static String MISSING_CONTENT_CSV = "missing_content.csv"; +// private final static String MISSING_VALUES_CSV = "missing_values.csv"; +// +// +///* +// @Test +// public void parseValidCsv() throws IllegalAccessException, IOException, InstantiationException { +// String expectedJson = getExpectation("vnfConfigUpdatePayload.json"); +// readAndParse(VALID_CSV,16,expectedJson); +// +// }*/ +// +// private String getExpectation(String modelFileName) throws IOException { +// // load expected result +// final URL resource = this.getClass().getResource("/" + modelFileName); +// String expected = IOUtils.toString(resource, "UTF-8"); +// return expected; +// } +///* +// @Test +// public void parseOneLineCsv() throws IllegalAccessException, IOException, InstantiationException { +// String expectedJson ="{\"payload\":{\"request-parameters\":{\"vnf-name\":\"ibcx0099v\"}}}"; +// readAndParse(ONE_LINE_CSV,1,expectedJson); +// }*/ +// +// @DataProvider +// public static Object[][] invalidFiles(Method test) { +// return new Object[][]{ +// {MISSING_CONTENT_CSV}, {MISSING_VALUES_CSV} +// }; +// } +///* +// @Test(dataProvider = "invalidFiles", expectedExceptions = {BadRequestException.class}, expectedExceptionsMessageRegExp = "Invalid csv file") +// public void parseMissingContentCsv(String invalidFile) throws IllegalAccessException, IOException, InstantiationException { +// readAndParse(invalidFile, 2, null); +// } +// +// +// @Test +// public void parseEmptyCsv() throws IllegalAccessException, IOException, InstantiationException { +// String expectedJson ="{}"; +// readAndParse(EMPTY_CSV,0,expectedJson); +// } +// +// private void readAndParse(String fileName, int expectedNumRows, String expectedJson) throws IllegalAccessException, IOException, InstantiationException { +// final URL resource = CsvServiceTest.class.getClassLoader().getResource(CSV_FOLDER.replaceFirst("\\{CSV_FILE\\}", fileName)); +// Assert.assertNotNull(resource, "The csv file was not found"); +// List<String[]> content = csvService.readCsv(resource.getPath()); +// Assert.assertEquals(content.size(), expectedNumRows, "The number of non-empty lines in file is wrong"); +// JSONObject json = csvService.convertCsvToJson (content); +// JSONAssert.assertEquals(expectedJson, json, JSONCompareMode.STRICT); +// +// }*/ +// +// +//} diff --git a/vid-app-common/src/test/java/org/onap/vid/services/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/services/TestSuite.java new file mode 100644 index 000000000..e43432467 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/services/TestSuite.java @@ -0,0 +1,11 @@ +package org.onap.vid.services; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( + +{ ChangeManagementServiceImplTest.class, ChangeManagementServiceTest.class }) +public class TestSuite { // nothing +} diff --git a/vid-app-common/src/test/java/org/onap/vid/testUtils/IntersectionTest.java b/vid-app-common/src/test/java/org/onap/vid/testUtils/IntersectionTest.java new file mode 100644 index 000000000..c766d26f3 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/IntersectionTest.java @@ -0,0 +1,101 @@ +package org.onap.vid.testUtils; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.vid.utils.Intersection; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by moriya1 on 10/10/2017. + */ +public class IntersectionTest { + + @Test + public void testFourArrays(){ + List<String> l1 = new ArrayList<String>(); + l1.add("1"); + l1.add("2"); + + List<String> l2 = new ArrayList<String>(); + l2.add("2"); + l2.add("3"); + + List<String> l3 = new ArrayList<String>(); + l3.add("2"); + l3.add("4"); + + List<String> l4 = new ArrayList<String>(); + l4.add("2"); + l4.add("5"); + + List<List<String>> all = new ArrayList<>(); + all.add(l1); + all.add(l2); + all.add(l3); + all.add(l4); + Intersection<String> m = new Intersection<>(); + List<String> ans = m.intersectMultipileArray(all); + Assert.assertEquals(1,ans.size()); + Assert.assertEquals(ans.get(0),"2"); + + } + + + + @Test + public void testTwoArrays(){ + List<String> l1 = new ArrayList<String>(); + l1.add("1"); + l1.add("2"); + + List<String> l2 = new ArrayList<String>(); + l2.add("2"); + l2.add("3"); + + List<List<String>> all = new ArrayList<>(); + all.add(l1); + all.add(l2); + Intersection<String> m = new Intersection<>(); + List<String> l3 = m.intersectMultipileArray(all); + Assert.assertEquals(l3.size(),1); + Assert.assertEquals(l3.get(0),"2"); + + } + + + @Test + public void testNoIntersection(){ + List<String> l1 = new ArrayList<String>(); + l1.add("1"); + l1.add("2"); + + List<String> l2 = new ArrayList<String>(); + l2.add("3"); + l2.add("4"); + + List<List<String>> all = new ArrayList<>(); + all.add(l1); + all.add(l2); + Intersection<String> m = new Intersection<>(); + List<String> l3 = m.intersectMultipileArray(all); + Assert.assertEquals(l3.size(),0); + + } + + @Test + public void testOneArrays(){ + List<String> l1 = new ArrayList<String>(); + l1.add("1"); + l1.add("2"); + List<List<String>> all = new ArrayList<>(); + all.add(l1); + Intersection<String> m = new Intersection<>(); + List<String> l3 = m.intersectMultipileArray(all); + Assert.assertEquals(l3.size(),2); + Assert.assertEquals(l3.get(0),"1"); + Assert.assertEquals(l3.get(1),"2"); + + } +} diff --git a/vid-app-common/src/test/java/org/onap/vid/testUtils/RegExMatcher.java b/vid-app-common/src/test/java/org/onap/vid/testUtils/RegExMatcher.java new file mode 100644 index 000000000..c88c8a835 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/RegExMatcher.java @@ -0,0 +1,29 @@ +package org.onap.vid.testUtils; + +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; + +public class RegExMatcher extends TypeSafeMatcher<String> { + + private final String regEx; + + public RegExMatcher(String regEx) { + this.regEx = regEx; + } + + + @Override + public void describeTo(Description description) { + description.appendText("matches regEx="+regEx); + } + + + @Override + protected boolean matchesSafely(String item) { + return item.matches(regEx); + } + + public static RegExMatcher matchesRegEx(final String regEx) { + return new RegExMatcher(regEx); + } +} diff --git a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java new file mode 100644 index 000000000..73a79cd21 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java @@ -0,0 +1,68 @@ +package org.onap.vid.testUtils; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.junit.Assert; + +import java.util.Iterator; + +import static fj.parser.Parser.fail; + +/** + * Created by Oren on 6/7/17. + */ +public class TestUtils { + + /** + * The method compares between two jsons. the function assert that the actual object does not reduce or change the functionallity/parsing of the expected json. + * This means that if the expected JSON has a key which is null or the JSON doesn't have a key which contained in the expected JSON the assert will succeed and the will pass. + * For example : For JSON expected = {a:null} and actual {a:3} the test will pass + * Other example : For JSON expected = {a:3} and actual {a:null} the test will fail + * + * @param expected JSON + * @param actual JSON + */ + public static void assertJsonStringEqualsIgnoreNulls(String expected, String actual) { + if (expected == null || expected == JSONObject.NULL) {return;} + + JSONObject expectedJSON = new JSONObject(expected); + JSONObject actualJSON = new JSONObject(actual); + Iterator<?> keys = expectedJSON.keys(); + + while( keys.hasNext() ) { + String key = (String)keys.next(); + Object expectedValue = expectedJSON.get(key); + if (expectedValue == JSONObject.NULL){ + continue; + } + + Object actualValue = actualJSON.get(key); + + if (expectedValue instanceof JSONObject) { + String expectedVal = expectedValue.toString(); + String actualVal = actualValue.toString(); + assertJsonStringEqualsIgnoreNulls(expectedVal, actualVal); + } + else if (expectedValue instanceof JSONArray) { + if (actualValue instanceof JSONArray) { + JSONArray expectedJSONArray = (JSONArray)expectedValue; + JSONArray actualJSONArray = (JSONArray)actualValue; + for (int i = 0; i < expectedJSONArray.length(); i++) { + String expectedItem = expectedJSONArray.get(i).toString(); + String actualItem = actualJSONArray.get(i).toString(); + if (expectedValue instanceof JSONObject) + assertJsonStringEqualsIgnoreNulls(expectedItem, actualItem); + } + } + else { + fail("expected: " + expectedValue + " got:" + actualValue); + } + } + else { + Assert.assertEquals(expectedValue, actualValue); + } + } + } + + +} |